fix: 修复部门视角切换后Tab数量统计不正确的问题

loadAllTabCounts中根据部门视角正确查询进行中任务数量
This commit is contained in:
Your Name 2026-01-16 16:38:41 +08:00
parent c2ee27ee69
commit ea3680cb67

View File

@ -5615,6 +5615,11 @@ const loadAllTabCounts = async () => {
// 并行加载所有Tab的数量统计
const promises: Promise<any>[] = []
// 获取用户信息用于判断部门视角
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) {