fix: 优化文档16项问题修复

- 问题1/3: 绩效考核/培训记录员工姓名可点击跳转员工详情页
- 问题2: 离职证明模板支持自定义+员工端下载
- 问题4(P0): 修复工资填写后数据归零问题
- 问题5: 社保添加员工参保信息列表
- 问题6(P0): 商业保险支持为员工参保
- 问题7(P0): 员工福利支持为员工添加福利
- 问题8: 规章制度支持导入Word文档
- 问题9: 文本模板下载Word增加HTML格式
- 问题10: 模板下载变量替换修复(排除token参数)
- 问题11(P0): 电子签署发起时员工下拉框有选项
- 问题12: 新增绩效记录添加考评人选项
- 问题13: 违纪记录添加处罚执行细节
- 问题14: 特殊员工列表添加查看详情按钮和姓名链接
- 问题15: 员工福利汇总正确显示参保人员
- 问题16(P0): 证据链验证修复(递归排序key+自动修复历史哈希)
This commit is contained in:
freedakgmail
2026-08-11 21:24:43 +08:00
parent b682178549
commit 86e5526a83
27 changed files with 837 additions and 428 deletions
+67
View File
@@ -1511,4 +1511,71 @@ router.post('/ai-suggest', async (req: AuthRequest, res: Response, next: NextFun
}
})
// ========== 员工参保信息列表 ==========
router.get('/employee-enrollment', async (req: AuthRequest, res: Response, next: NextFunction) => {
try {
const orgId = req.user!.orgId
const keyword = (req.query.keyword as string) || ''
// 查询所有在职员工
const employees = await prisma.employee.findMany({
where: {
orgId,
status: 'ACTIVE',
...(keyword ? { name: { contains: keyword, mode: 'insensitive' } } : {}),
},
select: {
id: true,
name: true,
department: true,
position: true,
socialInsBase: true,
housingFundBase: true,
city: true,
},
orderBy: { department: 'asc' },
})
const empIds = employees.map(e => e.id)
// 查询当前有效的社保记录(endMonth 为 null
const socialRecords = await prisma.employeeSocialInsRecord.findMany({
where: { orgId, employeeId: { in: empIds }, endMonth: null },
select: { employeeId: true, city: true, base: true, startMonth: true, changeType: true },
})
// 查询当前有效的公积金记录
const housingRecords = await prisma.employeeHousingFundRecord.findMany({
where: { orgId, employeeId: { in: empIds }, endMonth: null },
select: { employeeId: true, city: true, base: true, startMonth: true, changeType: true },
})
const socialMap = new Map(socialRecords.map(r => [r.employeeId, r]))
const housingMap = new Map(housingRecords.map(r => [r.employeeId, r]))
const list = employees.map(emp => {
const social = socialMap.get(emp.id)
const housing = housingMap.get(emp.id)
return {
id: emp.id,
name: emp.name,
department: emp.department,
position: emp.position,
socialInsBase: social?.base ?? emp.socialInsBase ?? 0,
socialInsCity: social?.city ?? emp.city ?? '',
socialInsStart: social?.startMonth ?? '',
socialInsStatus: social ? 'INSURED' : 'UNINSURED',
housingFundBase: housing?.base ?? emp.housingFundBase ?? 0,
housingFundCity: housing?.city ?? emp.city ?? '',
housingFundStart: housing?.startMonth ?? '',
housingFundStatus: housing ? 'INSURED' : 'UNINSURED',
}
})
res.json({ success: true, data: list })
} catch (err) {
next(err)
}
})
export default router