调整部分内容
parent
9b44ab18aa
commit
65bbf49cdc
|
|
@ -45,6 +45,6 @@ class SkuList extends RowAction
|
||||||
|
|
||||||
return $this->response()
|
return $this->response()
|
||||||
// ->success('Processed successfully: '.$this->getKey())
|
// ->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) {
|
$grid->actions(function (Grid\Displayers\Actions $actions) {
|
||||||
$actions->disableDelete(Admin::user()->cannot('dcat.admin.article_categories.destroy'));
|
$actions->disableDelete(Admin::user()->cannot('dcat.admin.article_categories.destroy'));
|
||||||
if (Admin::user()->can('dcat.admin.articles.index')) {
|
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) {
|
$grid->actions(function (Grid\Displayers\Actions $actions) {
|
||||||
$actions->disableEdit(Admin::user()->cannot('dcat.admin.product_spus.edit'));
|
$actions->disableEdit(Admin::user()->cannot('dcat.admin.product_spus.edit'));
|
||||||
$actions->disableDelete(Admin::user()->cannot('dcat.admin.product_spus.destroy'));
|
$actions->disableDelete(Admin::user()->cannot('dcat.admin.product_spus.destroy'));
|
||||||
if (Admin::user()->can('dcat.admin.product_spus.list')) {
|
if (Admin::user()->can('dcat.admin.product_spus.sku_list')) {
|
||||||
$actions->prepend(new SkuList());
|
$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;
|
return $this->type == 1;
|
||||||
})->then(function (Column $column) {
|
})->then(function (Column $column) {
|
||||||
$column->showTreeInDialog(function (Grid\Displayers\DialogTree $tree) {
|
$column->showTreeInDialog(function (Grid\Displayers\DialogTree $tree) {
|
||||||
|
$tree->title('商品分类');
|
||||||
$tree->nodes(ProductCategory::get()->toArray());
|
$tree->nodes(ProductCategory::get()->toArray());
|
||||||
$tree->setTitleColumn('name');
|
$tree->setTitleColumn('name');
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -25,6 +25,7 @@ class ProductSkuTable extends Grid
|
||||||
$builder = ProductSku::with('category');
|
$builder = ProductSku::with('category');
|
||||||
|
|
||||||
$grid = parent::make($builder, function (Grid $grid) {
|
$grid = parent::make($builder, function (Grid $grid) {
|
||||||
|
$grid->disableCreateButton();
|
||||||
$grid->setResource('product-skus');
|
$grid->setResource('product-skus');
|
||||||
$grid->showRowSelector();
|
$grid->showRowSelector();
|
||||||
$grid->batchActions(function ($batch) {
|
$grid->batchActions(function ($batch) {
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,13 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use App\Admin\Extensions\Column\Modal;
|
||||||
use App\Admin\Extensions\Form\Product\SelectAttr;
|
use App\Admin\Extensions\Form\Product\SelectAttr;
|
||||||
use App\Admin\Extensions\Form\Product\SelectSpec;
|
use App\Admin\Extensions\Form\Product\SelectSpec;
|
||||||
use Dcat\Admin\Admin;
|
use Dcat\Admin\Admin;
|
||||||
use Dcat\Admin\Form;
|
use Dcat\Admin\Form;
|
||||||
use Dcat\Admin\Form\Field\Editor;
|
use Dcat\Admin\Form\Field\Editor;
|
||||||
use Dcat\Admin\Grid;
|
use Dcat\Admin\Grid;
|
||||||
|
use Dcat\Admin\Grid\Column;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Dcat-admin - admin builder based on Laravel.
|
* Dcat-admin - admin builder based on Laravel.
|
||||||
|
|
@ -28,6 +30,8 @@ use Dcat\Admin\Grid;
|
||||||
|
|
||||||
Admin::css('/dist/admin/css/app.css');
|
Admin::css('/dist/admin/css/app.css');
|
||||||
|
|
||||||
|
Column::extend('modal', Modal::class);
|
||||||
|
|
||||||
Grid::resolving(function (Grid $grid) {
|
Grid::resolving(function (Grid $grid) {
|
||||||
$grid->disableRowSelector();
|
$grid->disableRowSelector();
|
||||||
$grid->disableCreateButton();
|
$grid->disableCreateButton();
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue