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 || ''}
)}