From 3b9fb6131280e46bd017be31eb524a9f1ee7e124 Mon Sep 17 00:00:00 2001 From: Your Name Date: Fri, 2 Jan 2026 18:42:00 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=BE=85=E5=AE=A1=E6=A0=B8?= =?UTF-8?q?=E4=BB=BB=E5=8A=A1=E5=AE=A1=E6=A0=B8API=E8=B0=83=E7=94=A8?= =?UTF-8?q?=E5=92=8CTab=E6=95=B0=E9=87=8F=E6=98=BE=E7=A4=BA=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1. 修复TaskHall.vue中handleApproveTask和handleRejectTask使用错误的API - 改为使用两级审核API:approveDemandLevel/approveReceivingLevel - 改为使用rejectByDemandLeader/rejectByReceivingLeader 2. 修复Tab标签数量显示为0的问题 - 新增loadAllTabCounts函数在页面初始化时加载所有Tab数量 - 在任务操作后刷新Tab数量统计 3. 优化通知图标类型映射 - 支持大小写不敏感的通知类型匹配 - 支持task_approval等下划线格式的通知类型 --- frontend/src/components/NotificationBell.vue | 34 +++++--- frontend/src/views/TaskHall.vue | 88 +++++++++++++++++--- 2 files changed, 101 insertions(+), 21 deletions(-) diff --git a/frontend/src/components/NotificationBell.vue b/frontend/src/components/NotificationBell.vue index 85ead6d..33a8cde 100644 --- a/frontend/src/components/NotificationBell.vue +++ b/frontend/src/components/NotificationBell.vue @@ -172,18 +172,30 @@ const handleMarkAllRead = async () => { // 获取图标名称 const getIconName = (notification: Notification) => { - switch (notification.notificationType) { - case 'system': - return 'info' - case 'task': - return 'document' - case 'score': - return 'trophy' - case 'review': - return 'star' - default: - return 'bell' + const type = (notification.notificationType || '').toLowerCase() + + // 匹配系统通知 + if (type === 'system') { + return 'info' } + + // 匹配任务相关通知(task, task_approval, task_review, task_completed, task_rejected等) + if (type.includes('task')) { + return 'document' + } + + // 匹配积分通知 + if (type.includes('score')) { + return 'trophy' + } + + // 匹配评审通知 + if (type === 'review' || type.includes('review')) { + return 'star' + } + + // 默认铃铛图标 + return 'bell' } // 格式化时间 diff --git a/frontend/src/views/TaskHall.vue b/frontend/src/views/TaskHall.vue index 0323993..ddea756 100644 --- a/frontend/src/views/TaskHall.vue +++ b/frontend/src/views/TaskHall.vue @@ -2317,8 +2317,10 @@ const handleApproveTwoLevelTask = async (task: Task) => { message.success('接单部门审核通过,任务已发布到大厅') } - // 刷新列表 + // 刷新列表和数量 loadPendingApprovalTasks() + loadAllTabCounts() + loadDashboardStats() } catch (error: any) { console.error('审核失败:', error) message.error(error.msg || error.message || '审核失败') @@ -2368,8 +2370,10 @@ const handleRejectTwoLevelTask = async (task: Task) => { message.success('已驳回,任务已退回给需求部门负责人') } - // 刷新列表 + // 刷新列表和数量 loadPendingApprovalTasks() + loadAllTabCounts() + loadDashboardStats() } catch (error: any) { console.error('驳回失败:', error) message.error(error.msg || error.message || '驳回失败') @@ -2712,6 +2716,7 @@ const handleUpdateProgress = (task: Task) => { await taskApi.updateTaskProgress(task.id, newProgress) message.success('进度更新成功') loadInProgressTasks() + loadAllTabCounts() loadDashboardStats() } catch (error: any) { message.error(error.message || '进度更新失败') @@ -2746,6 +2751,7 @@ const handleCompleteTask = (task: Task) => { await taskApi.completeTask(task.id, { deliveryPath }) message.success('任务已提交审核') loadInProgressTasks() + loadAllTabCounts() loadDashboardStats() } catch (error: any) { message.error(error.message || '任务完结失败') @@ -2754,25 +2760,40 @@ const handleCompleteTask = (task: Task) => { }) } -// 审核通过 +// 审核通过(使用两级审核流程) const handleApproveTask = (task: Task) => { Modal.confirm({ title: '审核通过', content: `确认通过任务审核:${task.title}?`, onOk: async () => { try { - await taskApi.approveTask(task.id) - message.success('审核通过') + const approvalData: TaskApprovalDTO = { + comment: '审核通过' + } + + // 根据当前审核角色调用不同的API + if (task.currentApproverRole === 'demand_leader') { + await taskApi.approveDemandLevel(task.id!, approvalData) + message.success('需求部门审核通过') + } else if (task.currentApproverRole === 'receiving_leader') { + await taskApi.approveReceivingLevel(task.id!, approvalData) + message.success('接单部门审核通过,任务已发布到大厅') + } else { + message.error('无法确定审核角色') + return + } + loadReviewTasks() + loadAllTabCounts() loadDashboardStats() } catch (error: any) { - message.error(error.message || '审核失败') + message.error(error.msg || error.message || '审核失败') } } }) } -// 驳回任务 +// 驳回任务(使用两级审核流程) const handleRejectTask = (task: Task) => { let reason = '' @@ -2795,12 +2816,23 @@ const handleRejectTask = (task: Task) => { } try { - await taskApi.rejectTask(task.id, { reason }) - message.success('任务已驳回') + // 根据当前审核角色调用不同的API + if (task.currentApproverRole === 'demand_leader') { + await taskApi.rejectByDemandLeader(task.id!, reason) + message.success('需求部门已驳回') + } else if (task.currentApproverRole === 'receiving_leader') { + await taskApi.rejectByReceivingLeader(task.id!, reason) + message.success('接单部门已驳回') + } else { + message.error('无法确定审核角色') + return Promise.reject() + } + loadReviewTasks() + loadAllTabCounts() loadDashboardStats() } catch (error: any) { - message.error(error.message || '驳回失败') + message.error(error.msg || error.message || '驳回失败') } } }) @@ -2867,9 +2899,45 @@ const getTaskStatusText = (status: string) => { return statusMap[status] || status } +// 加载所有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 + } + + // 加载待我审核任务数量(仅部门负责人) + if (isDepartmentLeader.value) { + const pendingApprovalRes = await taskApi.getPendingApprovalTasks() + if (pendingApprovalRes.code === 200) { + pendingApprovalTotal.value = (pendingApprovalRes.data || []).length + } + } + } catch (error) { + console.error('加载Tab数量统计失败:', error) + } +} + onMounted(() => { loadConfigs() loadDashboardStats() + loadAllTabCounts() // 加载所有Tab的数量统计 loadTasks() // 监听配置更新事件 window.addEventListener('configUpdated', handleConfigUpdate as EventListener)