调整部分内容
parent
9b44ab18aa
commit
65bbf49cdc
|
|
@ -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()]));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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('<a href="'.admin_route('articles.index', ['category' =>$actions->row]).'">
|
||||
<i class="feather icon-list grid-action-icon"></i> '.__('admin.list').
|
||||
'</a>');
|
||||
// $actions->prepend(new ArticleList());
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -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('<a href="'.admin_route('product_spus.sku_list', ['spu' =>$actions->row]).'">
|
||||
<i class="feather icon-list grid-action-icon"></i> '.__('admin.list').
|
||||
'</a>');
|
||||
// $actions->prepend(new SkuList());
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,81 @@
|
|||
<?php
|
||||
|
||||
namespace App\Admin\Extensions\Column;
|
||||
|
||||
use Dcat\Admin\Contracts\LazyRenderable;
|
||||
use Dcat\Admin\Grid\Displayers\AbstractDisplayer;
|
||||
use Dcat\Admin\Support\Helper;
|
||||
use Dcat\Admin\Widgets\Modal as WidgetModal;
|
||||
|
||||
class Modal extends AbstractDisplayer
|
||||
{
|
||||
protected $title;
|
||||
|
||||
protected $xl = false;
|
||||
|
||||
protected $icon = 'fa-clone';
|
||||
|
||||
public function title(string $title)
|
||||
{
|
||||
$this->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 ? "<i class='fa {$this->icon}'></i>" : '';
|
||||
|
||||
return "<a href='javascript:void(0)'>{$icon} {$this->value}</a>";
|
||||
}
|
||||
}
|
||||
|
|
@ -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');
|
||||
});
|
||||
|
|
|
|||
|
|
@ -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) {
|
||||
|
|
|
|||
|
|
@ -1,11 +1,13 @@
|
|||
<?php
|
||||
|
||||
use App\Admin\Extensions\Column\Modal;
|
||||
use App\Admin\Extensions\Form\Product\SelectAttr;
|
||||
use App\Admin\Extensions\Form\Product\SelectSpec;
|
||||
use Dcat\Admin\Admin;
|
||||
use Dcat\Admin\Form;
|
||||
use Dcat\Admin\Form\Field\Editor;
|
||||
use Dcat\Admin\Grid;
|
||||
use Dcat\Admin\Grid\Column;
|
||||
|
||||
/**
|
||||
* Dcat-admin - admin builder based on Laravel.
|
||||
|
|
@ -28,6 +30,8 @@ use Dcat\Admin\Grid;
|
|||
|
||||
Admin::css('/dist/admin/css/app.css');
|
||||
|
||||
Column::extend('modal', Modal::class);
|
||||
|
||||
Grid::resolving(function (Grid $grid) {
|
||||
$grid->disableRowSelector();
|
||||
$grid->disableCreateButton();
|
||||
|
|
|
|||
Loading…
Reference in New Issue