'require|checkData', 'project_id' => 'require|checkProject', 'device_name' => 'require', 'device_type' => 'checkDeviceType', 'devices' => 'checkDevices' ]; /** * 参数描述 * @var string[] */ protected $field = [ 'id' => 'id', 'project_id' => '项目id', 'device_name' => '监控设备名称', 'device_type' => '设备类型', 'device_sn' => '设备序列号', 'number' => '编号', 'remark' => '备注', ]; /** * @notes 添加场景 * @return SupervisionMonitoringEquipmentValidate * @author likeadmin * @date 2024/02/23 15:20 */ public function sceneAdd() { return $this->remove('id',true); } /** * @notes 编辑场景 * @return SupervisionMonitoringEquipmentValidate * @author likeadmin * @date 2024/02/23 15:20 */ public function sceneEdit() {} /** * @notes 删除场景 * @return SupervisionMonitoringEquipmentValidate * @author likeadmin * @date 2024/02/23 15:20 */ public function sceneDelete() { return $this->only(['id']); } /** * @notes 详情场景 * @return SupervisionMonitoringEquipmentValidate * @author likeadmin * @date 2024/02/23 15:20 */ public function sceneDetail() { return $this->only(['id']); } public function checkData($value): bool|string { $data = SupervisionMonitoringEquipment::where('id',$value)->findOrEmpty(); if($data->isEmpty()){ return '数据不存在'; } return true; } public function checkProject($value): bool|string { $data = SupervisionProject::where('id',$value)->findOrEmpty(); if($data->isEmpty()){ return '项目信息不存在'; } return true; } public function checkDeviceType($value): bool|string { $dict = DictData::where('type_value','device_type')->column('value'); if(!in_array($value,$dict)){ return '设备类型数据值无效'; } return true; } public function checkDevices($value): bool|string { if(empty($value) || $value == '') return true; if(!is_array($value)) return '设备列表数据格式错误'; foreach($value as $k=>$v){ if(isset($v['id']) && !empty($v['id'])){ $data = SupervisionMonitoringEquipmentDetail::where('id',$v['id'])->findOrEmpty(); if($data->isEmpty()){ return '第'.($k+1).'行设备信息不存在'; } } if(empty($v['name'])){ return '第'.($k+1).'行设备名称为空'; } } return true; } }