Browse Source

优惠券-详情优化,添加排序快捷编辑

master
liangyuyan 5 years ago
parent
commit
d968ebebec
  1. 118
      app/Admin/Controllers/v3/CouponController.php
  2. 5
      resources/lang/zh-CN/coupon.php

118
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,23 +104,24 @@ 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){
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->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');
@ -129,32 +129,67 @@ class CouponController extends AdminController
}
return $text;
});
$show->type_text;
$show->category_text;
$show->market_ids->as(function($marketId){
$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 = '全部市场';
if($marketId > 0){
$market = marketModel::select('name')->find($marketId)->toArray();
$text = $market ? $market['name'] : $text ;
}
return $text;
});
// $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->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');

5
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' => [
],

Loading…
Cancel
Save