From c74274e8b4e07cc5453c573377df7052215b6282 Mon Sep 17 00:00:00 2001 From: Your Name Date: Thu, 15 Jan 2026 17:22:39 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E9=A1=B6=E9=83=A8=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E5=B1=95=E6=9D=BF=E5=8F=AA=E6=9C=89=E9=83=A8=E9=97=A8=E8=B4=9F?= =?UTF-8?q?=E8=B4=A3=E4=BA=BA=E5=88=87=E6=8D=A2=E8=A7=86=E8=A7=92=E6=97=B6?= =?UTF-8?q?=E6=89=8D=E6=98=BE=E7=A4=BA=E9=83=A8=E9=97=A8=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=EF=BC=8C=E6=99=AE=E9=80=9A=E7=94=A8=E6=88=B7=E6=98=BE=E7=A4=BA?= =?UTF-8?q?=E4=B8=AA=E4=BA=BA=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/src/views/TaskHall.vue | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/frontend/src/views/TaskHall.vue b/frontend/src/views/TaskHall.vue index 3bcf70c..86edd12 100644 --- a/frontend/src/views/TaskHall.vue +++ b/frontend/src/views/TaskHall.vue @@ -4277,21 +4277,16 @@ const loadDashboardStats = async () => { const month = selectedMonth.value?.format('YYYY-MM') const params: { month?: string; deptId?: number } = {} if (month) params.month = month - // 获取有效的部门ID(切换的部门或用户自己的部门) - let effectiveDept = effectiveDeptId.value - // 如果 effectiveDeptId 为空,尝试从 localStorage 获取 - if (!effectiveDept) { - const userStr = localStorage.getItem('userInfo') - if (userStr) { - try { - const user = JSON.parse(userStr) - effectiveDept = user.deptId - } catch (e) { /* ignore */ } - } - } - if (effectiveDept) { - params.deptId = effectiveDept + + // 只有部门负责人切换了部门视角时才传递 deptId + // 普通用户不传 deptId,后端会根据 userId 查询个人数据 + const isDeptLeader = userInfo.value?.isDepartmentLeader || false + if (isDeptLeader && currentDeptView.value !== undefined) { + // 部门负责人且切换了部门视角 + params.deptId = currentDeptView.value } + // 注意:普通用户不传 deptId,这样后端会按用户个人统计数据 + const response = await taskApi.getDashboardStats(Object.keys(params).length > 0 ? params : undefined) if (response.code === 200) { const data = response.data