77 lines
3.1 KiB
PHP
77 lines
3.1 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\Controllers\AdminController;
|
|
use App\Services\Admin\RegionService;
|
|
use Slowlyo\OwlAdmin\Renderers\Button;
|
|
use App\Admin\Components;
|
|
|
|
class RegionController extends AdminController
|
|
{
|
|
protected string $serviceName = RegionService::class;
|
|
|
|
protected string $pageTitle = '实验田';
|
|
|
|
public function list(): Page
|
|
{
|
|
$crud = $this->baseCRUD()
|
|
->filterTogglable(false)
|
|
->headerToolbar([
|
|
$this->createButton(true, 'lg'),
|
|
...$this->baseHeaderToolBar(),
|
|
])
|
|
->filter(
|
|
$this->baseFilter()->body([
|
|
amisMake()->TextControl()->make('name')->label('名称')->name('name'),
|
|
Components::make()->parentControl(admin_url('api/region-categories/tree-list'), 'category_id', '分类')->size('sm'),
|
|
|
|
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('名称'),
|
|
TableColumn::make()->name('category.name')->label('分类')->className('text-primary'),
|
|
TableColumn::make()->name('area')->label('面积'),
|
|
TableColumn::make()->name('device_count')->label('设备数量'),
|
|
TableColumn::make()->name('is_enable')->type('switch')->label('显示'),
|
|
TableColumn::make()->name('created_at')->label('创建时间')->type('datetime')->sortable(true),
|
|
// TableColumn::make()->name('updated_at')->label('更新时间')->type('datetime')->sortable(true),
|
|
$this->rowActions(true, 'lg'),
|
|
]);
|
|
|
|
return $this->baseList($crud);
|
|
}
|
|
|
|
public function form(): Form
|
|
{
|
|
return $this->baseForm()->body([
|
|
\amisMake()->TextControl()->name('name')->label('名称')->required(true),
|
|
Components::make()->parentControl(admin_url('api/region-categories/tree-list'), 'category_id', '分类'),
|
|
Components::make()->fuEditorControl('description', '介绍'),
|
|
Components::make()->decimalControl('area', '面积m²'),
|
|
Components::make()->sortControl(),
|
|
\amisMake()->SwitchControl()->name('is_enable')->label('显示'),
|
|
\amisMake()->TransferControl()->name('devices')->label('关联设备')
|
|
->selectMode('chained')->searchable(true)->options(),
|
|
|
|
]);
|
|
}
|
|
|
|
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()->static(true)->name('created_at')->label('创建时间'),
|
|
TextControl::make()->static(true)->name('updated_at')->label('更新时间')
|
|
]);
|
|
}
|
|
}
|