feat: 花名册操作自动创建电子签署流程
## 新增 esign.service.ts - autoCreateEsignRecord 公共方法,供其他业务模块调用 - 自动渲染模板文件内容 + 创建证据链 ## 自动触发签署 - 增加员工(创建合同时):自动创建劳动合同电子签署记录(scene=CONTRACT) - 主动离职(createDraft type=RESIGNATION):自动创建离职协议签署(scene=RESIGNATION) - 公司解聘(executeTermination type=TERMINATION):执行完成后自动创建离职协议签署 ## 前端提示 - 添加员工成功后提示"劳动合同电子签署已自动发起",可跳转签署页面 - 主动离职成功后提示"离职协议电子签署已自动发起" Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import prisma from '../lib/prisma'
|
||||
import { RiskAssessment, TerminationReason } from '@prisma/client'
|
||||
import { autoCreateEsignRecord } from './esign.service'
|
||||
|
||||
function dateToMonth(date: Date): string {
|
||||
const y = date.getFullYear()
|
||||
@@ -594,6 +595,18 @@ export async function createDraft(orgId: string, userId: string, data: any) {
|
||||
},
|
||||
})
|
||||
|
||||
// 主动离职时自动创建离职协议电子签署记录
|
||||
if (data.type === 'RESIGNATION') {
|
||||
await autoCreateEsignRecord({
|
||||
orgId,
|
||||
employeeId: data.employeeId,
|
||||
scene: 'RESIGNATION',
|
||||
documentTitle: `${employee.name}的离职协议`,
|
||||
remark: '员工主动离职时自动发起',
|
||||
createdBy: userId,
|
||||
})
|
||||
}
|
||||
|
||||
return { id: record.id }
|
||||
}
|
||||
|
||||
@@ -749,6 +762,19 @@ export async function executeTermination(orgId: string, recordId: string, userId
|
||||
})
|
||||
})
|
||||
|
||||
// 公司解聘执行完成后自动创建离职协议电子签署记录
|
||||
if (record.type === 'TERMINATION') {
|
||||
const employee = await prisma.employee.findFirst({ where: { id: record.employeeId }, select: { name: true } })
|
||||
await autoCreateEsignRecord({
|
||||
orgId,
|
||||
employeeId: record.employeeId,
|
||||
scene: 'RESIGNATION',
|
||||
documentTitle: `${employee?.name || '员工'}的解除劳动合同协议`,
|
||||
remark: '公司解聘执行完成时自动发起',
|
||||
createdBy: userId,
|
||||
})
|
||||
}
|
||||
|
||||
return { id: recordId }
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user