feat: 员工特殊状态台账(三期/工伤/医疗期)完整实现

This commit is contained in:
selfrelease
2026-07-30 15:04:34 +08:00
parent 5a5ce7186b
commit 826c8fda65
11 changed files with 1275 additions and 6 deletions
@@ -0,0 +1,45 @@
-- 员工特殊状态台账表(三期/工伤/医疗期等)
CREATE TABLE IF NOT EXISTS "EmployeeSpecialStatus" (
"id" TEXT NOT NULL,
"orgId" TEXT NOT NULL,
"employeeId" TEXT NOT NULL,
"type" TEXT NOT NULL,
"status" TEXT NOT NULL DEFAULT 'ACTIVE',
"startDate" TIMESTAMP(3),
"endDate" TIMESTAMP(3),
"actualEndDate" TIMESTAMP(3),
"expectedDueDate" TIMESTAMP(3),
"maternityLeaveStart" TIMESTAMP(3),
"maternityLeaveEnd" TIMESTAMP(3),
"nursingEndDate" TIMESTAMP(3),
"injuryDate" TIMESTAMP(3),
"injuryDescription" TEXT,
"certificationDate" TIMESTAMP(3),
"certificationNo" TEXT,
"disabilityLevel" INTEGER,
"assessmentDate" TIMESTAMP(3),
"medicalMonths" INTEGER,
"medicalPeriodEnd" TIMESTAMP(3),
"description" TEXT,
"attachments" JSONB,
"timeline" JSONB,
"reminderDate" TIMESTAMP(3),
"createdBy" TEXT NOT NULL,
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updatedAt" TIMESTAMP(3) NOT NULL,
CONSTRAINT "EmployeeSpecialStatus_pkey" PRIMARY KEY ("id")
);
CREATE INDEX IF NOT EXISTS "EmployeeSpecialStatus_orgId_status_idx" ON "EmployeeSpecialStatus"("orgId", "status");
CREATE INDEX IF NOT EXISTS "EmployeeSpecialStatus_orgId_type_idx" ON "EmployeeSpecialStatus"("orgId", "type");
CREATE INDEX IF NOT EXISTS "EmployeeSpecialStatus_employeeId_idx" ON "EmployeeSpecialStatus"("employeeId");
-- 外键约束
ALTER TABLE "EmployeeSpecialStatus"
ADD CONSTRAINT "EmployeeSpecialStatus_orgId_fkey"
FOREIGN KEY ("orgId") REFERENCES "Organization"("id") ON DELETE CASCADE;
ALTER TABLE "EmployeeSpecialStatus"
ADD CONSTRAINT "EmployeeSpecialStatus_employeeId_fkey"
FOREIGN KEY ("employeeId") REFERENCES "Employee"("id") ON DELETE CASCADE;
+48
View File
@@ -256,6 +256,7 @@ model Employee {
leaveRecords LeaveRecord[]
calendarEvents CalendarEvent[]
workProcesses WorkProcess[]
specialStatuses EmployeeSpecialStatus[]
@@unique([orgId, idCardHash])
}
@@ -1235,3 +1236,50 @@ model AttendancePublish {
@@unique([orgId, month])
@@index([orgId, month])
}
// ========== 员工特殊状态台账(三期/工伤/医疗期等) ==========
model EmployeeSpecialStatus {
id String @id @default(cuid())
orgId String
org Organization @relation(fields: [orgId], references: [id], onDelete: Cascade)
employeeId String
employee Employee @relation(fields: [employeeId], references: [id], onDelete: Cascade)
type String // PREGNANCY(三期) | WORK_INJURY(工伤) | MEDICAL_PERIOD(医疗期) | OTHER
status String @default("ACTIVE") // ACTIVE(进行中) | RESOLVED(已结束) | PENDING(待处理)
// 通用时间节点
startDate DateTime? // 开始日期
endDate DateTime? // 预计结束日期
actualEndDate DateTime? // 实际结束日期
// 三期专用
expectedDueDate DateTime? // 预产期
maternityLeaveStart DateTime? // 产假开始
maternityLeaveEnd DateTime? // 产假结束
nursingEndDate DateTime? // 哺乳期截止
// 工伤专用
injuryDate DateTime? // 受伤日期
injuryDescription String? // 伤情描述
certificationDate DateTime? // 工伤认定日期
certificationNo String? // 认定书编号
disabilityLevel Int? // 伤残等级(1-10级)
assessmentDate DateTime? // 鉴定日期
// 医疗期专用
medicalMonths Int? // 医疗期月数
medicalPeriodEnd DateTime? // 医疗期截止日
// 通用
description String? // 备注
attachments Json? // 附件列表 [{name, url}]
timeline Json? // 操作时间线 [{time, action, by}]
reminderDate DateTime? // 提醒日期
createdBy String
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
@@index([orgId, status])
@@index([orgId, type])
@@index([employeeId])
}