From d64f9c41a66b2343cf93e4df528fd6a2fa8f2d6b Mon Sep 17 00:00:00 2001 From: selfrelease Date: Sat, 1 Aug 2026 07:53:30 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E9=A6=96=E9=A1=B5?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E4=B8=8D=E4=B8=80=E8=87=B4=20=E2=80=94=201)?= =?UTF-8?q?=E9=A3=8E=E9=99=A9=E5=88=86=E5=B8=83=E7=94=A8=E5=8E=BB=E9=87=8D?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=202)=E6=97=A0=E5=B7=A5=E8=B5=84=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E6=97=B6=E4=B8=8D=E4=BC=B0=E7=AE=97=E7=A4=BE=E4=BF=9D?= =?UTF-8?q?=203)TaskCenter=E6=98=BE=E7=A4=BA=E5=85=A8=E9=83=A8=E5=BE=85?= =?UTF-8?q?=E5=8A=9E=E4=B8=8D=E5=86=8D=E6=88=AA=E5=8F=9610=E6=9D=A1=204)?= =?UTF-8?q?=E4=BF=AE=E5=A4=8DdedupedTodos=E5=BC=95=E7=94=A8=E9=A1=BA?= =?UTF-8?q?=E5=BA=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/src/routes/dashboard.routes.ts | 3 +-- backend/src/services/risk.service.ts | 17 +++++++++-------- frontend/src/pages/dashboard/TaskCenter.tsx | 4 ++-- 3 files changed, 12 insertions(+), 12 deletions(-) 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) => (