From 924402a16a245974f53cea28fd50decd8d68e0ea Mon Sep 17 00:00:00 2001 From: "zangch@mesnac.com" Date: Mon, 16 Mar 2026 09:39:22 +0800 Subject: [PATCH] =?UTF-8?q?feat(crmGiftApply):=20=E7=A4=BC=E5=93=81?= =?UTF-8?q?=E7=94=B3=E8=AF=B7=E6=94=AF=E6=8C=81=E5=89=AF=E6=80=BB=E8=A7=92?= =?UTF-8?q?=E8=89=B2=E5=88=A4=E6=96=AD=E4=B8=8E=E5=8F=98=E9=87=8F=E4=BC=A0?= =?UTF-8?q?=E9=80=92?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 礼品申请流程副总走市场经理审批 - 角色有副总,通过登陆用户角色判断是否副总 --- src/views/oa/crm/crmGiftApply/edit.vue | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/src/views/oa/crm/crmGiftApply/edit.vue b/src/views/oa/crm/crmGiftApply/edit.vue index d50394e..8e7a243 100644 --- a/src/views/oa/crm/crmGiftApply/edit.vue +++ b/src/views/oa/crm/crmGiftApply/edit.vue @@ -229,6 +229,10 @@ const userList = ref([]); // 用户列表,用于审批人选择 // 市场部ID常量 const MARKETING_DEPT_ID = 106; +// 副总角色标识 +const VICE_PRESIDENT_ROLE_KEY = 'FGFZ'; +// 缓存登录用户角色,用于提交流程变量和界面联动 +const currentUserRoles = ref([]); // 表单数据 const initFormData: CrmGiftApplyForm = { @@ -280,7 +284,7 @@ const rules = reactive({ // 计算属性:判断是否显示审批人选择器(非市场部用户显示) const showApproverSelector = computed(() => { - return form.value.applicantDeptId !== undefined && form.value.applicantDeptId !== MARKETING_DEPT_ID; + return form.value.applicantDeptId !== undefined && form.value.applicantDeptId !== MARKETING_DEPT_ID && !isVicePresident.value; }); // 计算属性:判断表单是否禁用 @@ -288,6 +292,9 @@ const isFormDisabled = computed(() => { return routeParams.value.type === 'view' || routeParams.value.type === 'approval'; }); +// 通过登录用户角色判断是否副总,避免把组织身份写死到部门规则里 +const isVicePresident = computed(() => currentUserRoles.value.includes(VICE_PRESIDENT_ROLE_KEY)); + /** 加载客户列表 */ const loadCustomerList = async () => { try { @@ -330,6 +337,7 @@ const initUserInfo = async () => { try { const res = await getInfo(); const user = res.data.user; + currentUserRoles.value = Array.isArray(res.data.roles) ? res.data.roles : []; form.value.applicantId = user.userId; form.value.applicantName = user.nickName; form.value.applicantDeptId = user.deptId; @@ -341,6 +349,12 @@ const initUserInfo = async () => { if (!form.value.variables) { form.value.variables = {}; } + // 角色快照写入变量,便于流程排查时直接看到发起时的身份信息 + form.value.variables = { + ...form.value.variables, + roleKeys: currentUserRoles.value.join(','), + isVicePresident: isVicePresident.value ? '1' : '0' + }; } catch (error) { console.error('获取用户信息失败:', error); } @@ -479,8 +493,7 @@ const submitForm = async (status: string) => { } else { // 提交审批 form.value.flowCode = FLOW_CODE; - // P0-2: 添加 deptId 和 deptName 用于工作流条件分支判断 - // 保留已选择的approverId(用于非市场部用户的部门经理审批节点) + // 这里同时传部门与角色变量,原因是礼品流程既要按部门分支,也要优先识别“副总直达市场经理” form.value.variables = { ...form.value.variables, // 保留 approverId 和 approverName giftApplyId: form.value.giftApplyId, @@ -489,6 +502,8 @@ const submitForm = async (status: string) => { applicantName: form.value.applicantName, deptId: form.value.applicantDeptId, deptName: form.value.applicantDeptName, + roleKeys: currentUserRoles.value.join(','), + isVicePresident: isVicePresident.value ? '1' : '0', totalAmount: form.value.totalAmount, customerUnitName: form.value.customerUnitName };