'require', 'project_id' => 'require|checkProject', 'theme' => 'require', 'follow_date' => 'require|dateFormat:Y-m-d', 'follow_type' => 'require|checkType', 'project_assurance' => 'require|checkAssurance', 'follow_status' => 'require|checkStatus', 'follow_stage' => 'require|checkStage', 'next_follow_up_date' => 'date|dateFormat:Y-m-d|checkNextFollowUpDate', 'annex' => 'checkAnnex', ]; protected $message = [ 'id.require' => '缺少必要参数', 'project_id.require' => '请选择项目', 'theme.require' => '请填写主题', 'follow_date.require' => '请选择日期', 'follow_date.dateFormat' => '日期格式错误', 'follow_type.require' => '请选择类型', 'project_assurance.require' => '请选择项目把握度', 'follow_status.require' => '请选择状态', 'follow_stage.require' => '请选择阶段', 'next_follow_up_date.dateFormat' => '下次回访日期格式错误' ]; /** * @notes 添加场景 * @return ProjectFollowUpValidate * @author likeadmin * @date 2023/11/14 10:49 */ public function sceneAdd() { return $this->remove('id', true); } /** * @notes 编辑场景 * @return ProjectFollowUpValidate * @author likeadmin * @date 2023/11/14 10:49 */ public function sceneEdit() {} /** * @notes 删除场景 * @return ProjectFollowUpValidate * @author likeadmin * @date 2023/11/14 10:49 */ public function sceneDelete() { return $this->only(['id']); } /** * @notes 详情场景 * @return ProjectFollowUpValidate * @author likeadmin * @date 2023/11/14 10:49 */ public function sceneDetail() { return $this->only(['id']); } public function checkProject($value): bool|string { $project = Project::where('id',$value)->findOrEmpty(); if($project->isEmpty()){ return '项目不存在'; } return true; } public function checkType($value): bool|string { $dictData = DictData::where('type_value','follow_type')->column('value'); if(!in_array($value,$dictData)){ return '类型值错误'; } return true; } public function checkAssurance($value): bool|string { $dictData = DictData::where('type_value','project_assurance')->column('value'); if(!in_array($value,$dictData)){ return '项目把握度值错误'; } return true; } public function checkStatus($value): bool|string { $dictData = DictData::where('type_value','follow_status')->column('value'); if(!in_array($value,$dictData)){ return '状态值错误'; } return true; } public function checkStage($value): bool|string { $dictData = DictData::where('type_value','follow_stage')->column('value'); if(!in_array($value,$dictData)){ return '阶段值错误'; } return true; } public function checkNextFollowUpDate($value,$rule,$data): bool|string { if(!empty($value)){ if(strtotime($value) < strtotime($data['follow_date'])){ return '下次回访日期不能小于项目跟进日期'; } } return true; } public function checkAnnex($value): bool|string { if(!empty($value) && $value != ''){ if(!is_array($value)){ return '附件格式错误'; } } return true; } }