feat: 电子签全场景集成+场景筛选+设置开关

- ESignRecord 模型新增 scene 字段(CONTRACT/RESIGNATION/POLICY/PAYSLIP/ONBOARDING)
- Organization 模型新增3个电子签开关:esignPolicyEnabled/esignPayslipEnabled/esignOnboardingEnabled
- 设置页面企业信息新增电子签署设置区域,3个开关各自独立,缺省关闭
- 规章制度签收:开启电子签后,员工阅读确认时自动创建POLICY场景签署记录
- 工资条确认:开启电子签后,员工确认工资条时自动创建PAYSLIP场景签署记录
- 入职文件签署:开启电子签后,HR审批通过入职流程时自动创建ONBOARDING场景签署记录
- 电子签署列表增加场景筛选下拉(全部场景/劳动合同/离职协议/规章制度/工资条/入职文件)
- 管理端和员工端列表均展示场景标签(基于scene字段,替代硬编码判断)
- 合同和离职流程的esign调用已加scene参数
This commit is contained in:
freedakgmail
2026-08-05 07:47:00 +08:00
parent e8cd0f472b
commit 9512b555ee
11 changed files with 153 additions and 16 deletions
+21
View File
@@ -164,6 +164,27 @@ router.post('/:id/approve', authMiddleware, async (req: AuthRequest, res: Respon
...(execResult.employeeId && !process.employeeId && { employeeId: execResult.employeeId }),
},
})
// 入职审批通过且开启了入职文件电子签,创建电子签记录
if (execResult.employeeId && process.type === 'ONBOARDING') {
const orgSettings = await prisma.organization.findUnique({ where: { id: req.user!.orgId }, select: { esignOnboardingEnabled: true } })
if (orgSettings?.esignOnboardingEnabled) {
await prisma.eSignRecord.create({
data: {
orgId: req.user!.orgId,
employeeId: execResult.employeeId,
scene: 'ONBOARDING',
documentTitle: '入职文件签署',
status: 'PENDING',
initiatedBy: req.user!.id,
createdBy: req.user!.id,
remark: '入职审批通过后自动发起',
expiredAt: new Date(Date.now() + 30 * 24 * 60 * 60 * 1000),
},
})
}
}
res.json({ success: true, data: updated })
} catch (err) {
next(err)