diff --git a/backend/src/routes/dashboard.routes.ts b/backend/src/routes/dashboard.routes.ts index 6686a49..e10c075 100644 --- a/backend/src/routes/dashboard.routes.ts +++ b/backend/src/routes/dashboard.routes.ts @@ -246,12 +246,9 @@ router.get('/workspace/next-actions', authMiddleware, async (req: AuthRequest, r const now = new Date() const in30Days = new Date(now.getTime() + 30 * 24 * 60 * 60 * 1000) - // 1. 待办风险项(全部) - const riskItems = await prisma.riskItem.findMany({ - where: { orgId, status: 'PENDING' }, - orderBy: { createdAt: 'desc' }, - select: { id: true, title: true, type: true, level: true, deadline: true, actionUrl: true, employeeId: true }, - }) + // 1. 待办风险项(使用 getDashboardData 的去重 todos,与概览一致) + const dashboardData = await getDashboardData(orgId) + const dedupedTodos = dashboardData.todos // 2. 草稿发薪批次 const draftBatches = await prisma.payrollBatch.findMany({ @@ -293,13 +290,13 @@ router.get('/workspace/next-actions', authMiddleware, async (req: AuthRequest, r { category: '待办事项', priority: 'high', - items: riskItems.map(r => ({ - id: r.id, - title: r.title, - type: r.type, - level: r.level, - dueDate: r.deadline?.toISOString().slice(0, 10), - link: r.actionUrl || '/', + items: dedupedTodos.map(t => ({ + id: t.id, + title: t.title, + type: t.type, + level: t.level, + dueDate: t.deadline, + link: t.actionUrl || '/', })), }, {