'require|checkData', 'expense_reimbursement_id' => 'require|checkExpenseReimbursement', 'dept_id' => 'require|checkDept', 'date' => 'dateFormat:Y-m-d', 'subject_name' => 'require|checkSubjectName', 'amount' => 'require|float|egt:0', ]; /** * 参数描述 * @var string[] */ protected $field = [ 'id' => 'id', 'expense_reimbursement_id' => '费用报销单id', 'dept_id' => '费用归属部门', 'date' => '发生日期', 'subject_name' => '科目名称', 'amount' => '金额', 'abstract' => '摘要', ]; /** * @notes 添加场景 * @return FinancialExpenseReimbursementDetailValidate * @author likeadmin * @date 2024/03/28 09:26 */ public function sceneAdd() { return $this->only(['expense_reimbursement_id', 'dept_id', 'date', 'subject_name', 'amount', 'abstract']); } /** * @notes 编辑场景 * @return FinancialExpenseReimbursementDetailValidate * @author likeadmin * @date 2024/03/28 09:26 */ public function sceneEdit() { return $this->only(['id', 'expense_reimbursement_id', 'dept_id', 'date', 'subject_name', 'amount', 'abstract']); } /** * @notes 删除场景 * @return FinancialExpenseReimbursementDetailValidate * @author likeadmin * @date 2024/03/28 09:26 */ public function sceneDelete() { return $this->only(['id'])->remove('id', 'checkData'); } /** * @notes 详情场景 * @return FinancialExpenseReimbursementDetailValidate * @author likeadmin * @date 2024/03/28 09:26 */ public function sceneDetail() { return $this->only(['id']); } public function checkData($value): bool|string { $data = FinancialExpenseReimbursementDetail::where('id', $value)->findOrEmpty(); return $data->isEmpty() ? '数据不存在' : true; } public function checkExpenseReimbursement($value): bool|string { $data = FinancialExpenseReimbursement::where('id', $value)->findOrEmpty(); return $data->isEmpty() ? '费用报销单信息不存在' : true; } public function checkDept($value): bool|string { $data = Dept::where('id', $value)->findOrEmpty(); return $data->isEmpty() ? '费用归属部门信息不存在' : true; } public function checkSubjectName($value): bool|string { $dict = DictData::where('type_value', 'subject_category')->column('value'); return !in_array($value, $dict) ? '科目名称数据值无效' : true; } }