改变预警设置表单
parent
1a251a3625
commit
7853032f81
|
|
@ -2,6 +2,9 @@
|
|||
|
||||
namespace App\Admin\Controllers;
|
||||
|
||||
use App\Models\Device;
|
||||
use App\Models\MonitorMode;
|
||||
use App\Models\WarningNotice;
|
||||
use Illuminate\Http\Request;
|
||||
use Slowlyo\OwlAdmin\Controllers\AdminController;
|
||||
|
||||
|
|
@ -22,29 +25,42 @@ class WarningSettingController extends AdminController
|
|||
[
|
||||
'title' => '气象预警',
|
||||
'value' => 'meteorological',
|
||||
'tab'=>$this->meteorologicalForm(),
|
||||
'unmountOnExit' => true//每次切换tab都要销毁
|
||||
],
|
||||
[
|
||||
'title' => '水质预警',
|
||||
'value' => 'detail',
|
||||
'tab'=>'',
|
||||
'tab'=>$this->modeForm(MonitorMode::TYPE_METEOROLOGICAL),
|
||||
'unmountOnExit' => true//每次切换tab都要销毁
|
||||
],
|
||||
// [
|
||||
// 'title' => '水质预警',
|
||||
// 'value' => 'detail',
|
||||
// 'tab'=>'',
|
||||
// 'unmountOnExit' => true//每次切换tab都要销毁
|
||||
// ],
|
||||
[
|
||||
'title' => '土壤预警',
|
||||
'value' => 'detail',
|
||||
'tab'=>'',
|
||||
'tab'=>$this->modeForm(MonitorMode::TYPE_SOIL),
|
||||
'unmountOnExit' => true//每次切换tab都要销毁
|
||||
],
|
||||
]);
|
||||
}
|
||||
|
||||
public function meteorologicalForm(){
|
||||
return \amisMake()->Form()->title('')->body([
|
||||
\amisMake()->TextControl()->label('设备名称'),
|
||||
\amisMake()->DateRangeControl()->label('时间范围'),
|
||||
amis('submit')->label(__('admin.save'))->level('primary'),
|
||||
]);
|
||||
public function modeForm($type)
|
||||
{
|
||||
$formBody = $fields = [];
|
||||
foreach(MonitorMode::fieldMap($type) as $field => $fieldName){
|
||||
$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')
|
||||
])
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
@ -14,6 +14,15 @@ class WarningNotice extends Model
|
|||
'reported_at',
|
||||
];
|
||||
|
||||
public static function lvMap(){
|
||||
return [
|
||||
'1' => 'Ⅰ级预警',
|
||||
'2' => 'Ⅱ级预警',
|
||||
'3' => 'Ⅲ级预警',
|
||||
'4' => 'Ⅳ级预警',
|
||||
];
|
||||
}
|
||||
|
||||
public function device(){
|
||||
return $this->belongsTo(Device::class, 'device_id');
|
||||
}
|
||||
|
|
|
|||
|
|
@ -137,8 +137,8 @@ class DeviceService extends BaseService
|
|||
|
||||
//特殊字段,特殊统计图;
|
||||
switch($field){
|
||||
//点状图;
|
||||
//柱状图
|
||||
//点状图;-todo
|
||||
//柱状图;-todo
|
||||
default://折线图
|
||||
$_chartCard = amisMake()->Card()->body(
|
||||
amisMake()->Chart()->config(
|
||||
|
|
|
|||
Loading…
Reference in New Issue