diff --git a/backend/src/routes/dashboard.routes.ts b/backend/src/routes/dashboard.routes.ts index 5550a2b..6686a49 100644 --- a/backend/src/routes/dashboard.routes.ts +++ b/backend/src/routes/dashboard.routes.ts @@ -246,11 +246,10 @@ 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. 待办风险项 + // 1. 待办风险项(全部) const riskItems = await prisma.riskItem.findMany({ where: { orgId, status: 'PENDING' }, orderBy: { createdAt: 'desc' }, - take: 10, select: { id: true, title: true, type: true, level: true, deadline: true, actionUrl: true, employeeId: true }, }) diff --git a/backend/src/services/risk.service.ts b/backend/src/services/risk.service.ts index 0817e77..8400f5d 100644 --- a/backend/src/services/risk.service.ts +++ b/backend/src/services/risk.service.ts @@ -692,8 +692,8 @@ export async function getDashboardData(orgId: string) { socialEmpTotal = totalSocialEmp housingOrgTotal = totalHousingOrg housingEmpTotal = totalHousingEmp - } else if (socialConfig && employeeCount > 0) { - // 用平均工资作为估算基数 + } else if (socialConfig && employeeCount > 0 && payslips.length > 0) { + // 用平均工资作为估算基数(仅当有工资条数据时才估算) const avgBase = employeeCount > 0 ? Math.max(socialConfig.baseMin, Math.min(socialConfig.baseMax, totalBaseSalary / Math.max(employeeCount, 1))) : socialConfig.baseMin socialOrgTotal = avgBase * (socialConfig.pensionOrg + socialConfig.medicalOrg + socialConfig.unemploymentOrg + socialConfig.injuryOrg + socialConfig.maternityOrg) / 100 * employeeCount socialEmpTotal = avgBase * (socialConfig.pensionEmp + socialConfig.medicalEmp + socialConfig.unemploymentEmp) / 100 * employeeCount @@ -773,12 +773,6 @@ export async function getDashboardData(orgId: string) { orgTotalCost: yearTotalPay + yearSocialOrg + yearHousingOrg + yearOvertimePay + yearSeverance, } - const riskDistribution = { - contract: riskItems.filter((r: typeof riskItems[number]) => r.type === 'CONTRACT').length, - salary: riskItems.filter((r: typeof riskItems[number]) => r.type === 'SALARY').length, - termination: riskItems.filter((r: typeof riskItems[number]) => r.type === 'TERMINATION').length, - } - // 为所有风险项计算优先级和量化信息 const todosWithCost = riskItems.map((r: typeof riskItems[number]) => { const estimatedLoss = r.estimatedLoss || 0 @@ -832,6 +826,13 @@ export async function getDashboardData(orgId: string) { } const dedupedTodos = Array.from(dedupedTodoMap.values()) + // 风险分布:使用去重后的数据,与待办列表一致 + const riskDistribution = { + contract: dedupedTodos.filter((t) => t.type === 'CONTRACT').length, + salary: dedupedTodos.filter((t) => t.type === 'SALARY').length, + termination: dedupedTodos.filter((t) => t.type === 'TERMINATION').length, + } + // 按优先级排序:URGENT > HIGH > MEDIUM > LOW const priorityOrder = { URGENT: 0, HIGH: 1, MEDIUM: 2, LOW: 3 } todosWithCost.sort((a, b) => priorityOrder[a.priority] - priorityOrder[b.priority]) diff --git a/frontend/src/pages/dashboard/TaskCenter.tsx b/frontend/src/pages/dashboard/TaskCenter.tsx index 38c0123..86de684 100644 --- a/frontend/src/pages/dashboard/TaskCenter.tsx +++ b/frontend/src/pages/dashboard/TaskCenter.tsx @@ -102,8 +102,8 @@ export function TaskCenter() { ({group.items.length}) {/* 行动项列表 */} -
- {group.items.slice(0, 5).map((item) => ( +
+ {group.items.map((item) => (