fix: 接单部门Tab计数与Dashboard统计保持一致(包含主任务+子任务)

This commit is contained in:
Your Name 2026-01-17 09:42:50 +08:00
parent c61b368233
commit 5221f7a799

View File

@ -5795,17 +5795,29 @@ const loadAllTabCounts = async () => {
}).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
Promise.all([
taskApi.getTasks({
receiverDeptId: currentDeptView.value,
status: 'in_progress',
page: 1,
pageSize: 1
}),
taskApi.getInProgressTaskItems({
deptId: currentDeptView.value,
page: 1,
pageSize: 1
})
]).then(([taskRes, itemRes]) => {
let count = 0
if (taskRes.data && taskRes.data.total !== undefined) {
count += taskRes.data.total
}
if (itemRes.data && itemRes.data.total !== undefined) {
count += itemRes.data.total
}
inProgressTotal.value = count
}).catch(() => {})
)
}
@ -5857,14 +5869,39 @@ const loadAllTabCounts = async () => {
)
}
// 4. 已完成任务数量
promises.push(
taskApi.getCompletedTasks({ page: 1, pageSize: 1 }).then(res => {
if (res.data && res.data.total !== undefined) {
completedTotal.value = res.data.total
}
}).catch(() => {})
)
// 4. 已完成任务数量 - 🔥 根据部门视角正确查询
if (isDeptLeader && currentDeptView.value !== undefined && currentDeptType === 'receiving') {
// 接单部门负责人视角:查询子任务
promises.push(
taskApi.getCompletedTaskItems({
deptId: currentDeptView.value,
page: 1,
pageSize: 1
}).then(res => {
if (res.data && res.data.total !== undefined) {
completedTotal.value = res.data.total
}
}).catch(() => {})
)
} else if (currentDeptType === 'receiving' && !isDeptLeader) {
// 接单部门普通用户:查询自己完成的子任务
promises.push(
taskApi.getCompletedTaskItems({ page: 1, pageSize: 1 }).then(res => {
if (res.data && res.data.total !== undefined) {
completedTotal.value = res.data.total
}
}).catch(() => {})
)
} else {
// 需求部门或管理员:查询主任务
promises.push(
taskApi.getCompletedTasks({ page: 1, pageSize: 1 }).then(res => {
if (res.data && res.data.total !== undefined) {
completedTotal.value = res.data.total
}
}).catch(() => {})
)
}
// 5. 我发起的任务数量
promises.push(