fix: 修复已撤销解聘记录(CANCELLED)在各模块中未正确过滤的问题

- 花名册API新增latestTerminationStatus字段,前端列表/操作按钮/离职日期列过滤CANCELLED/COMPLETED
- 证据链后端过滤CANCELLED状态的解聘记录,不再产生无效证据和风险提醒
- 重新入职判断增加status=COMPLETED条件,避免已撤销记录被误判为已离职
- 薪酬警告过滤CANCELLED状态,不再对已撤销记录触发结算提醒
- 风险扫描查询条件增加status=COMPLETED,避免已撤销记录导致员工被跳过
- 解聘向导canProceed和警告提示过滤CANCELLED/COMPLETED状态
- 档案解聘记录列表过滤CANCELLED状态,新增流程状态标签
- 重新生成Prisma Client以同步femaleWorkerType字段
This commit is contained in:
selfrelease
2026-07-25 20:10:42 +08:00
parent 41a2c665ed
commit 7ca2ada0d4
6 changed files with 20 additions and 12 deletions
+3 -2
View File
@@ -118,6 +118,7 @@ router.get('/', authMiddleware, async (req: AuthRequest, res, next) => {
latestTerminationDate: e.terminations[0]?.terminationDate || null,
latestTerminationType: e.terminations[0]?.type || null,
latestTerminationId: e.terminations[0]?.id || null,
latestTerminationStatus: e.terminations[0]?.status || null,
hireDate: e.hireDate,
gender: e.gender,
phone: e.phone,
@@ -389,8 +390,8 @@ router.get('/:id/evidence-chain', authMiddleware, async (req: AuthRequest, res,
})
})
// 7. 解聘证据
employee.terminations.forEach((t) => {
// 7. 解聘证据(排除已撤销的记录)
employee.terminations.filter((t) => t.status !== 'CANCELLED').forEach((t) => {
const reasonMap: Record<string, string> = { NEGOTIATED: '协商一致', FAULT: '员工过错', NONFAULT: '非过错解除', LAYOFF: '经济性裁员', EXPIRED: '合同到期', RESIGNATION: '员工主动离职' }
const typeLabel = t.type === 'RESIGNATION' && t.reason === 'NEGOTIATED'
? '协商一致离职'
+1 -1
View File
@@ -315,7 +315,7 @@ export async function rehireEmployee(orgId: string, userId: string, id: string,
const today = new Date()
today.setHours(0, 0, 0, 0)
const isResigned = employee.terminations.some((t) => t.terminationDate <= today)
const isResigned = employee.terminations.some((t) => t.status === 'COMPLETED' && t.terminationDate <= today)
if (!isResigned) {
throw { code: 'CONFLICT', message: '该员工当前在职,无需重新入职' }
}
+1 -1
View File
@@ -236,7 +236,7 @@ export async function getPayrollRiskWarnings(orgId: string, employeeId: string):
if (!employee.housingFundBase) {
warnings.push('未设置公积金缴费基数')
}
if (employee.terminations.length) {
if (employee.terminations.some((t) => t.status !== 'CANCELLED')) {
warnings.push('已有解聘记录,请注意结算')
}
+1 -1
View File
@@ -107,7 +107,7 @@ export async function detectOnboardingRisks(orgId: string) {
where: { orgId, status: 'ACTIVE', hireDate: { lte: today } },
include: {
contracts: { orderBy: { createdAt: 'desc' }, take: 1 },
terminations: { where: { terminationDate: { lte: today } }, take: 1 },
terminations: { where: { terminationDate: { lte: today }, status: 'COMPLETED' }, take: 1 },
},
})