'require|checkData', 'project_id' => 'require|checkProject', 'side_station_type' => 'require|checkSideStationType', 'check_item_id' => 'require|checkCheckItem', 'company_id' => 'checkCompany', 'start_time' => 'require|dateFormat:Y-m-d H:i:s', 'end_time' => 'require|dateFormat:Y-m-d H:i:s', 'workers' => 'integer', 'managers' => 'integer', 'side_station_result' => 'in:0,1', 'check_item_detail_ids' => 'checkCheckItemDetail', 'annex' => 'checkAnnex', 'side_result' => 'checkSideResult', 'side_problem' => 'checkSideProblem' ]; /** * 参数描述 * @var string[] */ protected $field = [ 'id' => 'id', 'project_id' => '项目id', 'side_station_code' => '旁站编号', 'side_station_type' => '旁站类型', 'check_item_id' => '单位工程', 'position' => '部位', 'company_id' => '施工单位', 'start_time' => '旁站开始时间', 'end_time' => '旁站结束时间', 'workers' => '施工人数', 'managers' => '管理人数', 'situation' => '现场施工情况', 'side_station_result' => '旁站结果 0-完成 1-交班', 'side_station_user' => '旁站人员', 'create_user' => '创建人', ]; /** * @notes 添加场景 * @return SupervisionSideStationValidate * @author likeadmin * @date 2024/02/27 13:58 */ public function sceneAdd() { return $this->remove('id',true); } /** * @notes 编辑场景 * @return SupervisionSideStationValidate * @author likeadmin * @date 2024/02/27 13:58 */ public function sceneEdit() {} /** * @notes 删除场景 * @return SupervisionSideStationValidate * @author likeadmin * @date 2024/02/27 13:58 */ public function sceneDelete() { return $this->only(['id']); } /** * @notes 详情场景 * @return SupervisionSideStationValidate * @author likeadmin * @date 2024/02/27 13:58 */ public function sceneDetail() { return $this->only(['id']); } public function checkData($value): bool|string { $data = SupervisionSideStation::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 checkSideStationType($value): bool|string { $dict = DictData::where('type_value','side_station_type')->column('value'); if(!in_array($value,$dict)){ return '旁站类型数据值无效'; } return true; } public function checkCheckItem($value,$rule,$params): bool|string { $data = SupervisionCheckItem::where('id',$value)->where('project_id',$params['project_id'])->where('node_type',2)->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 checkCheckItemDetail($value,$rule,$params): bool|string { if(!isset($value) || $value == '') return true; if(!is_array($value)) return '检查表单选择数据格式错误'; foreach($value as $v){ $data = SupervisionCheckItem::where('id',$v)->where('project_id',$params['project_id'])->findOrEmpty(); if($data->isEmpty()){ return '检查项节点数据不存在'; } } return true; } public function checkAnnex($value): bool|string { if(!empty($value) && $value != '' && !is_array($value)){ return '附件格式错误'; } return true; } public function checkSideResult($value): bool|string { if(!isset($value) || $value == '') return true; if(!is_array($value)) return '旁站结果数据格式错误'; foreach($value as $k=>$v){ if(!empty($v['id'])){ $data = SupervisionSideStationResult::where('id',$v['id'])->findOrEmpty(); if($data->isEmpty()){ return '旁站结果列表第'.($k+1).'行数据不存在'; } } if(empty($v['check_type'])) return '旁站结果列表第'.($k+1).'行检查类别为空'; if(empty($v['check_content'])) return '旁站结果列表第'.($k+1).'行检查内容为空'; if(!isset($v['must_check']) || $v['must_check'] == '') return '旁站结果列表第'.($k+1).'行是否必检为空'; if(!in_array($v['must_check'],[0,1])) return '旁站结果列表第'.($k+1).'行是否必检数据值无效'; if(!isset($v['check_result']) || $v['check_result'] == '') return '旁站结果列表第'.($k+1).'行检查结果为空'; if(!in_array($v['check_result'],[0,1])) return '旁站结果列表第'.($k+1).'行检查结果数据值无效'; } return true; } public function checkSideProblem($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; } }