From 3338d4fd90f07eb9763f6306888b521aea5e2428 Mon Sep 17 00:00:00 2001 From: Yangk Date: Fri, 9 Jan 2026 15:20:10 +0800 Subject: [PATCH] =?UTF-8?q?feat(oa):=20=E6=B7=BB=E5=8A=A0=E5=87=BA?= =?UTF-8?q?=E5=B7=AE=E7=94=B3=E8=AF=B7=E5=92=8C=E5=94=AE=E5=90=8E=E7=94=B3?= =?UTF-8?q?=E8=AF=B7=E7=9A=84=E6=8A=84=E9=80=81=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 在出差申请编辑页面添加抄送人员选择下拉框 - 实现抄送人员的自动填充逻辑,包括默认人员和部门负责人 - 在售后申请中添加项目管理角色用户作为抄送对象 --- src/api/oa/crm/businessTripApply/types.ts | 5 ++ src/views/oa/crm/businessTripApply/edit.vue | 69 ++++++++++++++++----- src/views/oa/erp/afterSales/edit.vue | 8 ++- 3 files changed, 66 insertions(+), 16 deletions(-) diff --git a/src/api/oa/crm/businessTripApply/types.ts b/src/api/oa/crm/businessTripApply/types.ts index 04e382f..cb5a53a 100644 --- a/src/api/oa/crm/businessTripApply/types.ts +++ b/src/api/oa/crm/businessTripApply/types.ts @@ -263,6 +263,11 @@ export interface BusinessTripApplyForm extends BaseEntity { * 流程编码 */ flowCode?: string; + + /** + * 抄送人员ID列表 + */ + copyUserIds?: string | string[]; } export interface BusinessTripApplyQuery extends PageQuery { diff --git a/src/views/oa/crm/businessTripApply/edit.vue b/src/views/oa/crm/businessTripApply/edit.vue index 9cce556..a48a465 100644 --- a/src/views/oa/crm/businessTripApply/edit.vue +++ b/src/views/oa/crm/businessTripApply/edit.vue @@ -181,7 +181,7 @@ - + + + + + + + + @@ -227,6 +233,7 @@ import ProjectSelect from '@/components/ProjectSelect/index.vue'; import { CodeRuleEnum, FlowCodeEnum } from '@/enums/OAEnum'; import { getInfo } from '@/api/login'; import { listUser } from '@/api/system/user'; // 导入用户列表API +import { allListDept } from '@/api/system/dept'; // 导入部门列表API import { ProjectInfoVO } from '@/api/oa/erp/projectInfo/types'; import dayjs from 'dayjs'; @@ -248,6 +255,10 @@ const projectSelectRef = ref>(); // const userSelectRef = ref>(); // 审批人选择 ref const userList = ref([]); // 用户列表 +const deptInfoList = ref([]); // 部门列表 + +// 默认抄送人员的昵称列表 +const defaultCopyUserNames = ['米兰', '于洋', '张兰艳', '张东辉', '冯俊杰']; // 流程相关数据 const submitFormData = ref({ @@ -283,7 +294,8 @@ const initFormData: BusinessTripApplyForm = { flowStatus: 'draft', remark: undefined, ossId: undefined, - variables: {} // 初始化 variables + variables: {}, // 初始化 variables + copyUserIds: [] as string[] // 抄送人员ID列表 }; const data = reactive({ @@ -327,15 +339,40 @@ onMounted(async () => { routeParams.value = route.query; const id = routeParams.value.id; + // 加载用户列表 (用于审批人选择和抄送人员选择) + const userRes = await listUser({ pageNum: 1, pageSize: 1000 }); + userList.value = userRes.rows; + + // 加载部门列表 (用于获取部门负责人和分管副总) + const deptRes = await allListDept({ deptCategory: '03' } as any); + deptInfoList.value = deptRes.data || []; + // 自动填充申请人信息 if (!id) { try { - const userRes = await getInfo(); - if (userRes.data?.user) { - form.value.applicantId = userRes.data.user.userId; - form.value.applicantName = userRes.data.user.nickName; - form.value.deptId = userRes.data.user.deptId; - form.value.deptName = userRes.data.user.deptName; + const infoRes = await getInfo(); + if (infoRes.data?.user) { + form.value.applicantId = infoRes.data.user.userId; + form.value.applicantName = infoRes.data.user.nickName; + form.value.deptId = infoRes.data.user.deptId; + form.value.deptName = infoRes.data.user.deptName; + + // 根据部门ID获取部门负责人和分管副总 + const deptInfo = deptInfoList.value.find((d: any) => d.deptId === infoRes.data.user.deptId); + if (deptInfo) { + const deptLeaderId = deptInfo.leader; + const vicePresidentId = deptInfo.vicePresident; + // 将部门负责人和分管副总加入默认抄送人员 + const deptCopyIds: string[] = []; + if (deptLeaderId) deptCopyIds.push(String(deptLeaderId)); + if (vicePresidentId) deptCopyIds.push(String(vicePresidentId)); + + // 根据昵称匹配默认抄送人员 + const defaultCopyIds = userList.value.filter((u: any) => defaultCopyUserNames.includes(u.nickName)).map((u: any) => String(u.userId)); + + // 合并默认抄送人员和部门负责人/分管副总(去重) + form.value.copyUserIds = [...new Set([...defaultCopyIds, ...deptCopyIds])]; + } } } catch (e) { console.error('获取用户信息失败', e); @@ -346,14 +383,13 @@ onMounted(async () => { } } - // 加载用户列表 (用于审批人选择) - listUser({ pageNum: 1, pageSize: 1000 }).then((res: any) => { - userList.value = res.rows; - }); - if (id && (routeParams.value.type === 'update' || routeParams.value.type === 'view' || routeParams.value.type === 'approval')) { const res = await getBusinessTripApply(id); Object.assign(form.value, res.data); + // 将抄送人员字符串转换为数组 + if (form.value.copyUserIds && typeof form.value.copyUserIds === 'string') { + form.value.copyUserIds = (form.value.copyUserIds as string).split(',').filter((id) => id); + } } }); }); @@ -426,9 +462,12 @@ const executeSubmit = async (status: string, mode: boolean) => { // 提交审批 form.value.tripStatus = '2'; // 审批中 form.value.flowStatus = 'waiting'; + // 将抄送人员ID数组转换为逗号分隔字符串 + const copyUserIdsStr = Array.isArray(form.value.copyUserIds) ? form.value.copyUserIds.join(',') : form.value.copyUserIds || ''; form.value.variables = { ...form.value.variables, - tripType: form.value.tripType + tripType: form.value.tripType, + businessTripCopyUsers: copyUserIdsStr }; form.value.bizExt = { businessTitle: '出差申请', diff --git a/src/views/oa/erp/afterSales/edit.vue b/src/views/oa/erp/afterSales/edit.vue index 9505de4..0a9a5d1 100644 --- a/src/views/oa/erp/afterSales/edit.vue +++ b/src/views/oa/erp/afterSales/edit.vue @@ -461,6 +461,9 @@ const editingIndex = ref(-1); // 材料表编辑索引 (-1 为新增) const checkedLabor = ref([]); // 人员表选中项 const checkedMaterial = ref([]); // 材料表选中项 +// 项目管理角色用户昵称列表(抄送对象) +const projectMgrUserNames = ['于洋']; + // 流程相关变量 const submitFormData = ref({ businessId: '', flowCode: '', variables: {}, bizExt: {} }); const taskVariables = ref>({}); @@ -929,10 +932,13 @@ const executeSubmit = async (status: string, mode: boolean) => { if (status !== 'draft') { // --- 提交审批 --- submitData.flowCode = FlowCodeEnum.AFTER_SALES_KEY; + // 根据昵称匹配项目管理角色用户作为抄送对象 + const copyUserIds = userList.value.filter((u: any) => projectMgrUserNames.includes(u.nickName)).map((u: any) => String(u.userId)); submitData.variables = { afterSalesId: submitData.afterSalesId, totalCost: submitData.totalCost || 0, - startUserId: useUserStore().userId + startUserId: useUserStore().userId, + afterSalesCopyUsers: copyUserIds.join(',') }; submitData.bizExt = { businessTitle: `售后申请:${submitData.afterSalesSubject}`,