fix: 顶部数据展板只有部门负责人切换视角时才显示部门数据,普通用户显示个人数据
This commit is contained in:
parent
313f647a86
commit
c74274e8b4
@ -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
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user