'require|checkData', 'material_parallel_testing_id' => 'require|checkMaterialParallelTesting', 'material_entry_detail_id' => 'require|checkMaterialEntryDetail', 'num' => 'require|float', 'check_code' => 'require', 'check_result' => 'require|in:1,2', 'check_time' => 'require|dateFormat:Y-m-d', 'check_user' => 'require', 'check_annex' => 'checkAnnex', 'check_problem' => 'checkProblem' ]; /** * 参数描述 * @var string[] */ protected $field = [ 'id' => 'id', 'material_parallel_testing_id' => '材料平行检验id', 'material_entry_detail_id' => '材料进场明细id', 'num' => '检验数量', 'check_code' => '报告编号', 'check_result' => '检验结果', 'check_time' => '获得日期', 'check_user' => '操作人', 'check_remark' => '备注', ]; /** * @notes 添加场景 * @return SupervisionMaterialParallelTestingDetailValidate * @author likeadmin * @date 2024/02/29 15:00 */ public function sceneAdd() { return $this->only(['material_parallel_testing_id','material_entry_detail_id','num']); } /** * @notes 编辑场景 * @return SupervisionMaterialParallelTestingDetailValidate * @author likeadmin * @date 2024/02/29 15:00 */ public function sceneEdit() { return $this->only(['id','material_parallel_testing_id','material_entry_detail_id','num']); } /** * @notes 检验场景 * @return SupervisionMaterialParallelTestingDetailValidate * @author likeadmin * @date 2024/02/29 09:22 */ public function sceneCheck() { return $this->only(['id','check_code','check_result','check_time','check_user','check_remark','check_annex','check_problem']); } /** * @notes 删除场景 * @return SupervisionMaterialParallelTestingDetailValidate * @author likeadmin * @date 2024/02/29 15:00 */ public function sceneDelete() { return $this->only(['id']); } /** * @notes 详情场景 * @return SupervisionMaterialParallelTestingDetailValidate * @author likeadmin * @date 2024/02/29 15:00 */ public function sceneDetail() { return $this->only(['id']); } public function checkData($value): bool|string { $data = SupervisionMaterialParallelTestingDetail::where('id',$value)->findOrEmpty(); if($data->isEmpty()){ return '数据不存在'; } return true; } public function checkMaterialParallelTesting($value): bool|string { $data = SupervisionMaterialParallelTesting::where('id',$value)->findOrEmpty(); if($data->isEmpty()){ return '材料平行检验信息不存在'; } return true; } public function checkMaterialEntryDetail($value,$rule,$params): bool|string { $witness_sampling = SupervisionMaterialParallelTesting::where('id',$params['material_parallel_testing_id'])->findOrEmpty(); $data = SupervisionMaterialEntryDetail::where('id',$value)->where('material_entry_id',$witness_sampling['material_entry_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 checkProblem($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; } }