From ea3680cb67ef4b7a38d0047fa8c78a791724fb0d Mon Sep 17 00:00:00 2001 From: Your Name Date: Fri, 16 Jan 2026 16:38:41 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E9=83=A8=E9=97=A8?= =?UTF-8?q?=E8=A7=86=E8=A7=92=E5=88=87=E6=8D=A2=E5=90=8ETab=E6=95=B0?= =?UTF-8?q?=E9=87=8F=E7=BB=9F=E8=AE=A1=E4=B8=8D=E6=AD=A3=E7=A1=AE=E7=9A=84?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit loadAllTabCounts中根据部门视角正确查询进行中任务数量 --- frontend/src/views/TaskHall.vue | 65 ++++++++++++++++++++++++++------- 1 file changed, 52 insertions(+), 13 deletions(-) diff --git a/frontend/src/views/TaskHall.vue b/frontend/src/views/TaskHall.vue index 2225fbc..4eb862a 100644 --- a/frontend/src/views/TaskHall.vue +++ b/frontend/src/views/TaskHall.vue @@ -5615,6 +5615,11 @@ const loadAllTabCounts = async () => { // 并行加载所有Tab的数量统计 const promises: Promise[] = [] + // 获取用户信息用于判断部门视角 + const userInfo = JSON.parse(localStorage.getItem('userInfo') || '{}') + const isDeptLeader = userInfo.isDepartmentLeader === 1 || managedDepartments.value.length > 0 + const currentDeptType = effectiveDeptType.value + // 1. 可接任务数量 promises.push( taskApi.getTaskHall({ page: 1, pageSize: 1 }).then(res => { @@ -5624,19 +5629,53 @@ const loadAllTabCounts = async () => { }).catch(() => {}) ) - // 2. 进行中任务数量 - promises.push( - taskApi.getTasks({ - status: 'in_progress', - role: 'receiver', - page: 1, - pageSize: 1 - }).then(res => { - if (res.data && res.data.total !== undefined) { - inProgressTotal.value = res.data.total - } - }).catch(() => {}) - ) + // 2. 进行中任务数量 - 🔥 根据部门视角正确查询 + if (isDeptLeader && currentDeptView.value !== undefined) { + // 部门负责人切换了视角 + if (currentDeptType === 'demand') { + // 需求部门视角:查询该部门发起的所有处理中任务 + promises.push( + taskApi.getTasks({ + publisherDeptId: currentDeptView.value, + excludeStatuses: 'draft,completed,cancelled', + page: 1, + pageSize: 1 + }).then(res => { + if (res.data && res.data.total !== undefined) { + inProgressTotal.value = res.data.total + } + }).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 + } + }).catch(() => {}) + ) + } + } else { + // 未切换视角或普通用户:使用默认查询 + promises.push( + taskApi.getTasks({ + status: 'in_progress', + role: 'receiver', + page: 1, + pageSize: 1 + }).then(res => { + if (res.data && res.data.total !== undefined) { + inProgressTotal.value = res.data.total + } + }).catch(() => {}) + ) + } // 3. 待审核任务数量(主任务 + 子任务组) if (isDepartmentLeader.value) {