fix: 修复loadDashboardStats中userInfo未定义的问题

This commit is contained in:
Your Name 2026-01-15 17:59:40 +08:00
parent 96bf8aef68
commit b0f6da53f7

View File

@ -4278,9 +4278,12 @@ const loadDashboardStats = async () => {
const params: { month?: string; deptId?: number } = {}
if (month) params.month = month
// 从 localStorage 获取用户信息
const userInfo = JSON.parse(localStorage.getItem('userInfo') || '{}')
// 只有部门负责人切换了部门视角时才传递 deptId
// 普通用户不传 deptId,后端会根据 userId 查询个人数据
const isDeptLeader = userInfo.value?.isDepartmentLeader || false
const isDeptLeader = userInfo.isDepartmentLeader === 1 || userInfo.isDepartmentLeader === true || managedDepartments.value.length > 0
if (isDeptLeader && currentDeptView.value !== undefined) {
// 部门负责人且切换了部门视角
params.deptId = currentDeptView.value