fix: 花名册合同风险统计与风险中心不一致
花名册快捷筛选标签基于当前页数据统计,改为后端返回全局RiskItem统计 - 后端roster API返回globalRiskStats(expiring/expired/unsigned) - 前端优先使用全局统计,fallback到当前页统计
This commit is contained in:
@@ -210,6 +210,13 @@ router.get('/', authMiddleware, async (req: AuthRequest, res, next) => {
|
||||
result = result.slice(skip, skip + pageSize)
|
||||
}
|
||||
|
||||
// 全局合同风险统计(基于 RiskItem,与风险中心同口径)
|
||||
const [globalExpiring, globalExpired, globalUnsigned] = await Promise.all([
|
||||
prisma.riskItem.count({ where: { orgId: req.user!.orgId, status: 'PENDING', type: 'CONTRACT', level: 'MEDIUM' } }),
|
||||
prisma.riskItem.count({ where: { orgId: req.user!.orgId, status: 'PENDING', type: 'CONTRACT', level: 'HIGH' } }),
|
||||
prisma.riskItem.count({ where: { orgId: req.user!.orgId, status: 'PENDING', type: 'ONBOARDING' } }),
|
||||
])
|
||||
|
||||
res.json({
|
||||
success: true,
|
||||
data: result,
|
||||
@@ -219,6 +226,11 @@ router.get('/', authMiddleware, async (req: AuthRequest, res, next) => {
|
||||
total: filteredTotal,
|
||||
totalPages: Math.ceil(filteredTotal / pageSize),
|
||||
},
|
||||
globalRiskStats: {
|
||||
expiring: globalExpiring,
|
||||
expired: globalExpired,
|
||||
unsigned: globalUnsigned,
|
||||
},
|
||||
})
|
||||
} catch (err) {
|
||||
next(err)
|
||||
|
||||
Reference in New Issue
Block a user