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)