'require|checkData', 'approve_dept' => 'require|checkDept', 'cost_type' => 'require|checkCostType', 'pay_type' => 'require|checkPayType', 'tax_deductible_amount' => 'float|egt:0', 'bill_num' => 'require|integer|egt:0', 'fee_application_id' => 'checkFeeApplication', 'create_user' => 'require', 'create_time' => 'require|dateFormat:Y-m-d H:i:s', 'detail' => 'checkDetail' ]; /** * 参数描述 * @var string[] */ protected $field = [ 'id' => 'id', 'code' => '单据编号', 'approve_dept' => '审批部门', 'cost_type' => '费用类别', 'pay_type' => '支付方式', 'tax_deductible_amount' => '可抵扣税额', 'bill_num' => '附单据张数', 'fee_application_id' => '关联费用申请', 'content' => '事由', 'create_user' => '申请人', 'create_time' => '申请日期', ]; /** * @notes 添加场景 * @return FinancialTravelReimbursementValidate * @author likeadmin * @date 2024/03/28 14:23 */ public function sceneAdd() { return $this->remove('id', true); } /** * @notes 编辑场景 * @return FinancialTravelReimbursementValidate * @author likeadmin * @date 2024/03/28 14:23 */ public function sceneEdit() { return $this->only(['id', 'approve_dept', 'cost_type', 'pay_type', 'tax_deductible_amount', 'bill_num', 'fee_application_id', 'content', 'create_user', 'create_time', 'detail']); } /** * @notes 删除场景 * @return FinancialTravelReimbursementValidate * @author likeadmin * @date 2024/03/28 14:23 */ public function sceneDelete() { return $this->only(['id'])->remove('id', 'checkData'); } /** * @notes 详情场景 * @return FinancialTravelReimbursementValidate * @author likeadmin * @date 2024/03/28 14:23 */ public function sceneDetail() { return $this->only(['id']); } public function checkData($value): bool|string { $data = FinancialTravelReimbursement::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 checkCostType($value): bool|string { $dict = DictData::where('type_value', 'cost_type')->column('value'); return !in_array($value, $dict) ? '费用类别数据值无效' : true; } public function checkPayType($value): bool|string { $dict = DictData::where('type_value', 'financial_pay_type')->column('value'); return !in_array($value, $dict) ? '支付方式数据值无效' : true; } public function checkFeeApplication($value): bool|string { if (empty($value)) return true; $data = FinancialFeeApplication::where('id', $value)->findOrEmpty(); return $data->isEmpty() ? '费用申请信息不存在' : true; } public function checkDetail($value): bool|string { if (empty($value) || $value == '') return true; if (!is_array($value)) return '报销明细数据格式错误'; foreach ($value as $k => $v) { if (isset($v['id']) && !empty($v['id'])) { $data = FinancialTravelReimbursementDetail::where('id', $v['id'])->findOrEmpty(); if ($data->isEmpty()) { return '第' . ($k + 1) . '行报销明细信息不存在'; } } if (empty($v['dept_id'])) { return '第' . ($k + 1) . '行费用归属部门为空'; } else { $dept = Dept::where('id', $v['dept_id'])->findOrEmpty(); if ($dept->isEmpty()) return '第' . ($k + 1) . '行费用归属部门信息不存在'; } if (empty($v['date'])) { return '第' . ($k + 1) . '行起止日期为空'; } if (empty($v['address'])) { return '第' . ($k + 1) . '行起止地点为空'; } } return true; } }