'require|checkData', 'org_id' => 'require|checkOrg', 'dept_id' => 'require|checkDept', 'project_id' => 'require|checkProject', 'contract_amount' => 'require|float|egt:0', 'cl_cost' => 'float|egt:0', 'fb_cost' => 'float|egt:0', 'rg_cost' => 'float|egt:0', 'fy_cost' => 'float|egt:0', 'jj_cost' => 'float|egt:0', 'budget_list' => 'checkAnnex', 'budget_date' => 'require|dateFormat:Y-m-d', 'project_manager' => 'require', 'flow_id' => 'require|checkFlow', 'path' => 'require', ]; protected $message = [ 'id.require' => '缺少必要参数', 'org_id.require' => '请选择组织', 'dept_id.require' => '请选择部门', 'project_id.require' => '请选择项目', 'contract_amount.require' => '请填写合同金额', 'contract_amount.float' => '合同金额值必须是数字', 'contract_amount.egt' => '合同金额值必须大于等于0', 'cl_cost.float' => '材料成本值必须是数字', 'cl_cost.egt' => '材料成本值必须大于等于0', 'fb_cost.float' => '分包成本值必须是数字', 'fb_cost.egt' => '分包成本值必须大于等于0', 'rg_cost.float' => '人工成本值必须是数字', 'rg_cost.egt' => '人工成本值必须大于等于0', 'fy_cost.float' => '费用成本值必须是数字', 'fy_cost.egt' => '费用成本值必须大于等于0', 'jj_cost.float' => '机具成本值必须是数字', 'jj_cost.egt' => '机具成本值必须大于等于0', 'budget_date.dateFormat' => '预算日期数据格式错误', 'project_manager' => '请填写项目经理', ]; /** * @notes 添加场景 * @return ProjectTotalBudgetValidate * @author likeadmin * @date 2024/01/08 14:25 */ public function sceneAdd() { return $this->remove('id',true)->remove('flow_id',true)->remove('path',true); } /** * @notes 编辑场景 * @return ProjectTotalBudgetValidate * @author likeadmin * @date 2024/01/08 14:25 */ public function sceneEdit() { return $this->remove('org_id',true)->remove('dept_id',true)->remove('project_id',true)->remove('flow_id',true)->remove('path',true); } /** * @notes 删除场景 * @return ProjectTotalBudgetValidate * @author likeadmin * @date 2024/01/08 14:25 */ public function sceneDelete() { return $this->only(['id']); } /** * @notes 详情场景 * @return ProjectTotalBudgetValidate * @author likeadmin * @date 2024/01/08 14:25 */ public function sceneDetail() { return $this->only(['id']); } public function sceneApprove() { return $this->only(['id','flow_id','path']); } public function checkData($value): bool|string { $data = ProjectTotalBudget::where('id',$value)->findOrEmpty(); if($data->isEmpty()){ return '数据不存在'; } return true; } public function checkOrg($value): bool|string { $org = Orgs::where('id',$value)->findOrEmpty(); if($org->isEmpty()){ return '组织不存在'; } return true; } public function checkDept($value,$rule,$data): bool|string { $dept = Dept::where('id',$value)->findOrEmpty(); if($dept->isEmpty()){ return '部门不存在'; } if($dept['org_id'] != $data['org_id']){ return '部门无效'; } return true; } public function checkProject($value): bool|string { $project = Project::where('id',$value)->findOrEmpty(); if($project->isEmpty()){ return '项目信息不存在'; } if($project['is_budget'] == 1){ return '该项目已编制总预算'; } return true; } public function checkAnnex($value): bool|string { if(!empty($value) && $value != ''){ $annex = $value;//json_decode($value,true); if(empty($annex) || !is_array($annex)){ return '预算清单格式错误'; } } return true; } }