76 lines
2.5 KiB
PHP
76 lines
2.5 KiB
PHP
<?php
|
|
|
|
namespace App\Admin\Controllers;
|
|
|
|
use App\Models\MonitorMode;
|
|
use Slowlyo\OwlAdmin\Controllers\AdminController;
|
|
use Slowlyo\OwlAdmin\Renderers\Form;
|
|
use Slowlyo\OwlAdmin\Renderers\Page;
|
|
use Slowlyo\OwlAdmin\Renderers\TableColumn;
|
|
use App\Services\Admin\WarningNoticeService;
|
|
use App\Models\WarningNotice;
|
|
|
|
class WarningNoticeController extends AdminController
|
|
{
|
|
protected string $serviceName = WarningNoticeService::class;
|
|
|
|
protected string $pageTitle = '报警记录';
|
|
|
|
public function list(): Page
|
|
{
|
|
$crud = $this->baseCRUD()
|
|
->filterTogglable(false)
|
|
->headerToolbar([
|
|
...$this->baseHeaderToolBar(),
|
|
])
|
|
->columns([
|
|
TableColumn::make()->name('id')->label('ID')->sortable(true),
|
|
TableColumn::make()->name('device.modes')->type('each')->items([
|
|
'type' => 'tpl',
|
|
'tpl' => "<span class='label label-info m-l-sm'><%= data.name %></span>",
|
|
])->label('监测点位'),
|
|
TableColumn::make()->name('device.name')->label('设备名称'),
|
|
TableColumn::make()->name('lv')->type('mapping')->map(WarningNotice::lvMap())->label('报警等级')->className('text-primary'),
|
|
TableColumn::make()->name('content')->label('报警内容'),
|
|
|
|
TableColumn::make()->name('status')->label('状态')->type('mapping')->map(WarningNotice::stateMapLabel())->className('text-primary'),
|
|
TableColumn::make()->name('created_at')->label('报警时间')->type('datetime')->sortable(true),
|
|
amisMake()->Operation()->label(__('admin.actions'))->buttons([
|
|
$this->updateState()->visibleOn('${status == 0}'),
|
|
]),
|
|
]);
|
|
|
|
return $this->baseList($crud);
|
|
}
|
|
|
|
public function form(): Form
|
|
{
|
|
return $this->baseForm()->body([
|
|
]);
|
|
}
|
|
|
|
public function detail(): Form
|
|
{
|
|
return $this->baseDetail()->body([
|
|
|
|
]);
|
|
}
|
|
|
|
private function updateState(){
|
|
return amisMake()->AjaxAction()
|
|
->label('标记处理')
|
|
->level('link')
|
|
->confirmText('是否确认标记处理')
|
|
->api('put:'.admin_url('warning-notice-mark').'/${id}');
|
|
}
|
|
|
|
//标记已处理警报内容;
|
|
public function updateNotice($id)
|
|
{
|
|
$rows = WarningNotice::where('id', $id)->update([
|
|
'status'=> 1
|
|
]);
|
|
|
|
return $this->autoResponse($rows, '保存成功');
|
|
}
|
|
} |