diff --git a/frontend/src/views/TaskHall.vue b/frontend/src/views/TaskHall.vue index 78974c1..b68132e 100644 --- a/frontend/src/views/TaskHall.vue +++ b/frontend/src/views/TaskHall.vue @@ -3936,8 +3936,18 @@ const loadDashboardStats = async () => { const params: { month?: string; deptId?: number } = {} if (month) params.month = month // 获取有效的部门ID(切换的部门或用户自己的部门) - const effectiveDept = effectiveDeptId.value - console.log('loadDashboardStats - userDeptId:', userDeptId.value, 'currentDeptView:', currentDeptView.value, 'effectiveDept:', effectiveDept) + 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 */ } + } + } + console.log('loadDashboardStats - effectiveDept:', effectiveDept, 'userDeptId:', userDeptId.value, 'currentDeptView:', currentDeptView.value) if (effectiveDept) { params.deptId = effectiveDept }