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:
@@ -171,6 +171,25 @@ router.post('/payslip/:id/confirm', portalAuth, async (req: any, res, next) => {
|
||||
events: [{ action: '工资条确认', timestamp: new Date().toISOString(), ip: req.ip, userAgent: req.headers['user-agent'] }],
|
||||
createdBy: req.employee.id,
|
||||
}).catch(() => {})
|
||||
|
||||
// 如果开启了工资条电子签,创建电子签记录
|
||||
const org = await prisma.organization.findUnique({ where: { id: req.employee.orgId }, select: { esignPayslipEnabled: true } })
|
||||
if (org?.esignPayslipEnabled) {
|
||||
await prisma.eSignRecord.create({
|
||||
data: {
|
||||
orgId: req.employee.orgId,
|
||||
employeeId: req.employee.id,
|
||||
scene: 'PAYSLIP',
|
||||
documentTitle: `工资条确认:${payslip.month}`,
|
||||
status: 'PENDING',
|
||||
initiatedBy: req.employee.id,
|
||||
createdBy: req.employee.id,
|
||||
remark: '工资条确认时自动发起',
|
||||
expiredAt: new Date(Date.now() + 30 * 24 * 60 * 60 * 1000),
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
res.json({ success: true })
|
||||
} catch (err) {
|
||||
next(err)
|
||||
@@ -544,6 +563,27 @@ router.post('/policies/:id/read', portalAuth, async (req: Request, res: Response
|
||||
userAgent: req.headers['user-agent'] || null,
|
||||
},
|
||||
})
|
||||
|
||||
// 如果开启了制度电子签,创建电子签记录
|
||||
const org = await prisma.organization.findUnique({ where: { id: orgId }, select: { esignPolicyEnabled: true } })
|
||||
if (org?.esignPolicyEnabled) {
|
||||
const policyDoc = await prisma.policyDocument.findUnique({ where: { id: req.params.id }, select: { title: true, content: true } })
|
||||
await prisma.eSignRecord.create({
|
||||
data: {
|
||||
orgId,
|
||||
employeeId,
|
||||
scene: 'POLICY',
|
||||
documentTitle: `制度签收:${policyDoc?.title || '未知'}`,
|
||||
documentContent: policyDoc?.content || null,
|
||||
status: 'PENDING',
|
||||
initiatedBy: employeeId,
|
||||
createdBy: employeeId,
|
||||
remark: '制度阅读确认后自动发起',
|
||||
expiredAt: new Date(Date.now() + 30 * 24 * 60 * 60 * 1000),
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
res.json({ success: true, data: { readAt: record.readAt.toISOString() } })
|
||||
} catch (err) {
|
||||
next(err)
|
||||
|
||||
Reference in New Issue
Block a user