添加预警消息点位显示
parent
8840e75eb2
commit
da6634fd4e
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
namespace App\Admin\Controllers;
|
||||
|
||||
use App\Models\MonitorMode;
|
||||
use Slowlyo\OwlAdmin\Controllers\AdminController;
|
||||
use Slowlyo\OwlAdmin\Renderers\Form;
|
||||
use Slowlyo\OwlAdmin\Renderers\Page;
|
||||
|
|
@ -13,7 +14,7 @@ class WarningNoticeController extends AdminController
|
|||
{
|
||||
protected string $serviceName = WarningNoticeService::class;
|
||||
|
||||
protected string $pageTitle = '报警记录';//待完善-todo
|
||||
protected string $pageTitle = '报警记录';
|
||||
|
||||
public function list(): Page
|
||||
{
|
||||
|
|
@ -24,6 +25,10 @@ class WarningNoticeController extends AdminController
|
|||
])
|
||||
->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>",
|
||||
])->valueField('id')->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('报警内容'),
|
||||
|
|
|
|||
|
|
@ -55,6 +55,10 @@ class Device extends Model
|
|||
];
|
||||
}
|
||||
|
||||
public function modes(){
|
||||
return $this->belongsToMany(MonitorMode::class, MonitorDevice::class, 'device_id', 'monitor_id')->withPivot('fields');
|
||||
}
|
||||
|
||||
public function logs(): HasMany
|
||||
{
|
||||
return $this->hasMany(DeviceLog::class);
|
||||
|
|
|
|||
|
|
@ -12,5 +12,5 @@ class WarningNoticeService extends BaseService
|
|||
{
|
||||
protected string $modelName = WarningNotice::class;
|
||||
|
||||
protected array $withRelationships = ['device'];
|
||||
protected array $withRelationships = ['device.modes'];
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue