90 lines
3.6 KiB
PHP
90 lines
3.6 KiB
PHP
<?php
|
|
|
|
namespace App\Admin\Controllers;
|
|
|
|
use Slowlyo\OwlAdmin\Renderers\Page;
|
|
use Slowlyo\OwlAdmin\Renderers\Form;
|
|
use Slowlyo\OwlAdmin\Renderers\TableColumn;
|
|
use Slowlyo\OwlAdmin\Renderers\TextControl;
|
|
use Slowlyo\OwlAdmin\Renderers\Image;
|
|
use Slowlyo\OwlAdmin\Controllers\AdminController;
|
|
use Slowlyo\OwlAdmin\Renderers\Button;
|
|
use App\Services\Admin\RegionCategoryService;
|
|
use App\Admin\Components;
|
|
use Illuminate\Http\Request;
|
|
|
|
class RegionCategoryController extends AdminController
|
|
{
|
|
protected string $serviceName = RegionCategoryService::class;
|
|
|
|
protected string $pageTitle = '区域分类';
|
|
|
|
public function list(): Page
|
|
{
|
|
// dd(Components::make()->parentControl('region-categories/tree-list'));
|
|
$crud = $this->baseCRUD()
|
|
//关闭查询
|
|
->filterTogglable(false)
|
|
//去掉分页-start
|
|
->loadDataOnce(true)
|
|
->footerToolbar([])
|
|
//去掉分页-end
|
|
->headerToolbar([
|
|
$this->createButton(true),
|
|
...$this->baseHeaderToolBar(),
|
|
])
|
|
->quickSaveItemApi(admin_url('quick-edit/region-categories/$id'))
|
|
->filter(
|
|
$this->baseFilter()->body([
|
|
amisMake()->TextControl()->make('name')->label('分类名称')->name('name')->size('md'),
|
|
Components::make()->parentControl(admin_url('api/region-categories/tree-list'))->size('md'),
|
|
|
|
Button::make()->label(__('admin.reset'))->actionType('clear-and-submit'),
|
|
amis('submit')->label(__('admin.search'))->level('primary'),
|
|
])->actions([])
|
|
)
|
|
->columns([
|
|
TableColumn::make()->name('id')->label('ID')->sortable(true),
|
|
TableColumn::make()->name('name')->label('名称'),
|
|
Image::make()->name('icon')->label(__('region-category.icon'))->width(100),
|
|
// TableColumn::make()->name('parent.name')->label('父级ID'),
|
|
TableColumn::make()->name('sort')->label('排序'),
|
|
TableColumn::make()->name('is_enable')->type('switch')->label('显示')->quickEdit(
|
|
Components::make()->enableControl('is_enable', '', 'inline')->saveImmediately(true)
|
|
),
|
|
TableColumn::make()->name('created_at')->label('创建时间')->type('datetime')->sortable(true),
|
|
$this->rowActions(true),
|
|
]);
|
|
|
|
return $this->baseList($crud);
|
|
}
|
|
|
|
public function form(): Form
|
|
{
|
|
return $this->baseForm()->body([
|
|
amisMake()->TextControl()->name('name')->label('名称')->required(true),
|
|
amisMake()->ImageControl()->name('icon')->label('封面图')->autoUpload(true),
|
|
amisMake()->TextControl()->name('description')->label('描述'),
|
|
Components::make()->parentControl(admin_url('api/region-categories/tree-list')),
|
|
Components::make()->sortControl(),
|
|
Components::make()->enableControl()->value(1),
|
|
]);
|
|
}
|
|
|
|
public function detail(): Form
|
|
{
|
|
return $this->baseDetail()->body([
|
|
TextControl::make()->static(true)->name('id')->label('ID'),
|
|
TextControl::make()->static(true)->name('name')->label('名称'),
|
|
TextControl::make()->name('icon')->label(__('region-category.icon'))->static(true)->staticSchema(Image::make()),
|
|
TextControl::make()->static(true)->name('description')->label('描述'),
|
|
TextControl::make()->static(true)->name('created_at')->label('创建时间'),
|
|
TextControl::make()->static(true)->name('updated_at')->label('更新时间')
|
|
]);
|
|
}
|
|
|
|
public function getTreeList(Request $request){
|
|
return $this->service->getTree();
|
|
}
|
|
}
|