fix: 解聘保存后根据解聘日期判断在职/离职状态
- 解聘日期<=今天:员工状态设为RESIGNED(离职) - 解聘日期>今天:员工状态保持ACTIVE(在职,未到解聘日)
This commit is contained in:
@@ -157,9 +157,15 @@ export async function createTermination(orgId: string, userId: string, data: any
|
||||
},
|
||||
})
|
||||
|
||||
// 根据解聘日期判断在职/离职状态
|
||||
const termDate = new Date(data.terminationDate)
|
||||
const today = new Date()
|
||||
today.setHours(0, 0, 0, 0)
|
||||
const isResigned = termDate <= today
|
||||
|
||||
await prisma.employee.update({
|
||||
where: { id: data.employeeId },
|
||||
data: { status: 'RESIGNED' },
|
||||
data: { status: isResigned ? 'RESIGNED' : 'ACTIVE' },
|
||||
})
|
||||
|
||||
await prisma.riskItem.updateMany({
|
||||
|
||||
Reference in New Issue
Block a user