'require|checkData', 'project_id' => 'require|checkProject', 'contract_id' => 'require|checkContract', 'settlement_amount' => 'require|float|egt:0', 'settlement_date' => 'require|dateFormat:Y-m-d', 'annex' => 'checkAnnex', 'flow_id' => 'require|checkFlow', 'path' => 'require', ]; protected $message = [ 'id.require' => '缺少必要参数', 'project_id.require' => '请选择项目', 'contract_id.require' => '请选择合同', 'settlement_amount.require' => '请填写结算金额', 'settlement_amount.float' => '结算金额值必须是数字', 'settlement_amount.egt' => '结算金额值必须大于等于0', 'settlement_date.require' => '请选择结算日期', 'settlement_date.dateFormat' => '结算日期格式错误', ]; /** * @notes 添加场景 * @return ProjectSettlementValidate * @author likeadmin * @date 2023/12/29 10:22 */ public function sceneAdd() { return $this->remove('id',true)->remove('flow_id',true)->remove('path',true); } /** * @notes 编辑场景 * @return ProjectSettlementValidate * @author likeadmin * @date 2023/12/29 10:22 */ public function sceneEdit() { return $this->remove('flow_id',true)->remove('path',true); } /** * @notes 删除场景 * @return ProjectSettlementValidate * @author likeadmin * @date 2023/12/29 10:22 */ public function sceneDelete() { return $this->only(['id']); } /** * @notes 详情场景 * @return ProjectSettlementValidate * @author likeadmin * @date 2023/12/29 10:22 */ public function sceneDetail() { return $this->only(['id']); } public function sceneApprove() { return $this->only(['id','flow_id','path']); } public function checkData($value): bool|string { $data = ProjectSettlement::where('id',$value)->findOrEmpty(); if($data->isEmpty()){ return '数据不存在'; } return true; } public function checkProject($value): bool|string { $data = Project::where('id',$value)->findOrEmpty(); if($data->isEmpty()){ return '项目不存在'; } return true; } public function checkContract($value,$rule,$data): bool|string { $contract = Contract::where('id',$value)->findOrEmpty(); if($contract->isEmpty()){ return '合同不存在'; } $bid = BidBuyBiddingDocument::where('id',$contract['buy_bidding_document_id'])->findOrEmpty(); if($bid->isEmpty() || $bid['project_id'] != $data['project_id']){ return '合同无效'; } return true; } public function checkAnnex($value): bool|string { if(!empty($value) && $value != ''){ if(!is_array($value)){ return '附件必须是json数组'; } } return true; } }