From da6634fd4ef5bcf64225451a553e0e05835d0872 Mon Sep 17 00:00:00 2001 From: vine_liutk <961510893@qq.com> Date: Fri, 26 May 2023 19:15:10 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E9=A2=84=E8=AD=A6=E6=B6=88?= =?UTF-8?q?=E6=81=AF=E7=82=B9=E4=BD=8D=E6=98=BE=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Admin/Controllers/WarningNoticeController.php | 7 ++++++- app/Models/Device.php | 4 ++++ app/Services/Admin/WarningNoticeService.php | 2 +- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/app/Admin/Controllers/WarningNoticeController.php b/app/Admin/Controllers/WarningNoticeController.php index a95dc29..2419c9d 100644 --- a/app/Admin/Controllers/WarningNoticeController.php +++ b/app/Admin/Controllers/WarningNoticeController.php @@ -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' => "<%= data.name %>", + ])->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('报警内容'), diff --git a/app/Models/Device.php b/app/Models/Device.php index 174e3a4..c9acc7d 100644 --- a/app/Models/Device.php +++ b/app/Models/Device.php @@ -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); diff --git a/app/Services/Admin/WarningNoticeService.php b/app/Services/Admin/WarningNoticeService.php index 47466fd..15b1e1e 100644 --- a/app/Services/Admin/WarningNoticeService.php +++ b/app/Services/Admin/WarningNoticeService.php @@ -12,5 +12,5 @@ class WarningNoticeService extends BaseService { protected string $modelName = WarningNotice::class; - protected array $withRelationships = ['device']; + protected array $withRelationships = ['device.modes']; }