From cb26fffc7beab0d44806eeb6fb38c2bdbf968020 Mon Sep 17 00:00:00 2001 From: Yangk Date: Mon, 23 Mar 2026 15:10:38 +0800 Subject: [PATCH] =?UTF-8?q?feat(oa/crm):=20=E4=B8=BA=E5=87=BA=E5=B7=AE?= =?UTF-8?q?=E7=94=B3=E8=AF=B7=E5=AE=A1=E6=89=B9=E6=B5=81=E7=A8=8B=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0=E5=8A=A8=E6=80=81=E8=A1=A8=E5=8D=95=E9=AA=8C=E8=AF=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 在审批模式下为申请人添加开始和结束日期的强制校验 - 实现结束日期必须晚于开始日期的自定义验证逻辑 - 仅在审批类型且当前用户为申请人时启用强校验 --- src/views/oa/crm/businessTripApply/edit.vue | 23 +++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/src/views/oa/crm/businessTripApply/edit.vue b/src/views/oa/crm/businessTripApply/edit.vue index 87e620c..a53d382 100644 --- a/src/views/oa/crm/businessTripApply/edit.vue +++ b/src/views/oa/crm/businessTripApply/edit.vue @@ -20,7 +20,7 @@ 出差申请{{ routeParams.type === 'view' ? ' - 查看' : form.tripId ? ' - 修改' : ' - 新增' }} - + @@ -132,7 +132,7 @@ - + @@ -489,6 +489,25 @@ const isFormDisabled = computed(() => { // 计算动态校验规则 const computedRules = computed(() => { const baseRules = { ...rules.value }; + + // 申请人确认节点添加强校验(开始日期和结束日期不为空,且结束要在开始之后) + if (routeParams.value.type === 'approval' && String(useUserStore().userId) === String(form.value.applicantId)) { + baseRules.startTime = [{ required: true, message: '开始日期不能为空', trigger: 'change' }]; + baseRules.endTime = [ + { required: true, message: '结束日期不能为空', trigger: 'change' }, + { + validator: (rule: any, value: any, callback: any) => { + if (value && form.value.startTime && dayjs(value).isBefore(dayjs(form.value.startTime))) { + callback(new Error('结束日期不能早于开始日期')); + } else { + callback(); + } + }, + trigger: 'change' + } + ]; + } + return baseRules; });