1
0
Fork 0

改变预警设置表单

develop
vine_liutk 2023-05-18 19:14:22 +08:00
parent 1a251a3625
commit 7853032f81
3 changed files with 41 additions and 16 deletions

View File

@ -2,6 +2,9 @@
namespace App\Admin\Controllers; namespace App\Admin\Controllers;
use App\Models\Device;
use App\Models\MonitorMode;
use App\Models\WarningNotice;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use Slowlyo\OwlAdmin\Controllers\AdminController; use Slowlyo\OwlAdmin\Controllers\AdminController;
@ -22,29 +25,42 @@ class WarningSettingController extends AdminController
[ [
'title' => '气象预警', 'title' => '气象预警',
'value' => 'meteorological', 'value' => 'meteorological',
'tab'=>$this->meteorologicalForm(), 'tab'=>$this->modeForm(MonitorMode::TYPE_METEOROLOGICAL),
'unmountOnExit' => true//每次切换tab都要销毁
],
[
'title' => '水质预警',
'value' => 'detail',
'tab'=>'',
'unmountOnExit' => true//每次切换tab都要销毁 'unmountOnExit' => true//每次切换tab都要销毁
], ],
// [
// 'title' => '水质预警',
// 'value' => 'detail',
// 'tab'=>'',
// 'unmountOnExit' => true//每次切换tab都要销毁
// ],
[ [
'title' => '土壤预警', 'title' => '土壤预警',
'value' => 'detail', 'value' => 'detail',
'tab'=>'', 'tab'=>$this->modeForm(MonitorMode::TYPE_SOIL),
'unmountOnExit' => true//每次切换tab都要销毁 'unmountOnExit' => true//每次切换tab都要销毁
], ],
]); ]);
} }
public function meteorologicalForm(){ public function modeForm($type)
return \amisMake()->Form()->title('')->body([ {
\amisMake()->TextControl()->label('设备名称'), $formBody = $fields = [];
\amisMake()->DateRangeControl()->label('时间范围'), foreach(MonitorMode::fieldMap($type) as $field => $fieldName){
amis('submit')->label(__('admin.save'))->level('primary'), $fields[] = [
]); 'label' => $fieldName, 'type'=>'number','step'=>'0.01','name'=>$field,
'operators'=> ['between']
];
}
foreach(WarningNotice::lvMap() as $lv => $lvName){
$formBody[] = amisMake()->ConditionBuilderControl(str($lv), $lvName)->fields( $fields);
}
return \amisMake()->Form()->title('')->body(array_merge($formBody, [
amisMake()->TextControl('type', '类别')->value($type)->hidden(true),
amis('submit')->label(__('admin.save'))->level('primary')
])
);
} }
} }

View File

@ -14,6 +14,15 @@ class WarningNotice extends Model
'reported_at', 'reported_at',
]; ];
public static function lvMap(){
return [
'1' => 'Ⅰ级预警',
'2' => 'Ⅱ级预警',
'3' => 'Ⅲ级预警',
'4' => 'Ⅳ级预警',
];
}
public function device(){ public function device(){
return $this->belongsTo(Device::class, 'device_id'); return $this->belongsTo(Device::class, 'device_id');
} }

View File

@ -137,8 +137,8 @@ class DeviceService extends BaseService
//特殊字段,特殊统计图; //特殊字段,特殊统计图;
switch($field){ switch($field){
//点状图; //点状图;-todo
//柱状图 //柱状图;-todo
default://折线图 default://折线图
$_chartCard = amisMake()->Card()->body( $_chartCard = amisMake()->Card()->body(
amisMake()->Chart()->config( amisMake()->Chart()->config(