baseCRUD() ->filterTogglable(false) ->headerToolbar([ $this->createButton(true, 'lg'), ...$this->baseHeaderToolBar(), ]) ->columns([ TableColumn::make()->name('id')->label('ID')->sortable(true), TableColumn::make()->name('name')->label('名称'), TableColumn::make()->name('sn')->label('编号'), TableColumn::make()->name('created_at')->label('创建时间')->type('datetime')->sortable(true), TableColumn::make()->name('updated_at')->label('更新时间')->type('datetime')->sortable(true), $this->rowActions(true), ]); return $this->baseList($crud); } public function form(): Form { return $this->baseForm()->body([ TextControl::make()->name('name')->label('名称')->required(true), TextControl::make()->name('sn')->label('编号'), \amisMake()->SelectControl()->name('powered_by')->label('厂家')->options(), TextControl::make()->name('model_sn')->label('型号'), \amisMake()->RadiosControl()->name('type')->label('类型')->options(Device::typeMap())->required(true), //监控设备-额外参数 \amisMake()->TextControl()->name('extends.ip')->hiddenOn('data.type != '.Device::TYPE_MONITOR)->label('设备IP'), \amisMake()->TextControl()->name('extends.username')->hiddenOn('data.type != '.Device::TYPE_MONITOR)->label('设备用户名'), \amisMake()->TextControl()->name('extends.password')->hiddenOn('data.type != '.Device::TYPE_MONITOR)->label('设备密码'), \amisMake()->GroupControl()->body([ \amisMake()->TextControl()->name('extends.live_port')->hiddenOn('data.type != '.Device::TYPE_MONITOR)->label('实时端口'), \amisMake()->TextControl()->name('extends.live_channel')->hiddenOn('data.type != '.Device::TYPE_MONITOR)->label('实时通道'), ]), \amisMake()->GroupControl()->body([ \amisMake()->TextControl()->name('extends.back_port')->hiddenOn('data.type != '.Device::TYPE_MONITOR)->label('回放端口'), \amisMake()->TextControl()->name('extends.back_channel')->hiddenOn('data.type != '.Device::TYPE_MONITOR)->label('回放通道'), ]), ]); } public function detail(): Form { return $this->baseDetail()->body([ TextControl::make()->static(true)->name('id')->label('ID'), TextControl::make()->static(true)->name('name')->label('名称'), TextControl::make()->static(true)->name('sn')->label('编号'), TextControl::make()->static(true)->name('created_at')->label('创建时间'), TextControl::make()->static(true)->name('updated_at')->label('更新时间') ]); } /** * 监控设备列表 */ public function monitorList(){ return CRUDTable::make()->mode('cards')->columnsCount(3) ->data([ 'items' => [ [ 'id'=>1, 'src'=>'' // ws://183.221.204.29:8100/rtsp?url=cnRzcDovL2FkbWluOjEyMzQ1Njc4OXhAMTE3LjE3NC4xODQuMTE4OjkwMDkvY2FtL3JlYWxtb25pdG9yP2NoYW5uZWw9MSZzdWJ0eXBlPTA= ], ] ]) ->filter([ 'title' => '搜索条件', 'body' => [ \amisMake()->TextControl()->name('name')->label('点位名称')->size('sm'), amis('submit')->label(__('admin.search'))->level('primary'), ] ]) ->actions([]) ->itemClassName('col-sm-4') ->card([ 'header' => [], 'body' => amisMake()->Video() // ->isLive(true)->videoType('video/x-flv')->muted(true)->autoPlay(true) ->src('${src}') ]); } /** * 监控历史视频 */ public function monitorVideoList(){ return CRUDTable::make()->mode('cards')->columnsCount(3) ->data([ 'items' => [ [ 'id'=>1, 'src'=>'' // ws://183.221.204.29:8100/rtsp?url=cnRzcDovL2FkbWluOjEyMzQ1Njc4OXhAMTE3LjE3NC4xODQuMTE4OjkwMDkvY2FtL3JlYWxtb25pdG9yP2NoYW5uZWw9MSZzdWJ0eXBlPTA= ], ] ]) ->filter([ 'title' => '搜索条件', 'body' => [ \amisMake()->TextControl()->name('name')->label('点位名称')->size('sm'), \amisMake()->DateRangeControl()->label('时间范围'), amis('submit')->label(__('admin.search'))->level('primary'), ] ]) ->actions([]) ->itemClassName('col-sm-4') ->card([ 'header' => [], 'body' => amisMake()->Video() // ->isLive(true)->videoType('video/x-flv')->muted(true)->autoPlay(true) ->src('${src}') ]); } /** * 气象图表 */ public function meteorologicalChart(){ $randArr = function () { $_arr = []; for ($i = 0; $i < 7; $i++) { $_arr[] = random_int(10, 200); } return '[' . implode(',', $_arr) . ']'; }; $random1 = $randArr(); $random2 = $randArr(); return $this->basePage()->title('')->body([ \amisMake()->grid()->columns([ \amisMake()->Form()->title('搜索条件')->mode('inline')->body([ \amisMake()->TextControl()->label('设备名称'), \amisMake()->DateRangeControl()->label('时间范围'), amis('submit')->label(__('admin.search'))->level('primary'), ]), ]), \amisMake()->grid()->columns([ amisMake()->Flex()->items([ amisMake()->Card()->className('m-r')->body( amisMake()->Chart()->config("{ title:{ text: '空气温度', subtext: '℃'}, tooltip: { trigger: 'axis' }, xAxis: { type: 'category', boundaryGap: false, data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'] }, yAxis: { type: 'value' }, grid:{ left: '7%', right:'3%', top: 60, bottom: 30, }, series: [ { name:'空气温度', data: {$random2}, type: 'line', areaStyle: {}, smooth: true, symbol: 'none', }, ]}") ), amisMake()->Card()->className('m-r')->body( amisMake()->Chart()->config("{ title:{ text: '空气湿度', subtext: '%RH'}, tooltip: { trigger: 'axis' }, xAxis: { type: 'category', boundaryGap: false, data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'] }, yAxis: { type: 'value' }, grid:{ left: '7%', right:'3%', top: 60, bottom: 30, }, series: [ { name: '空气湿度', data: {$random1}, type: 'line', areaStyle: {}, smooth: true, symbol: 'none', }, ]}") ), amisMake()->Card()->className('m-r')->body( amisMake()->Chart()->config("{ title:{ text: '光照强度LUX', }, tooltip: { trigger: 'axis' }, xAxis: { type: 'category', boundaryGap: false, data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'] }, yAxis: { type: 'value' }, grid:{ left: '7%', right:'3%', top: 60, bottom: 30, }, series: [ { name: '光照强度LUX', data: {$random1}, type: 'line', areaStyle: {}, smooth: true, symbol: 'none', }, ]}") ), amisMake()->Card()->body( amisMake()->Chart()->config("{ title:{ text: '光照强度LUX', }, tooltip: { trigger: 'axis' }, xAxis: { type: 'category', boundaryGap: false, data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'] }, yAxis: { type: 'value' }, grid:{ left: '7%', right:'3%', top: 60, bottom: 30, }, series: [ { name: '光照强度LUX', data: {$random1}, type: 'line', areaStyle: {}, smooth: true, symbol: 'none', }, ]}") ), ]), ]), \amisMake()->grid()->columns([ amisMake()->Flex()->items([ amisMake()->Card()->className('m-r')->body( amisMake()->Chart()->config("{ title:{ text: '空气温度', subtext: '℃'}, tooltip: { trigger: 'axis' }, xAxis: { type: 'category', boundaryGap: false, data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'] }, yAxis: { type: 'value' }, grid:{ left: '7%', right:'3%', top: 60, bottom: 30, }, series: [ { name:'空气温度', data: {$random2}, type: 'line', areaStyle: {}, smooth: true, symbol: 'none', }, ]}") ), amisMake()->Card()->className('m-r')->body( amisMake()->Chart()->config("{ title:{ text: '空气湿度', subtext: '%RH'}, tooltip: { trigger: 'axis' }, xAxis: { type: 'category', boundaryGap: false, data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'] }, yAxis: { type: 'value' }, grid:{ left: '7%', right:'3%', top: 60, bottom: 30, }, series: [ { name: '空气湿度', data: {$random1}, type: 'line', areaStyle: {}, smooth: true, symbol: 'none', }, ]}") ), amisMake()->Card()->className('m-r')->body( amisMake()->Chart()->config("{ title:{ text: '光照强度LUX', }, tooltip: { trigger: 'axis' }, xAxis: { type: 'category', boundaryGap: false, data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'] }, yAxis: { type: 'value' }, grid:{ left: '7%', right:'3%', top: 60, bottom: 30, }, series: [ { name: '光照强度LUX', data: {$random1}, type: 'line', areaStyle: {}, smooth: true, symbol: 'none', }, ]}") ), amisMake()->Card()->body( amisMake()->Chart()->config("{ title:{ text: '光照强度LUX', }, tooltip: { trigger: 'axis' }, xAxis: { type: 'category', boundaryGap: false, data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'] }, yAxis: { type: 'value' }, grid:{ left: '7%', right:'3%', top: 60, bottom: 30, }, series: [ { name: '光照强度LUX', data: {$random1}, type: 'line', areaStyle: {}, smooth: true, symbol: 'none', }, ]}") ), ]), ]), ]); } /** * 水质图表 */ public function waterChart(){ $randArr = function () { $_arr = []; for ($i = 0; $i < 7; $i++) { $_arr[] = random_int(10, 200); } return '[' . implode(',', $_arr) . ']'; }; $random1 = $randArr(); $random2 = $randArr(); return $this->basePage()->title('')->body([ \amisMake()->grid()->columns([ \amisMake()->Form()->title('搜索条件')->mode('inline')->body([ \amisMake()->TextControl()->label('设备名称'), \amisMake()->DateRangeControl()->label('时间范围'), amis('submit')->label(__('admin.search'))->level('primary'), ]), ]), \amisMake()->grid()->columns([ amisMake()->Flex()->items([ amisMake()->Card()->className('m-r')->body( amisMake()->Chart()->config("{ title:{ text: '氯', subtext: 'mg/L'}, tooltip: { trigger: 'axis' }, xAxis: { type: 'category', boundaryGap: false, data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'] }, yAxis: { type: 'value' }, grid:{ left: '7%', right:'3%', top: 60, bottom: 30, }, series: [ { name:'氯', data: {$random2}, type: 'line', areaStyle: {}, smooth: true, symbol: 'none', }, ]}") ), amisMake()->Card()->className('m-r')->body( amisMake()->Chart()->config("{ title:{ text: '电导率', subtext: 'us/cm'}, tooltip: { trigger: 'axis' }, xAxis: { type: 'category', boundaryGap: false, data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'] }, yAxis: { type: 'value' }, grid:{ left: '7%', right:'3%', top: 60, bottom: 30, }, series: [ { name: '电导率', data: {$random1}, type: 'line', areaStyle: {}, smooth: true, symbol: 'none', }, ]}") ), amisMake()->Card()->className('m-r')->body( amisMake()->Chart()->config("{ title:{ text: '氧气', subtext: 'mg/L'}, tooltip: { trigger: 'axis' }, xAxis: { type: 'category', boundaryGap: false, data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'] }, yAxis: { type: 'value' }, grid:{ left: '7%', right:'3%', top: 60, bottom: 30, }, series: [ { name: '光照强度LUX', data: {$random1}, type: 'line', areaStyle: {}, smooth: true, symbol: 'none', }, ]}") ), amisMake()->Card()->body( amisMake()->Chart()->config("{ title:{ text: 'PH'}, tooltip: { trigger: 'axis' }, xAxis: { type: 'category', boundaryGap: false, data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'] }, yAxis: { type: 'value' }, grid:{ left: '7%', right:'3%', top: 60, bottom: 30, }, series: [ { name: '光照强度LUX', data: {$random1}, type: 'line', areaStyle: {}, smooth: true, symbol: 'none', }, ]}") ), ]), ]), \amisMake()->grid()->columns([ amisMake()->Flex()->items([ amisMake()->Card()->className('m-r')->body( amisMake()->Chart()->config("{ title:{ text: '温度', subtext: '℃'}, tooltip: { trigger: 'axis' }, xAxis: { type: 'category', boundaryGap: false, data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'] }, yAxis: { type: 'value' }, grid:{ left: '7%', right:'3%', top: 60, bottom: 30, }, series: [ { name:'温度', data: {$random2}, type: 'line', areaStyle: {}, smooth: true, symbol: 'none', }, ]}") ), amisMake()->Card()->body( amisMake()->Chart()->config("{ title:{ text: '浊度', subtext: 'NTU'}, tooltip: { trigger: 'axis' }, xAxis: { type: 'category', boundaryGap: false, data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'] }, yAxis: { type: 'value' }, grid:{ left: '7%', right:'3%', top: 60, bottom: 30, }, series: [ { name: '空气湿度', data: {$random1}, type: 'line', areaStyle: {}, smooth: true, symbol: 'none', }, ]}") ) ]), ]), ]); } /** * 土壤图表 */ public function soilChart(){ $randArr = function () { $_arr = []; for ($i = 0; $i < 7; $i++) { $_arr[] = random_int(10, 200); } return '[' . implode(',', $_arr) . ']'; }; $random1 = $randArr(); $random2 = $randArr(); return $this->basePage()->title('')->body([ \amisMake()->grid()->columns([ \amisMake()->Form()->title('搜索条件')->mode('inline')->body([ \amisMake()->TextControl()->label('设备名称'), \amisMake()->DateRangeControl()->label('时间范围'), amis('submit')->label(__('admin.search'))->level('primary'), ]), ]), \amisMake()->grid()->columns([ amisMake()->Flex()->items([ amisMake()->Card()->className('m-r')->body( amisMake()->Chart()->config("{ title:{ text: '氯', subtext: 'mg/L'}, tooltip: { trigger: 'axis' }, xAxis: { type: 'category', boundaryGap: false, data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'] }, yAxis: { type: 'value' }, grid:{ left: '7%', right:'3%', top: 60, bottom: 30, }, series: [ { name:'氯', data: {$random2}, type: 'line', areaStyle: {}, smooth: true, symbol: 'none', }, ]}") ), amisMake()->Card()->className('m-r')->body( amisMake()->Chart()->config("{ title:{ text: '电导率', subtext: 'us/cm'}, tooltip: { trigger: 'axis' }, xAxis: { type: 'category', boundaryGap: false, data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'] }, yAxis: { type: 'value' }, grid:{ left: '7%', right:'3%', top: 60, bottom: 30, }, series: [ { name: '电导率', data: {$random1}, type: 'line', areaStyle: {}, smooth: true, symbol: 'none', }, ]}") ), amisMake()->Card()->className('m-r')->body( amisMake()->Chart()->config("{ title:{ text: '氧气', subtext: 'mg/L'}, tooltip: { trigger: 'axis' }, xAxis: { type: 'category', boundaryGap: false, data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'] }, yAxis: { type: 'value' }, grid:{ left: '7%', right:'3%', top: 60, bottom: 30, }, series: [ { name: '光照强度LUX', data: {$random1}, type: 'line', areaStyle: {}, smooth: true, symbol: 'none', }, ]}") ), amisMake()->Card()->body( amisMake()->Chart()->config("{ title:{ text: 'PH'}, tooltip: { trigger: 'axis' }, xAxis: { type: 'category', boundaryGap: false, data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'] }, yAxis: { type: 'value' }, grid:{ left: '7%', right:'3%', top: 60, bottom: 30, }, series: [ { name: '光照强度LUX', data: {$random1}, type: 'line', areaStyle: {}, smooth: true, symbol: 'none', }, ]}") ), ]), ]), \amisMake()->grid()->columns([ amisMake()->Flex()->items([ amisMake()->Card()->className('m-r')->body( amisMake()->Chart()->config("{ title:{ text: '温度', subtext: '℃'}, tooltip: { trigger: 'axis' }, xAxis: { type: 'category', boundaryGap: false, data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'] }, yAxis: { type: 'value' }, grid:{ left: '7%', right:'3%', top: 60, bottom: 30, }, series: [ { name:'温度', data: {$random2}, type: 'line', areaStyle: {}, smooth: true, symbol: 'none', }, ]}") ), amisMake()->Card()->body( amisMake()->Chart()->config("{ title:{ text: '浊度', subtext: 'NTU'}, tooltip: { trigger: 'axis' }, xAxis: { type: 'category', boundaryGap: false, data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'] }, yAxis: { type: 'value' }, grid:{ left: '7%', right:'3%', top: 60, bottom: 30, }, series: [ { name: '空气湿度', data: {$random1}, type: 'line', areaStyle: {}, smooth: true, symbol: 'none', }, ]}") ) ]), ]), ]); } /** * 空气条件设置 */ public function airDetail(){ return amisMake()->Grid()->columns([ amisMake()->Wrapper()->sm(6)->body([ amisMake()->Panel()->title('智能开关设置') ->labelWidth(100) ->className('Panel--success') ->body([ \amisMake()->Form()->title('')->mode('horizontal')->body([ amisMake()->FieldSetControl()->title('智能开启')->body([ \amisMake()->SwitchControl()->name('open_is_enable')->label('开关'), \amisMake()->ConditionBuilderControl()->label('条件')->fields([ [ 'label' => '温度', 'type'=>'number','step'=>'0.01','name'=>'q', 'operators'=> [ 'equal', 'not_equal', 'less', 'less_or_equal', 'greater', 'greater_or_equal', 'between', 'not_between', // 'is_empty', 'is_not_empty' ] ], [ 'label' => '湿度', 'type'=>'number','step'=>'0.01','name'=>'x', 'operators'=> [ 'equal', 'not_equal', 'less', 'less_or_equal', 'greater', 'greater_or_equal', 'between', 'not_between', // 'is_empty', 'is_not_empty' ] ], ]), ]), amisMake()->FieldSetControl()->title('智能关闭')->body([ \amisMake()->SwitchControl()->name('close_is_enable')->label('开关'), \amisMake()->ConditionBuilderControl()->label('条件')->fields([ [ 'label' => '温度', 'type'=>'number','step'=>'0.01','name'=>'q', 'operators'=> [ 'equal', 'not_equal', 'less', 'less_or_equal', 'greater', 'greater_or_equal', 'between', 'not_between', // 'is_empty', 'is_not_empty' ] ], [ 'label' => '湿度', 'type'=>'number','step'=>'0.01','name'=>'x', 'operators'=> [ 'equal', 'not_equal', 'less', 'less_or_equal', 'greater', 'greater_or_equal', 'between', 'not_between', // 'is_empty', 'is_not_empty' ] ], ]), ]), ]), ]) ]), amisMake()->Wrapper()->sm(6)->body([ amisMake()->Panel()->title('开关记录') ->className('Panel--success') ->body([ \amisMake()->Table()->title('') ->data([ 'items' => [ [ 'name'=> '温度>10℃', 'name1'=> '关闭', 'time1'=> '2023-03-21 10:00:00', ] ] ]) ->columns([ amisMake()->TableColumn()->name('name')->label('触发条件'), amisMake()->TableColumn()->name('name1')->label('状态'), amisMake()->TableColumn()->name('time1')->label('执行时间'), ]) ]) ]), ]); } /** * 喷灌 */ public function wasserstrahlDetail(){ return amisMake()->Grid()->columns([ amisMake()->Wrapper()->sm(6)->body([ amisMake()->Panel()->title('智能喷灌设置') ->subFormMode('horizontal') ->labelWidth(80) ->className('Panel--success') ->body([ \amisMake()->Form()->title('')->mode('horizontal')->body([ amisMake()->FieldSetControl()->title('定时喷灌')->body([ \amisMake()->SwitchControl()->name('is_enable')->label('开关'), \amisMake()->ArrayControl()->name('config')->label('定时')->items([ amisMake()->ComboControl()->items([ \amisMake()->InputTimeRange(), \amisMake()->TextControl()->name('input')->label('喷灌量')->labelWidth(30), ]), ]), ]), ]), ]) ]), amisMake()->Wrapper()->sm(6)->body([ amisMake()->Panel()->title('开关记录') ->className('Panel--success') ->body([ \amisMake()->Table()->title('') ->data([ 'items' => [ [ 'name'=> '定时喷灌', 'name1'=> '关闭', 'time1'=> '2023-03-21 10:00:00', ] ] ]) ->columns([ amisMake()->TableColumn()->name('name')->label('触发条件'), amisMake()->TableColumn()->name('name1')->label('状态'), amisMake()->TableColumn()->name('time1')->label('执行时间'), ]) ]) ]), ]); } }