'require', 'code' => 'require', 'income_month' => 'require|dateFormat:Y-m', 'expense_time' => 'require|dateFormat:Y-m-d', 'flow_id' => 'require|checkFlow', 'annex' => 'checkAnnex', 'detail' => 'require|checkDetail', ]; /** * 参数描述 * @var string[] */ protected $field = [ 'id' => 'id', 'code' => '报销编码', 'income_month' => '入账月份', 'expense_time' => '原始单据日期', 'flow_id' => '审批流程', 'annex' => '附件', 'detail' => '报销选项', ]; /** * @notes 添加场景 * @return ExpenseValidate * @author likeadmin * @date 2024/05/24 14:16 */ public function sceneAdd() { return $this->only(['code','income_month','expense_time','flow_id','annex','detail','check_admin_ids','copy_uids']); } /** * @notes 编辑场景 * @return ExpenseValidate * @author likeadmin * @date 2024/05/24 14:16 */ public function sceneEdit() { return $this->only(['id','code','income_month','expense_time','flow_id','annex','detail','check_admin_ids','copy_uids']); } /** * @notes 删除场景 * @return ExpenseValidate * @author likeadmin * @date 2024/05/24 14:16 */ public function sceneDelete() { return $this->only(['id']); } /** * @notes 详情场景 * @return ExpenseValidate * @author likeadmin * @date 2024/05/24 14:16 */ public function sceneDetail() { return $this->only(['id']); } /** * @notes 详情场景 * @return ExpenseValidate * @author likeadmin * @date 2024/05/24 14:16 */ public function scenePay() { return $this->only(['id']); } public function checkFlow($value): bool|string { $data = OaFlow::where('id',$value)->findOrEmpty(); if($data->isEmpty()){ return '审批流程信息不存在'; } if($data['type'] != 5){ return '当前审批流信息不属于报销审批类型'; } return true; } public function checkDetail($value): bool|string { if(!is_array($value)){ return '报销选项数据格式错误'; } foreach($value as $k=>$v){ if(empty($v['amount'])){ return '报销选项第'.($k+1).'行报销金额为空'; } if(empty($v['cate_id'])){ return '报销选项第'.($k+1).'行报销项目为空'; } if(!in_array($v['cate_id'],[1,2,3,4,5,6])){ return '报销选项第'.($k+1).'行报销项目数据值错误'; } } return true; } }