diff --git a/frontend/src/views/TaskHall.vue b/frontend/src/views/TaskHall.vue index 991619a..a160dae 100644 --- a/frontend/src/views/TaskHall.vue +++ b/frontend/src/views/TaskHall.vue @@ -1115,6 +1115,8 @@ v-for="task in completedTaskList" :key="task.id" class="task-card chart-card completed" + @click="handleTaskClick(task)" + style="cursor: pointer;" >
@@ -3945,33 +3947,74 @@ const getTaskStatusText = (status: string, task?: any) => { // 加载所有Tab的数量统计 const loadAllTabCounts = async () => { try { - // 加载进行中任务数量 - const inProgressRes = await taskApi.getTasks({ - status: 'in_progress', - role: 'receiver', - page: 1, - pageSize: 1 - }) - if (inProgressRes.data && inProgressRes.data.total !== undefined) { - inProgressTotal.value = inProgressRes.data.total - } - - // 加载待审核任务数量 - const reviewRes = await taskApi.getAllPendingApprovalTasks({ - page: 1, - pageSize: 1 - }) - if (reviewRes.data && reviewRes.data.total !== undefined) { - reviewTotal.value = reviewRes.data.total - } - - // 加载待我审核任务数量(仅部门负责人) + // 并行加载所有Tab的数量统计 + const promises: Promise[] = [] + + // 1. 可接任务数量 + promises.push( + taskApi.getTaskHall({ page: 1, pageSize: 1 }).then(res => { + if (res.data && res.data.total !== undefined) { + total.value = res.data.total + } + }).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(() => {}) + ) + + // 3. 待审核任务数量(所有人可见) + promises.push( + taskApi.getAllPendingApprovalTasks({ + page: 1, + pageSize: 1 + }).then(res => { + if (res.data && res.data.total !== undefined) { + reviewTotal.value = res.data.total + } + }).catch(() => {}) + ) + + // 4. 已完成任务数量 + 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( + taskApi.getMyTasks({ role: 'publisher', page: 1, pageSize: 1 }).then(res => { + if (res.code === 200 && res.data && res.data.total !== undefined) { + publishedTotal.value = res.data.total + } + }).catch(() => {}) + ) + + // 6. 待我审核任务数量(仅部门负责人) if (isDepartmentLeader.value) { - const pendingApprovalRes = await taskApi.getPendingApprovalTasks() - if (pendingApprovalRes.code === 200) { - pendingApprovalTotal.value = (pendingApprovalRes.data || []).length - } + promises.push( + taskApi.getPendingApprovalTasks().then(res => { + if (res.code === 200) { + pendingApprovalTotal.value = (res.data || []).length + } + }).catch(() => {}) + ) } + + await Promise.all(promises) } catch (error) { console.error('加载Tab数量统计失败:', error) }