From d968ebebec6b590dd6ae59afb697d646721a5a05 Mon Sep 17 00:00:00 2001 From: liangyuyan <1103300295@qq.com> Date: Tue, 20 Oct 2020 10:22:50 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E6=83=A0=E5=88=B8-=E8=AF=A6=E6=83=85?= =?UTF-8?q?=E4=BC=98=E5=8C=96=EF=BC=8C=E6=B7=BB=E5=8A=A0=E6=8E=92=E5=BA=8F?= =?UTF-8?q?=E5=BF=AB=E6=8D=B7=E7=BC=96=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Admin/Controllers/v3/CouponController.php | 138 +++++++++++------- resources/lang/zh-CN/coupon.php | 5 +- 2 files changed, 91 insertions(+), 52 deletions(-) diff --git a/app/Admin/Controllers/v3/CouponController.php b/app/Admin/Controllers/v3/CouponController.php index adb5a62..78c4a84 100644 --- a/app/Admin/Controllers/v3/CouponController.php +++ b/app/Admin/Controllers/v3/CouponController.php @@ -10,12 +10,10 @@ use Dcat\Admin\Form; use Dcat\Admin\Grid; use Dcat\Admin\Show; use Dcat\Admin\Controllers\AdminController; -use App\Models\v3\CouponReceiveType as ReceiveTypeModel; use App\Models\v3\CouponSetting as SettingModel; use App\Models\v3\Coupon as CouponModel; use App\Models\v3\Market as MarketModel; use App\Models\v3\Category as CategoryModel; -use Dcat\Admin\Form\NestedForm; use App\Models\v3\CouponUse as UseModel; class CouponController extends AdminController @@ -47,6 +45,7 @@ class CouponController extends AdminController return $item; }); $grid->active_type_text; + $grid->weigh->editable(); $grid->status ->using( CouponModel::$status @@ -105,56 +104,92 @@ class CouponController extends AdminController protected function detail($id) { $builder = CouponModel::with('receiveType'); - return Show::make($id, $builder, function (Show $show) use($id){ - $show->id; - $show->title; - $show->introduce; - $show->full_amount; - $show->discounts; - $show->discount_type_text; - $show->inventory; - $show->inventory_use; - - $show->start_time_text; - $show->end_time_text; - $show->usable_start_time_text; - $show->usable_end_time_text; - - $show->active_type_text; - $show->column('receive_type.receive_type','')->as(function($receiveTypeId) use($show){ - $text = ''; - if($receiveTypeId > 0){ - $receiveTypeName = SettingModel::getSettingInfo($receiveTypeId,'name'); - $text = $receiveTypeName ? $receiveTypeName : $text; - } - return $text; - }); - $show->type_text; - $show->category_text; - $show->market_ids->as(function($marketId){ - $text = '全部市场'; - if($marketId > 0){ - $market = marketModel::select('name')->find($marketId)->toArray(); - $text = $market ? $market['name'] : $text ; - } - return $text; + return Show::make($id, $builder, function (Show $show){ + $show->row(function(Show\Row $show){ + $show->width(6)->id; + $show->width(6)->title; + $show->width(6)->introduce; + $show->width(6)->full_amount; + $show->width(6)->discounts; + $show->width(6)->discount_type_text; + $show->width(6)->inventory; + $show->width(6)->inventory_use; }); - // $show->category_ids->as(function($storeTypeId){ - // $text = '全部类型'; - // if($storeTypeId > 0){ - // $storeType = storeTypeModel::select('type_name')->find($storeTypeId)->toArray(); - // $text = $storeType ? $storeType['type_name'] : $text ; - // } - // return $text; - // }); - $show->is_new_user_text; + $show->row(function(Show\Row $show){ + $show->width(6)->start_time_text; + $show->width(6)->end_time_text; + $show->width(6)->usable_start_time_text; + $show->width(6)->usable_end_time_text; + $show->width(6)->active_type_text; + $show->width(6)->column('receive_type.receive_type','领取方式')->as(function($receiveTypeId) { + $text = ''; + if($receiveTypeId > 0){ + $receiveTypeName = SettingModel::getSettingInfo($receiveTypeId,'name'); + $text = $receiveTypeName ? $receiveTypeName : $text; + } + return $text; + }); + $show->width(6)->type_text; + $show->width(6)->category_text; + $show->width(6)->market_ids->as(function($marketIds){ + $text = ''; + if(!empty($marketIds)){ + $market = marketModel::whereIn('id',$marketIds)->pluck('name')->toArray(); + foreach($market as $value){ + $value = $value ?? ''; + $text .= '['.$value.'] '; + } + }else{ + $text = '全部市场'; + } + return $text; + }); + $show->category_ids->as(function($categoryIds){ + $text = ''; + if(!empty($categoryIds)){ + $market = CategoryModel::whereIn('id',$categoryIds)->pluck('title')->toArray(); + foreach($market as $value){ + $value = $value ?? ''; + $text .= '['.$value.'] '; + } + }else{ + $text = '全部分类'; + } + return $text; + }); + $show->activity_available->as(function($activityAvailable){ + $text = ''; + $activityAvailable = json_decode($activityAvailable); + if(!empty($activityAvailable)){ + foreach($activityAvailable as $value){ + $value = CouponModel::$activityAvailable[$value] ?? ''; + $text .= '['.$value.'] '; + } + } + return $text; + }); + $show->tags->as(function($tags){ + $text = ''; + $tags = json_decode($tags); + if(!empty($tags)){ + foreach($tags as $value){ + $value = $value ?? ''; + $text .= '['.$value.'] '; + } + } + return $text; + }); + $show->width(6)->is_new_user_text; - $show->usable_number; - $show->weigh; - $show->remark; - $show->status_text; - $show->created_at_text; - $show->updated_at_text; + $show->width(6)->usable_number; + $show->width(6)->weigh; + $show->width(6)->remark; + + $show->width(6)->created_at_text; + $show->width(6)->updated_at_text; + + $show->width(6)->status_text; + }); $show->panel()->tools(function ($tools) { $tools->disableEdit(); @@ -228,7 +263,7 @@ class CouponController extends AdminController }); $form->column(12,function(Form $form){ - $form->tags('activity_available','可用活动')->options(CouponModel::$activityAvailable); + $form->multipleSelect('activity_available','可用活动')->options(CouponModel::$activityAvailable); $form->tags('tags','标签')->options(['新人专享','满39减10','满19减5']); $form->text('remark')->maxLength(500,'最多只能输入500个字')->default(''); }); @@ -238,6 +273,7 @@ class CouponController extends AdminController $form->disableViewCheck(); $form->disableEditingCheck(); $form->disableCreatingCheck(); + $form->disableDeleteButton(); /* 不显示字段 */ $form->hidden('id'); diff --git a/resources/lang/zh-CN/coupon.php b/resources/lang/zh-CN/coupon.php index 27cf7a7..be12add 100644 --- a/resources/lang/zh-CN/coupon.php +++ b/resources/lang/zh-CN/coupon.php @@ -40,7 +40,10 @@ return [ 'receive_type_text' => '领取方式', 'created_at_text' => '创建时间', 'updated_at_text' => '更新时间', - 'use_number' => '已使用数量' + 'use_number' => '已使用数量', + 'activity_available' => '可用活动', + 'tags' => '标签', + 'receive_type.receive_type' => '领取方式', ], 'options' => [ ],