From 65bbf49cdc43d9c00c939f1dee72b612041b7b1e Mon Sep 17 00:00:00 2001 From: vine_liutk <961510893@qq.com> Date: Wed, 8 Dec 2021 11:01:29 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4=E9=83=A8=E5=88=86=E5=86=85?= =?UTF-8?q?=E5=AE=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Admin/Actions/Grid/SkuList.php | 2 +- .../Controllers/ArticleCategoryController.php | 5 +- .../Controllers/ProductSpuController.php | 7 +- app/Admin/Extensions/Column/Modal.php | 81 +++++++++++++++++++ app/Admin/Renderable/CouponRangeTable.php | 1 + app/Admin/Renderable/ProductSkuTable.php | 1 + app/Admin/bootstrap.php | 4 + 7 files changed, 97 insertions(+), 4 deletions(-) create mode 100644 app/Admin/Extensions/Column/Modal.php diff --git a/app/Admin/Actions/Grid/SkuList.php b/app/Admin/Actions/Grid/SkuList.php index f07a2e09..1d134b7f 100644 --- a/app/Admin/Actions/Grid/SkuList.php +++ b/app/Admin/Actions/Grid/SkuList.php @@ -45,6 +45,6 @@ class SkuList extends RowAction return $this->response() // ->success('Processed successfully: '.$this->getKey()) - ->redirect(admin_route('product_spus.list', ['spu' =>$this->getKey()])); + ->redirect(admin_route('product_spus.sku_list', ['spu' =>$this->getKey()])); } } diff --git a/app/Admin/Controllers/ArticleCategoryController.php b/app/Admin/Controllers/ArticleCategoryController.php index 6c1178dd..996fbcad 100644 --- a/app/Admin/Controllers/ArticleCategoryController.php +++ b/app/Admin/Controllers/ArticleCategoryController.php @@ -63,7 +63,10 @@ class ArticleCategoryController extends AdminController $grid->actions(function (Grid\Displayers\Actions $actions) { $actions->disableDelete(Admin::user()->cannot('dcat.admin.article_categories.destroy')); if (Admin::user()->can('dcat.admin.articles.index')) { - $actions->prepend(new ArticleList()); + $actions->prepend(' +  '.__('admin.list'). + ''); + // $actions->prepend(new ArticleList()); } }); diff --git a/app/Admin/Controllers/ProductSpuController.php b/app/Admin/Controllers/ProductSpuController.php index 8ae36e26..55e2181c 100644 --- a/app/Admin/Controllers/ProductSpuController.php +++ b/app/Admin/Controllers/ProductSpuController.php @@ -53,8 +53,11 @@ class ProductSpuController extends AdminController $grid->actions(function (Grid\Displayers\Actions $actions) { $actions->disableEdit(Admin::user()->cannot('dcat.admin.product_spus.edit')); $actions->disableDelete(Admin::user()->cannot('dcat.admin.product_spus.destroy')); - if (Admin::user()->can('dcat.admin.product_spus.list')) { - $actions->prepend(new SkuList()); + if (Admin::user()->can('dcat.admin.product_spus.sku_list')) { + $actions->prepend(' +  '.__('admin.list'). + ''); + // $actions->prepend(new SkuList()); } }); diff --git a/app/Admin/Extensions/Column/Modal.php b/app/Admin/Extensions/Column/Modal.php new file mode 100644 index 00000000..7da3a209 --- /dev/null +++ b/app/Admin/Extensions/Column/Modal.php @@ -0,0 +1,81 @@ +title = $title; + } + + public function xl() + { + $this->xl = true; + } + + public function icon($icon) + { + $this->icon = $icon; + } + + protected function setUpLazyRenderable(LazyRenderable $renderable) + { + return clone $renderable->payload(['key' => $this->getKey()]); + } + + public function display($callback = null) + { + $title = $this->value ?: $this->trans('title'); + if (func_num_args() == 2) { + [$title, $callback] = func_get_args(); + } + + $html = $this->value; + + if ($callback instanceof \Closure) { + $callback = $callback->call($this->row, $this); + + if (! $callback instanceof LazyRenderable) { + $html = Helper::render($callback); + + $callback = null; + } + } + + if ($callback && is_string($callback) && is_subclass_of($callback, LazyRenderable::class)) { + $html = $this->setUpLazyRenderable($callback::make()); + } elseif ($callback && $callback instanceof LazyRenderable) { + $html = $this->setUpLazyRenderable($callback); + } + + $title = $this->title ?: $title; + + return WidgetModal::make() + ->when(true, function ($modal) { + $this->xl ? $modal->xl() : $modal->lg(); + }) + ->title($title) + ->body($html) + ->delay(300) + ->button($this->renderButton()); + } + + protected function renderButton() + { + $icon = $this->icon ? "" : ''; + + return "{$icon} {$this->value}"; + } +} diff --git a/app/Admin/Renderable/CouponRangeTable.php b/app/Admin/Renderable/CouponRangeTable.php index 90dca8fd..4206104d 100644 --- a/app/Admin/Renderable/CouponRangeTable.php +++ b/app/Admin/Renderable/CouponRangeTable.php @@ -27,6 +27,7 @@ class CouponRangeTable extends Grid return $this->type == 1; })->then(function (Column $column) { $column->showTreeInDialog(function (Grid\Displayers\DialogTree $tree) { + $tree->title('商品分类'); $tree->nodes(ProductCategory::get()->toArray()); $tree->setTitleColumn('name'); }); diff --git a/app/Admin/Renderable/ProductSkuTable.php b/app/Admin/Renderable/ProductSkuTable.php index ed6f2dd5..e54208df 100644 --- a/app/Admin/Renderable/ProductSkuTable.php +++ b/app/Admin/Renderable/ProductSkuTable.php @@ -25,6 +25,7 @@ class ProductSkuTable extends Grid $builder = ProductSku::with('category'); $grid = parent::make($builder, function (Grid $grid) { + $grid->disableCreateButton(); $grid->setResource('product-skus'); $grid->showRowSelector(); $grid->batchActions(function ($batch) { diff --git a/app/Admin/bootstrap.php b/app/Admin/bootstrap.php index b788705a..c1956b68 100644 --- a/app/Admin/bootstrap.php +++ b/app/Admin/bootstrap.php @@ -1,11 +1,13 @@ disableRowSelector(); $grid->disableCreateButton();