From 4aa13d11c570c6ea962a7d7c858eac12b62e023c Mon Sep 17 00:00:00 2001 From: selfrelease Date: Sat, 1 Aug 2026 14:14:47 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E9=A3=8E=E9=99=A9=E4=B8=AD=E5=BF=83?= =?UTF-8?q?=E9=A1=B5=E9=9D=A2=E6=97=A0=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 后端缺少 /compliance/risks 路由,新增 /dashboard/risks 端点返回PENDING风险项 - 前端API调用从 /compliance/risks 改为 /dashboard/risks - RISK_TYPES 配置key从虚构子类型改为实际Prisma RiskType枚举值 - 风险列表字段映射修正: r.message→r.title, r.employeeName→r.employee.name --- backend/src/routes/dashboard.routes.ts | 14 ++++++++++++ frontend/src/pages/compliance/RiskCenter.tsx | 24 +++++++++++--------- 2 files changed, 27 insertions(+), 11 deletions(-) diff --git a/backend/src/routes/dashboard.routes.ts b/backend/src/routes/dashboard.routes.ts index e10c075..f6d9cd6 100644 --- a/backend/src/routes/dashboard.routes.ts +++ b/backend/src/routes/dashboard.routes.ts @@ -489,4 +489,18 @@ router.get('/performance-stats', authMiddleware, async (req: AuthRequest, res: R } }) +// 风险中心 — 获取所有待处理风险项 +router.get('/risks', authMiddleware, async (req: AuthRequest, res: Response, next: NextFunction) => { + try { + const risks = await prisma.riskItem.findMany({ + where: { orgId: req.user!.orgId, status: 'PENDING' }, + include: { employee: { select: { name: true, department: true } } }, + orderBy: [{ level: 'desc' }, { createdAt: 'desc' }], + }) + res.json({ success: true, data: risks }) + } catch (err) { + next(err) + } +}) + export default router diff --git a/frontend/src/pages/compliance/RiskCenter.tsx b/frontend/src/pages/compliance/RiskCenter.tsx index f8c67f4..6a7608a 100644 --- a/frontend/src/pages/compliance/RiskCenter.tsx +++ b/frontend/src/pages/compliance/RiskCenter.tsx @@ -23,13 +23,12 @@ const RISK_LEVELS: Record /** 风险类型配置 */ const RISK_TYPES: Record = { - CONTRACT_EXPIRE: { label: '合同到期', icon: FileText, link: '/roster' }, - CONTRACT_UNSIGNED: { label: '未签合同', icon: FileText, link: '/roster' }, - PROBATION_EXPIRE: { label: '试用期到期', icon: Clock, link: '/roster' }, - SALARY_BELOW_MIN: { label: '工资低于最低标准', icon: TrendingDown, link: '/money' }, - SOCIAL_INSURANCE_GAP: { label: '社保断缴', icon: ShieldAlert, link: '/social' }, - TERMINATION_RISK: { label: '离职风险', icon: Users, link: '/termination' }, - POLICY_UNREAD: { label: '制度未阅读', icon: FileText, link: '/policies' }, + CONTRACT: { label: '合同风险', icon: FileText, link: '/roster' }, + SALARY: { label: '薪酬风险', icon: TrendingDown, link: '/money' }, + TERMINATION: { label: '解聘风险', icon: Users, link: '/termination' }, + MONTHLY: { label: '月度任务', icon: Calendar, link: '/money' }, + ONBOARDING: { label: '入职手续', icon: Clock, link: '/roster' }, + RETIREMENT: { label: '退休提醒', icon: ShieldAlert, link: '/roster' }, } export default function RiskCenter() { @@ -40,7 +39,7 @@ export default function RiskCenter() { const { data: risks = [], isLoading } = useQuery({ queryKey: ['risk-center'], queryFn: async () => { - const res = await api.get('/compliance/risks') as any + const res = await api.get('/dashboard/risks') as any return res.data || [] }, }) @@ -187,10 +186,13 @@ export default function RiskCenter() { {levelCfg.label} {typeCfg.label} -
{r.message}
- {r.employeeName && ( +
{r.title}
+ {r.description && ( +
{r.description}
+ )} + {r.employee && (
- {r.employeeName} · {r.department || ''} + {r.employee.name} · {r.employee.department || ''}
)}