'require|checkData', 'contract_id' => 'require|checkContract', 'negotiation_name' => 'require', 'negotiation_amount' => 'require|float|gt:0', 'negotiation_type' => 'require|checkNegotiationType', 'labor_costs' => 'float|egt:0', 'material_costs' => 'float|egt:0', 'warranty_amount' => 'float|egt:0', 'warranty_expire_date' => 'dateFormat:Y-m-d', 'negotiation_quotation' => 'checkAnnex', 'negotiation_basis' => 'checkAnnex', 'flow_id' => 'require|checkFlow', 'path' => 'require', ]; protected $message = [ 'id.require' => '缺少必要参数', 'contract_id.require' => '请选择项目合同', 'negotiation_name.require' => '请填写洽商单名称', 'negotiation_amount.require' => '请填写洽商金额', 'negotiation_amount.float' => '洽商金额值必须是数字', 'negotiation_amount.gt' => '洽商金额值必须大于0', 'negotiation_type.require' => '请选择洽商类别', 'labor_costs.float' => '成本金额(人工)值必须是数字', 'labor_costs.egt' => '成本金额(人工)值必须大于等于0', 'material_costs.float' => '成本金额(材料)值必须是数字', 'material_costs.egt' => '成本金额(材料)值必须大于等于0', 'warranty_amount.float' => '洽商质保金额值必须是数字', 'warranty_amount.egt' => '洽商质保金额值必须大于等于0', 'warranty_expire_date.dateFormat' => '洽商质保到期时间数据格式错误', ]; /** * @notes 添加场景 * @return ContractNegotiationValidate * @author likeadmin * @date 2023/12/04 21:26 */ public function sceneAdd() { return $this->remove('id', true)->remove('flow_id',true)->remove('path',true); } /** * @notes 编辑场景 * @return ContractNegotiationValidate * @author likeadmin * @date 2023/12/04 21:26 */ public function sceneEdit() { return $this->remove('flow_id',true)->remove('path',true); } /** * @notes 删除场景 * @return ContractNegotiationValidate * @author likeadmin * @date 2023/12/04 21:26 */ public function sceneDelete() { return $this->only(['id'])->remove('id','checkData'); } /** * @notes 详情场景 * @return ContractNegotiationValidate * @author likeadmin * @date 2023/12/04 21:26 */ public function sceneDetail() { return $this->only(['id']); } public function sceneApprove() { return $this->only(['id','flow_id','path']); } public function checkData($value): bool|string { $data = ContractNegotiation::where('id',$value)->findOrEmpty(); if($data->isEmpty()){ return '数据不存在'; } return true; } public function checkContract($value): bool|string { $contract = Contract::where('id',$value)->findOrEmpty(); if($contract->isEmpty()){ return '项目合同信息不存在'; } return true; } public function checkNegotiationType($value): bool|string { $dict = DictData::where('type_value','negotiation_type')->column('value'); if(!in_array($value,$dict)){ return '洽商类别无效'; } return true; } }