From 1ae7e14ecf49a640f5e790e68ec353db97eb9011 Mon Sep 17 00:00:00 2001 From: Yangk Date: Fri, 12 Dec 2025 17:21:36 +0800 Subject: [PATCH] =?UTF-8?q?feat(erp/timesheet):=20=E6=96=B0=E5=A2=9E?= =?UTF-8?q?=E5=B7=A5=E6=97=B6=E5=A1=AB=E6=8A=A5=E7=AE=A1=E7=90=86=E6=A8=A1?= =?UTF-8?q?=E5=9D=97=E5=AE=A1=E6=89=B9=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/oa/erp/timesheetInfo/index.ts | 16 +++---- src/views/oa/erp/timesheetInfo/edit.vue | 58 ++++++++++++++++++++++--- 2 files changed, 59 insertions(+), 15 deletions(-) diff --git a/src/api/oa/erp/timesheetInfo/index.ts b/src/api/oa/erp/timesheetInfo/index.ts index dda1ac0..3f447b4 100644 --- a/src/api/oa/erp/timesheetInfo/index.ts +++ b/src/api/oa/erp/timesheetInfo/index.ts @@ -67,13 +67,13 @@ export const delTimesheetInfo = (timesheetId: string | number | Array { return request({ - url: '/oa/erp/timesheet/submitAndFlowStart', + url: '/oa/erp/timesheetInfo/submitAndFlowStart', method: 'post', data: data }); diff --git a/src/views/oa/erp/timesheetInfo/edit.vue b/src/views/oa/erp/timesheetInfo/edit.vue index 15f645c..b48b2e9 100644 --- a/src/views/oa/erp/timesheetInfo/edit.vue +++ b/src/views/oa/erp/timesheetInfo/edit.vue @@ -47,7 +47,7 @@ - + @@ -145,11 +145,19 @@ - + + + + + @@ -211,11 +219,19 @@ - + + + + + @@ -278,7 +294,7 @@ const data = reactive({ totalHours: 0, deptHours: 0, projectHours: 0, - timesheetStatus: '0', + // timesheetStatus: '0', flowStatus: 'draft', remark: undefined, // 子表 @@ -499,7 +515,7 @@ const getSummary = (param: any) => { if (column.property === 'hours') { const values = data.map((item: any) => Number(item[column.property])); const total = values.reduce((prev: any, curr: any) => (!Number.isNaN(curr) ? prev + curr : prev), 0); - sums[index] = total.toFixed(1) + ' H'; + sums[index] = total.toFixed(1); } }); return sums; @@ -516,12 +532,40 @@ const submitForm = (status: string) => { if (status !== 'draft') { // 提交审批 submitData.flowCode = FlowCodeEnum.TIMESHEET_KEY; + + // 提取部门工时审批人 (取 approverId) + const deptApproverSet = new Set(); + submitData.timesheetDeptList.forEach((item: any) => { + if (item.approverId) deptApproverSet.add(item.approverId); + }); + const deptApprovers = Array.from(deptApproverSet); + + // 提取项目工时审批人 (取 approverId) + const projectApproverSet = new Set(); + submitData.timesheetProjectList.forEach((item: any) => { + if (item.approverId) projectApproverSet.add(item.approverId); + }); + const projectApprovers = Array.from(projectApproverSet); + + // 必须选择审批人 + if (deptApprovers.length === 0 && projectApprovers.length === 0) { + proxy.$modal.msgError('请至少填写一项工时并指定审批人'); + buttonLoading.value = false; + return; + } + + // 放入流程变量 submitData.variables = { startUserId: userStore.userId, - totalHours: submitData.totalHours + totalHours: submitData.totalHours, + deptApprovers: deptApprovers, // 对应后端 variables.put("deptApprovers", ...) + projectApprovers: projectApprovers, // 对应后端 variables.put("projectApprovers", ...) + hasDeptWork: deptApprovers.length > 0, // 前端也可以传这个标记,双重保险 + hasProjectWork: projectApprovers.length > 0 // 前端也可以传这个标记 }; + submitData.bizExt = { - businessTitle: `工时填报:${userStore.nickname} (${submitData.startTime})`, + businessTitle: `工时填报:${userStore.nickname}`, businessCode: submitData.timesheetCode }; submitData.timesheetStatus = '2'; // 已提交