From 5221f7a799eab9d21eef3395e655945acf40f70e Mon Sep 17 00:00:00 2001 From: Your Name Date: Sat, 17 Jan 2026 09:42:50 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E6=8E=A5=E5=8D=95=E9=83=A8=E9=97=A8Tab?= =?UTF-8?q?=E8=AE=A1=E6=95=B0=E4=B8=8EDashboard=E7=BB=9F=E8=AE=A1=E4=BF=9D?= =?UTF-8?q?=E6=8C=81=E4=B8=80=E8=87=B4=EF=BC=88=E5=8C=85=E5=90=AB=E4=B8=BB?= =?UTF-8?q?=E4=BB=BB=E5=8A=A1+=E5=AD=90=E4=BB=BB=E5=8A=A1=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/src/views/TaskHall.vue | 71 +++++++++++++++++++++++++-------- 1 file changed, 54 insertions(+), 17 deletions(-) diff --git a/frontend/src/views/TaskHall.vue b/frontend/src/views/TaskHall.vue index 2418a5f..a2cce61 100644 --- a/frontend/src/views/TaskHall.vue +++ b/frontend/src/views/TaskHall.vue @@ -5795,17 +5795,29 @@ const loadAllTabCounts = async () => { }).catch(() => {}) ) } else { - // 接单部门视角:查询该部门接收的进行中任务 + // 接单部门视角:查询该部门接收的进行中任务(主任务+子任务) promises.push( - taskApi.getTasks({ - receiverDeptId: currentDeptView.value, - status: 'in_progress', - page: 1, - pageSize: 1 - }).then(res => { - if (res.data && res.data.total !== undefined) { - inProgressTotal.value = res.data.total + Promise.all([ + taskApi.getTasks({ + receiverDeptId: currentDeptView.value, + status: 'in_progress', + page: 1, + pageSize: 1 + }), + taskApi.getInProgressTaskItems({ + deptId: currentDeptView.value, + page: 1, + pageSize: 1 + }) + ]).then(([taskRes, itemRes]) => { + let count = 0 + if (taskRes.data && taskRes.data.total !== undefined) { + count += taskRes.data.total } + if (itemRes.data && itemRes.data.total !== undefined) { + count += itemRes.data.total + } + inProgressTotal.value = count }).catch(() => {}) ) } @@ -5857,14 +5869,39 @@ const loadAllTabCounts = async () => { ) } - // 4. 已完成任务数量 - promises.push( - taskApi.getCompletedTasks({ page: 1, pageSize: 1 }).then(res => { - if (res.data && res.data.total !== undefined) { - completedTotal.value = res.data.total - } - }).catch(() => {}) - ) + // 4. 已完成任务数量 - 🔥 根据部门视角正确查询 + if (isDeptLeader && currentDeptView.value !== undefined && currentDeptType === 'receiving') { + // 接单部门负责人视角:查询子任务 + promises.push( + taskApi.getCompletedTaskItems({ + deptId: currentDeptView.value, + page: 1, + pageSize: 1 + }).then(res => { + if (res.data && res.data.total !== undefined) { + completedTotal.value = res.data.total + } + }).catch(() => {}) + ) + } else if (currentDeptType === 'receiving' && !isDeptLeader) { + // 接单部门普通用户:查询自己完成的子任务 + promises.push( + taskApi.getCompletedTaskItems({ page: 1, pageSize: 1 }).then(res => { + if (res.data && res.data.total !== undefined) { + completedTotal.value = res.data.total + } + }).catch(() => {}) + ) + } else { + // 需求部门或管理员:查询主任务 + promises.push( + taskApi.getCompletedTasks({ page: 1, pageSize: 1 }).then(res => { + if (res.data && res.data.total !== undefined) { + completedTotal.value = res.data.total + } + }).catch(() => {}) + ) + } // 5. 我发起的任务数量 promises.push(