From 215f7c6bbf084b0bf6dbee1303a2539a3c21c3ad Mon Sep 17 00:00:00 2001 From: dj <1042039504@qq.com> Date: Mon, 9 Jun 2025 22:28:24 +0800 Subject: [PATCH] =?UTF-8?q?feat(expense-management):=20=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E7=A0=94=E5=8F=91=E5=B7=A5=E6=97=B6=E8=B6=85=E8=BF=8721.75?= =?UTF-8?q?=E5=A4=A9=E7=9A=84=E6=8F=90=E7=A4=BA=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 在保存分配明细时,增加对研发人员总工时的计算 - 如果总工时超过21.75天,系统将发出警告通知- 优化了控制台日志输出,便于调试和监控 --- .../expense-management/share-detail/add.vue | 42 ++++++++++++++++++- 1 file changed, 41 insertions(+), 1 deletion(-) diff --git a/src/views/expense-management/share-detail/add.vue b/src/views/expense-management/share-detail/add.vue index 3253efb..9e56200 100644 --- a/src/views/expense-management/share-detail/add.vue +++ b/src/views/expense-management/share-detail/add.vue @@ -386,7 +386,47 @@ const handleSubmit = (instance) => { apportionmentMonth: formData.value.apportionmentMonth, usrAllocations: formData.value.tableData, } - console.log('params', params, formData.value.tableData) + console.log('params', params.usrAllocations, formData.value.tableData) + const resultMap = params.usrAllocations.reduce((acc, item) => { + if (!acc[item.researchPersonnelId]) { + acc[item.researchPersonnelId] = []; + } + acc[item.researchPersonnelId].push(item); + return acc; + }, {}); + const exceedList = []; + + Object.entries(resultMap).forEach(([id, items]) => { + const totalDuration = items.reduce((sum, item) => sum + (item.researchDuration || 0), 0); + const preciseTotalDuration = parseFloat(totalDuration.toFixed(2)); + + if (preciseTotalDuration > 21.75) { + // 收集超出的研发人员ID及总工时 + exceedList.push({ id, totalDuration: preciseTotalDuration }); + } + }); +// 从 resultMap 中获取 researchPersonnel + const exceedResearchPersonnel = exceedList.map(item => { + const id = item.id; + const personnelItems = resultMap[id]; + // 获取第一个对象中的 researchPersonnel(假设所有对象的 researchPersonnel 相同) + const researchPersonnel = personnelItems[0].researchPersonnel; + return { id, researchPersonnel, totalDuration: item.totalDuration }; + }); + + console.log('超过21.75的研发人员:', exceedResearchPersonnel); + + if (exceedResearchPersonnel.length > 0) { + console.log('以下研发人员的总研发工时超过21.75天:', exceedResearchPersonnel); + + ElNotification({ + title: '提示', + message: `以下研发人员的总研发工时超过21.75天:${exceedResearchPersonnel.map(e => e.researchPersonnel).join(',')}`, + type: 'warning' + }); + } +// 调用函数 + console.log('是大V',resultMap) const {code, msg} = await addShare(params) ElNotification({ title: '提示',