'require|checkData', 'project_id' => 'require|checkProject', 'enter_time' => 'require|dateFormat:Y-m-d H:i:s', 'company_id' => 'checkCompany', 'enter_result' => 'require|in:0,1', 'entry_detail' => 'checkEntryDetail', 'entry_problem' => 'checkEntryProblem' ]; /** * 参数描述 * @var string[] */ protected $field = [ 'id' => 'id', 'project_id' => '项目id', 'code' => '编号', 'enter_time' => '进场时间', 'company_id' => '施工单位', 'enter_result' => '进场结果', 'co_participant' => '共同参与人', 'remark' => '备注', 'create_user' => '操作人', ]; /** * @notes 添加场景 * @return SupervisionDeviceEntryValidate * @author likeadmin * @date 2024/02/28 16:12 */ public function sceneAdd() { return $this->remove('id',true); } /** * @notes 编辑场景 * @return SupervisionDeviceEntryValidate * @author likeadmin * @date 2024/02/28 16:12 */ public function sceneEdit() {} /** * @notes 删除场景 * @return SupervisionDeviceEntryValidate * @author likeadmin * @date 2024/02/28 16:12 */ public function sceneDelete() { return $this->only(['id']); } /** * @notes 详情场景 * @return SupervisionDeviceEntryValidate * @author likeadmin * @date 2024/02/28 16:12 */ public function sceneDetail() { return $this->only(['id']); } public function checkData($value): bool|string { $data = SupervisionDeviceEntry::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 checkCompany($value,$rule,$params): bool|string { $data = SupervisionParticipatingUnits::where('id',$value)->where('project_id',$params['project_id'])->findOrEmpty(); if($data->isEmpty()){ return '施工单位信息不存在'; } return true; } public function checkEntryDetail($value): bool|string { if(!isset($value) || $value == '') return true; if(!is_array($value)) return '设备信息数据格式错误'; foreach($value as $k=>$v){ if(!empty($v['id'])){ $data = SupervisionDeviceEntryDetail::where('id',$v['id'])->findOrEmpty(); if($data->isEmpty()){ return '设备信息列表第'.($k+1).'行数据不存在'; } } if(empty($v['name'])) return '设备信息列表第'.($k+1).'行设备名称为空'; if(empty($v['brand'])) return '设备信息列表第'.($k+1).'行设备品牌为空'; if(empty($v['model'])) return '设备信息列表第'.($k+1).'行设备型号为空'; if(empty($v['unit'])) return '设备信息列表第'.($k+1).'行计数单位为空'; if(!isset($v['contract_brand']) || $v['contract_brand'] == ''){ return '设备信息列表第'.($k+1).'行是否合同约定品牌为空'; }else{ if(!in_array($v['contract_brand'],[0,1])) return '设备信息列表第'.($k+1).'行是否合同约定品牌选项数据值无效'; } if(empty($v['entry_number'])){ return '设备信息列表第'.($k+1).'行进场数量为空'; }else{ if(!is_numeric($v['entry_number'])) return '设备信息列表第'.($k+1).'行进场数量必须是数字'; } if(!isset($v['documentation']) || $v['documentation'] == ''){ return '设备信息列表第'.($k+1).'行证明文件是否齐全为空'; }else{ if(!in_array($v['documentation'],[0,1])) return '设备信息列表第'.($k+1).'行证明文件是否齐全选项数据值无效'; } if(!isset($v['verify']) || $v['verify'] == ''){ return '设备信息列表第'.($k+1).'行核对是否一致选项为空'; }else{ if(!in_array($v['verify'],[0,1])) return '设备信息列表第'.($k+1).'行核对是否一致项数据值无效'; } } return true; } public function checkEntryProblem($value): bool|string { if(!isset($value) || $value == '') return true; if(!is_array($value)) return '设备问题数据格式错误'; foreach($value as $k=>$v){ if(!empty($v['id'])){ $data = SupervisionProblem::where('id',$v['id'])->findOrEmpty(); if($data->isEmpty()){ return '设备问题列表第'.($k+1).'行数据不存在'; } } if(empty($v['problem_cate'])){ return '设备问题列表第'.($k+1).'行问题分类为空'; }else{ $dict = DictData::where('type_value','problem_cate')->column('value'); if(!in_array($v['problem_cate'],$dict)) return '设备问题列表第'.($k+1).'行问题分类数据值无效'; } if(empty($v['problem_description'])) return '设备问题列表第'.($k+1).'行问题说明为空'; if(empty($v['problem_name'])) return '设备问题列表第'.($k+1).'行问题名称为空'; } return true; } }