调整售后单标签
parent
dca972a2f9
commit
7b94a0bcf3
|
|
@ -0,0 +1,35 @@
|
|||
<?php
|
||||
|
||||
namespace App\Admin\Actions\Grid;
|
||||
|
||||
use App\Admin\Forms\Tags\AfterSaleTag as AfterSaleTagForm;
|
||||
use App\Models\AfterSale;
|
||||
use Dcat\Admin\Grid\RowAction;
|
||||
use Dcat\Admin\Widgets\Modal;
|
||||
|
||||
class AfterSaleSetTag extends RowAction
|
||||
{
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
protected $title = '<i class="feather icon-tag grid-action-icon"></i>';
|
||||
|
||||
public function title()
|
||||
{
|
||||
if ($this->title) {
|
||||
return $this->title.' 标签';
|
||||
}
|
||||
|
||||
return '标签';
|
||||
}
|
||||
|
||||
public function render()
|
||||
{
|
||||
$form = AfterSaleTagForm::make()->payload(['id'=>$this->getKey(), 'type'=>AfterSale::class]);
|
||||
return Modal::make()
|
||||
->lg()
|
||||
->title($this->title())
|
||||
->body($form)
|
||||
->button($this->title());
|
||||
}
|
||||
}
|
||||
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
namespace App\Admin\Controllers;
|
||||
|
||||
use App\Admin\Actions\Grid\AfterSaleSetTag;
|
||||
use App\Admin\Actions\Show\AfterSaleFinance;
|
||||
use App\Admin\Actions\Show\AfterSaleFinanceShipping;
|
||||
use App\Admin\Actions\Show\AfterSaleShipping;
|
||||
|
|
@ -11,6 +12,8 @@ use App\Admin\Actions\Show\AfterSaleVerify;
|
|||
use App\Admin\Repositories\AfterSale;
|
||||
use App\Models\AfterSale as AfterSaleModel;
|
||||
use App\Models\AfterSaleLog;
|
||||
use App\Models\Tag;
|
||||
use Dcat\Admin\Admin;
|
||||
use Dcat\Admin\Form;
|
||||
use Dcat\Admin\Grid;
|
||||
use Dcat\Admin\Http\Controllers\AdminController;
|
||||
|
|
@ -26,12 +29,19 @@ class AfterSaleController extends AdminController
|
|||
*/
|
||||
protected function grid()
|
||||
{
|
||||
$builder = AfterSale::with(['user', 'order', 'orderProduct']);
|
||||
$builder = AfterSale::with(['user', 'order', 'orderProduct', 'tags']);
|
||||
return Grid::make($builder, function (Grid $grid) {
|
||||
$grid->column('id')->sortable();
|
||||
$grid->column('sn');
|
||||
$grid->column('tags', '标签')->display(function ($tags) {
|
||||
$array = [];
|
||||
foreach ($this->tags as $key => $tag) {
|
||||
$array[] = $tag->name;
|
||||
}
|
||||
return $array;
|
||||
})->label();
|
||||
$grid->column('user.phone');
|
||||
$grid->column('order.sn');
|
||||
$grid->column('sn');
|
||||
|
||||
$grid->column('orderProduct.name');
|
||||
$grid->column('num');
|
||||
$grid->column('amount')->display(function ($value) {
|
||||
|
|
@ -64,12 +74,16 @@ class AfterSaleController extends AdminController
|
|||
]);
|
||||
// $grid->column('remarks');
|
||||
// $grid->column('tracking_number');
|
||||
|
||||
$grid->column('created_at');
|
||||
$grid->column('updated_at')->sortable();
|
||||
$grid->model()->orderBy('created_at', 'desc');
|
||||
|
||||
$grid->actions(function (Grid\Displayers\Actions $actions) {
|
||||
$actions->disableView(false);
|
||||
if (Admin::user()->can('dcat.admin.after_sales.tags')) {
|
||||
$actions->append(new AfterSaleSetTag());
|
||||
}
|
||||
});
|
||||
|
||||
$grid->filter(function (Grid\Filter $filter) {
|
||||
|
|
@ -86,6 +100,11 @@ class AfterSaleController extends AdminController
|
|||
$filter->equal('user.phone')->width(3);
|
||||
$filter->equal('order.sn')->width(3);
|
||||
$filter->equal('sn')->width(3);
|
||||
$filter->where('tags', function ($query) {
|
||||
$query->whereHas('tags', function ($q) {
|
||||
$q->whereIn('tags.id', $this->input);
|
||||
});
|
||||
}, '标签')->multipleSelect(Tag::AfterSaleTag()->pluck('name', 'id'))->width(3);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
@ -101,13 +120,16 @@ class AfterSaleController extends AdminController
|
|||
{
|
||||
return function (Row $row) use ($id) {
|
||||
$row->column(4, function ($column) use ($id) {
|
||||
$builder = AfterSale::with(['user', 'order', 'orderProduct']);
|
||||
$builder = AfterSale::with(['user', 'order', 'orderProduct', 'tags']);
|
||||
$column->row(Show::make($id, $builder, function (Show $show) {
|
||||
$show->field('id');
|
||||
$show->field('sn');
|
||||
$show->field('order.sn');
|
||||
$show->field('user.phone');
|
||||
$show->field('order_product.name');
|
||||
$show->field('tags')->as(function () {
|
||||
return $this->tags->pluck('name');
|
||||
})->label();
|
||||
$show->field('num');
|
||||
if (in_array($show->model()->type, [AfterSaleModel::TYPE_REFUND_AND_RETURN, AfterSaleModel::TYPE_REFUND])) {
|
||||
$show->field('amount')->as(function ($amount) {
|
||||
|
|
|
|||
|
|
@ -129,7 +129,7 @@ class OrderController extends AdminController
|
|||
{
|
||||
return function (Row $row) use ($id) {
|
||||
$row->column(5, function ($column) use ($id) {
|
||||
$builder = Order::with(['user', 'userCoupon']);
|
||||
$builder = Order::with(['user', 'userCoupon', 'tags']);
|
||||
$column->row(Show::make($id, $builder, function (Show $show) {
|
||||
// $show->field('id');
|
||||
$show->field('sn');
|
||||
|
|
@ -166,7 +166,9 @@ class OrderController extends AdminController
|
|||
'无'=>'#b3b9bf',
|
||||
]);
|
||||
$show->field('pay_at');
|
||||
|
||||
$show->field('tags')->as(function () {
|
||||
return $this->tags->pluck('name');
|
||||
})->label();
|
||||
$show->divider();
|
||||
$show->field('consignee_name');
|
||||
$show->field('consignee_telephone');
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ class TagController extends AdminController
|
|||
$grid->column('type')->using([
|
||||
TagModel::TYPE_ORDER =>'订单',
|
||||
TagModel::TYPE_PACKAGE=>'货运',
|
||||
// TagModel::TYPE_AFTER_SALE=>'售后',
|
||||
TagModel::TYPE_AFTER_SALE=>'售后',
|
||||
])->label();
|
||||
$grid->column('name');
|
||||
$grid->column('created_at')->sortable();
|
||||
|
|
@ -55,7 +55,7 @@ class TagController extends AdminController
|
|||
$filter->equal('type')->select([
|
||||
TagModel::TYPE_ORDER =>'订单',
|
||||
TagModel::TYPE_PACKAGE =>'货运',
|
||||
// 3=>'售后',
|
||||
TagModel::TYPE_AFTER_SALE =>'售后',
|
||||
])->width(3);
|
||||
});
|
||||
});
|
||||
|
|
@ -92,7 +92,7 @@ class TagController extends AdminController
|
|||
$form->radio('type')->options([
|
||||
TagModel::TYPE_ORDER =>'订单',
|
||||
TagModel::TYPE_PACKAGE=>'货运',
|
||||
// 3=>'售后',
|
||||
TagModel::TYPE_AFTER_SALE =>'售后',
|
||||
])->default($type)->required();
|
||||
$form->text('name')->required();
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,15 @@
|
|||
<?php
|
||||
|
||||
namespace App\Admin\Forms\Tags;
|
||||
|
||||
use Dcat\Admin\Traits\LazyWidget;
|
||||
|
||||
class AfterSaleTag extends Tag
|
||||
{
|
||||
use LazyWidget;
|
||||
|
||||
protected function authorize($user): bool
|
||||
{
|
||||
return $user->can('dcat.admin.after_sales.tags');
|
||||
}
|
||||
}
|
||||
|
|
@ -44,6 +44,7 @@ class Tag extends Form implements LazyRenderable
|
|||
$type = $this->payload['type'];
|
||||
$tags = Taggable::where('taggable_id', $id)->where('taggable_type', $type)->get();
|
||||
$scopeTag = lcfirst(class_basename($type)).'Tag';
|
||||
|
||||
$this->multipleSelect('tags')
|
||||
->options(TagModel::$scopeTag()->pluck('name', 'id'))
|
||||
->customFormat(function () use ($tags) {
|
||||
|
|
|
|||
|
|
@ -86,6 +86,11 @@ class AfterSale extends Model
|
|||
return $this->hasMany(AfterSaleLog::class, 'after_sale_id');
|
||||
}
|
||||
|
||||
public function tags()
|
||||
{
|
||||
return $this->belongsToMany(Tag::class, 'taggables', 'taggable_id', 'tag_id')->wherePivot('taggable_type', self::class)->withTimestamps();
|
||||
}
|
||||
|
||||
/**
|
||||
* 确认此售后单是否是换货
|
||||
*
|
||||
|
|
|
|||
|
|
@ -43,4 +43,9 @@ class Tag extends Model
|
|||
{
|
||||
return $this->where('type', self::TYPE_PACKAGE);
|
||||
}
|
||||
|
||||
public function scopeAfterSaleTag()
|
||||
{
|
||||
return $this->where('type', self::TYPE_AFTER_SALE);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -50,6 +50,16 @@ class AdAddressSeeder extends Seeder
|
|||
'dimensions'=> '375*200',
|
||||
'is_show' => true,
|
||||
],
|
||||
'share_register_banner' => [
|
||||
'name' => '分享注册位',
|
||||
'dimensions'=> '',
|
||||
'is_show' => true,
|
||||
],
|
||||
'share_download_banner' => [
|
||||
'name' => '分享下载位',
|
||||
'dimensions'=> '',
|
||||
'is_show' => true,
|
||||
],
|
||||
] as $key => $values) {
|
||||
AdAddress::firstOrCreate(['key' => $key], $values);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -210,6 +210,11 @@ class AdminMenuSeeder extends Seeder
|
|||
'icon' => '',
|
||||
'uri' => 'after-sales',
|
||||
],
|
||||
[
|
||||
'title' =>'售后标签',
|
||||
'icon' => '',
|
||||
'uri' => 'tags?type=3',
|
||||
],
|
||||
],
|
||||
],
|
||||
[
|
||||
|
|
|
|||
|
|
@ -178,6 +178,7 @@ class AdminPermissionSeeder extends Seeder
|
|||
'verify'=>['name' =>'审核'],
|
||||
'shipping'=>['name' =>'确认收货'],
|
||||
'finance'=>['name' =>'确认打款'],
|
||||
'tags'=>['name' =>'标签设置'],
|
||||
],
|
||||
],
|
||||
'messages'=>[
|
||||
|
|
|
|||
|
|
@ -35,6 +35,7 @@ return [
|
|||
'remarks3' => '备注',
|
||||
'tracking_number' => '运单号',
|
||||
'created_at'=>'申请时间',
|
||||
'tags' => '标签',
|
||||
],
|
||||
'options' => [
|
||||
],
|
||||
|
|
|
|||
Loading…
Reference in New Issue