70 lines
2.8 KiB
PHP
70 lines
2.8 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\MonitorModeService;
|
|
use App\Admin\Components;
|
|
use App\Models\MonitorMode;
|
|
|
|
/**
|
|
* @property MonitorModeService $service
|
|
*/
|
|
class MonitorModeController extends AdminController
|
|
{
|
|
protected string $serviceName = MonitorModeService::class;
|
|
|
|
public function list(): Page
|
|
{
|
|
$crud = $this->baseCRUD()
|
|
->filterTogglable(false)
|
|
->headerToolbar([
|
|
$this->createButton(true, 'lg'),
|
|
...$this->baseHeaderToolBar(),
|
|
])
|
|
->filter($this->baseFilter()->actions([])->body([
|
|
TextControl::make()->name('name')->label('名称')->size('md'),
|
|
amisMake()->SelectControl()->name('type')->label('类型')->options(MonitorMode::typeMap())->size('md'),
|
|
Components::make()->keywordsTagControl('group_tags', '分组', 'device-group')->size('md'),
|
|
amis('button')->label(__('admin.reset'))->actionType('clear-and-submit'),
|
|
amis('submit')->label(__('admin.search'))->level('primary'),
|
|
]))
|
|
->columns([
|
|
TableColumn::make()->name('id')->label('ID')->sortable(true),
|
|
TableColumn::make()->name('name')->label('名称'),
|
|
TableColumn::make()->name('type')->type('mapping')->map(MonitorMode::typeMap())->label('类型'),
|
|
TableColumn::make()->name('created_at')->label(__('admin.created_at'))->type('datetime')->sortable(true),
|
|
amisMake()->Operation()->label(__('admin.actions'))->buttons([
|
|
$this->rowDeleteButton()
|
|
]),
|
|
]);
|
|
|
|
return $this->baseList($crud);
|
|
}
|
|
|
|
public function form(): Form
|
|
{
|
|
return $this->baseForm()->body([
|
|
TextControl::make()->name('name')->label('名称'),
|
|
\amisMake()->RadiosControl()->name('type')->label('类型')->options(MonitorMode::typeMap())->required(true),
|
|
Components::make()->keywordsTagControl('group_tags', '分组', 'device-group'),
|
|
Components::make()->sortControl('sort', __('admin.order')),
|
|
TextControl::make()->name('is_enable')->type('switch')->default(1)->label('显示'),
|
|
TextControl::make()->name('is_recommend')->type('switch')->default(0)->label('推荐'),
|
|
]);
|
|
}
|
|
|
|
public function detail(): Form
|
|
{
|
|
return $this->baseDetail()->body([
|
|
TextControl::make()->static()->name('id')->label('ID'),
|
|
TextControl::make()->static()->name('created_at')->label(__('admin.created_at')),
|
|
TextControl::make()->static()->name('updated_at')->label(__('admin.updated_at'))
|
|
]);
|
|
}
|
|
}
|