feat: 商业保险/员工福利独立页面+易签宝电子签署框架
- 商业保险:从社公商保中拆出为独立页面,侧边栏新增「福利保障」分组 - 员工福利:新建完整模块(方案管理+批量参保+员工汇总),Prisma模型+后端路由+前端页面 - 电子签署:搭建易签宝对接框架(ESignRecord模型+创建/查询/取消/回调接口+前端签署管理页面) - 侧边栏新增「福利保障」分组:商业保险、员工福利、电子签署 - Prisma schema 新增6个模型:CommercialInsurancePlan/Enrollment, EmployeeBenefitPlan/Enrollment, ESignRecord
This commit is contained in:
@@ -183,6 +183,11 @@ model Organization {
|
||||
attendancePublishes AttendancePublish[]
|
||||
specialStatuses EmployeeSpecialStatus[]
|
||||
companyFiles CompanyFile[]
|
||||
commercialInsPlans CommercialInsurancePlan[]
|
||||
commercialInsEnrollments CommercialInsuranceEnrollment[]
|
||||
benefitPlans EmployeeBenefitPlan[]
|
||||
benefitEnrollments EmployeeBenefitEnrollment[]
|
||||
eSignRecords ESignRecord[]
|
||||
}
|
||||
|
||||
model User {
|
||||
@@ -268,6 +273,9 @@ model Employee {
|
||||
calendarEvents CalendarEvent[]
|
||||
workProcesses WorkProcess[]
|
||||
specialStatuses EmployeeSpecialStatus[]
|
||||
commercialInsEnrollments CommercialInsuranceEnrollment[]
|
||||
benefitEnrollments EmployeeBenefitEnrollment[]
|
||||
eSignRecords ESignRecord[]
|
||||
|
||||
@@unique([orgId, idCardHash])
|
||||
}
|
||||
@@ -1365,3 +1373,114 @@ model AcceptanceTest {
|
||||
@@unique([orgId, verifierName])
|
||||
@@index([orgId, status])
|
||||
}
|
||||
|
||||
// ========== 商业保险 ==========
|
||||
model CommercialInsurancePlan {
|
||||
id String @id @default(cuid())
|
||||
orgId String
|
||||
org Organization @relation(fields: [orgId], references: [id], onDelete: Cascade)
|
||||
name String
|
||||
type String // ACCIDENT | SUPPLEMENTARY_MEDICAL | EMPLOYER_LIABILITY | CRITICAL_ILLNESS | GROUP_LIFE | OTHER
|
||||
provider String // 保险公司
|
||||
policyNo String?
|
||||
premium Float // 年保费
|
||||
coverageAmount Float // 保额
|
||||
effectiveFrom String // YYYY-MM-DD
|
||||
effectiveTo String? // null = 长期
|
||||
description String?
|
||||
status String @default("ACTIVE") // ACTIVE | EXPIRED | CANCELLED
|
||||
enrollments CommercialInsuranceEnrollment[]
|
||||
createdBy String
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
|
||||
@@index([orgId, status])
|
||||
@@index([orgId, type])
|
||||
}
|
||||
|
||||
model CommercialInsuranceEnrollment {
|
||||
id String @id @default(cuid())
|
||||
orgId String
|
||||
org Organization @relation(fields: [orgId], references: [id], onDelete: Cascade)
|
||||
planId String
|
||||
plan CommercialInsurancePlan @relation(fields: [planId], references: [id], onDelete: Cascade)
|
||||
employeeId String
|
||||
employee Employee @relation(fields: [employeeId], references: [id], onDelete: Cascade)
|
||||
premium Float // 个人保费
|
||||
effectiveFrom String // YYYY-MM-DD
|
||||
effectiveTo String?
|
||||
status String @default("ACTIVE") // ACTIVE | TERMINATED
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
|
||||
@@index([orgId, planId])
|
||||
@@index([employeeId])
|
||||
}
|
||||
|
||||
// ========== 员工福利 ==========
|
||||
model EmployeeBenefitPlan {
|
||||
id String @id @default(cuid())
|
||||
orgId String
|
||||
org Organization @relation(fields: [orgId], references: [id], onDelete: Cascade)
|
||||
name String
|
||||
category String // TRANSPORT | MEAL | HOUSING | COMMUNICATION | HEALTH_CHECK | HOLIDAY | BIRTHDAY | OTHER
|
||||
amount Float // 每月金额(或每次金额)
|
||||
frequency String @default("MONTHLY") // MONTHLY | QUARTERLY | YEARLY | ONE_TIME
|
||||
taxDeductible Boolean @default(false) // 是否税前扣除
|
||||
description String?
|
||||
status String @default("ACTIVE")
|
||||
enrollments EmployeeBenefitEnrollment[]
|
||||
createdBy String
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
|
||||
@@index([orgId, status])
|
||||
@@index([orgId, category])
|
||||
}
|
||||
|
||||
model EmployeeBenefitEnrollment {
|
||||
id String @id @default(cuid())
|
||||
orgId String
|
||||
org Organization @relation(fields: [orgId], references: [id], onDelete: Cascade)
|
||||
planId String
|
||||
plan EmployeeBenefitPlan @relation(fields: [planId], references: [id], onDelete: Cascade)
|
||||
employeeId String
|
||||
employee Employee @relation(fields: [employeeId], references: [id], onDelete: Cascade)
|
||||
effectiveFrom String // YYYY-MM
|
||||
effectiveTo String? // null = 至今
|
||||
amount Float? // 覆盖默认金额(个别调整)
|
||||
status String @default("ACTIVE")
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
|
||||
@@index([orgId, planId])
|
||||
@@index([employeeId])
|
||||
}
|
||||
|
||||
// ========== 电子签署(易签宝) ==========
|
||||
model ESignRecord {
|
||||
id String @id @default(cuid())
|
||||
orgId String
|
||||
org Organization @relation(fields: [orgId], references: [id], onDelete: Cascade)
|
||||
contractId String? // 关联 LaborContract
|
||||
employeeId String
|
||||
employee Employee @relation(fields: [employeeId], references: [id], onDelete: Cascade)
|
||||
flowId String? // 易签宝流程ID
|
||||
documentTitle String // 文件标题
|
||||
documentContent String? // 文件内容(HTML/PDF base64)
|
||||
status String @default("PENDING") // PENDING | SIGNING | COMPLETED | REJECTED | EXPIRED | CANCELLED
|
||||
signUrl String? // 签署链接
|
||||
signedPdfUrl String? // 签署完成后的PDF链接
|
||||
initiatedBy String // 发起人(HR用户ID)
|
||||
completedAt DateTime?
|
||||
expiredAt DateTime?
|
||||
callbackData Json? // 易签宝回调数据
|
||||
remark String?
|
||||
createdBy String
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
|
||||
@@index([orgId, status])
|
||||
@@index([employeeId])
|
||||
@@index([contractId])
|
||||
}
|
||||
|
||||
@@ -66,6 +66,9 @@ import companyFileRoutes from './routes/company-file.routes'
|
||||
import acceptanceTestRoutes from './routes/acceptance-test.routes'
|
||||
import leaveRoutes from './routes/leave.routes'
|
||||
import salaryRoutes from './routes/salary.routes'
|
||||
import commercialInsuranceRoutes from './routes/commercial-insurance.routes'
|
||||
import benefitRoutes from './routes/benefit.routes'
|
||||
import esignRoutes from './routes/esign.routes'
|
||||
app.use('/api/v1/auth', authRoutes)
|
||||
app.use('/api/v1/dashboard', dashboardRoutes)
|
||||
app.use('/api/v1/employees', employeeRoutes)
|
||||
@@ -95,6 +98,9 @@ app.use('/api/v1/company-files', companyFileRoutes)
|
||||
app.use('/api/v1/acceptance-tests', acceptanceTestRoutes)
|
||||
app.use('/api/v1/leaves', leaveRoutes)
|
||||
app.use('/api/v1/salary', salaryRoutes)
|
||||
app.use('/api/v1/commercial-insurance', commercialInsuranceRoutes)
|
||||
app.use('/api/v1/benefits', benefitRoutes)
|
||||
app.use('/api/v1/esign', esignRoutes)
|
||||
|
||||
app.use(errorHandler)
|
||||
|
||||
|
||||
@@ -0,0 +1,173 @@
|
||||
import { Router, Response, NextFunction } from 'express'
|
||||
import { z } from 'zod'
|
||||
import prisma from '../lib/prisma'
|
||||
import { authMiddleware, AuthRequest } from '../middleware/auth'
|
||||
|
||||
const router = Router()
|
||||
router.use(authMiddleware)
|
||||
|
||||
const planSchema = z.object({
|
||||
name: z.string().min(1),
|
||||
category: z.string(),
|
||||
amount: z.number().default(0),
|
||||
frequency: z.string().default('MONTHLY'),
|
||||
taxDeductible: z.boolean().default(false),
|
||||
description: z.string().optional(),
|
||||
})
|
||||
|
||||
const BENEFIT_CATEGORIES: Record<string, string> = {
|
||||
TRANSPORT: '交通补贴',
|
||||
MEAL: '餐补',
|
||||
HOUSING: '住房补贴',
|
||||
COMMUNICATION: '通讯补贴',
|
||||
HEALTH_CHECK: '体检',
|
||||
HOLIDAY: '节日福利',
|
||||
BIRTHDAY: '生日福利',
|
||||
OTHER: '其他',
|
||||
}
|
||||
|
||||
// 福利方案列表
|
||||
router.get('/plans', async (req: AuthRequest, res: Response, next: NextFunction) => {
|
||||
try {
|
||||
const plans = await prisma.employeeBenefitPlan.findMany({
|
||||
where: { orgId: req.user!.orgId },
|
||||
orderBy: { createdAt: 'desc' },
|
||||
include: { _count: { select: { enrollments: { where: { status: 'ACTIVE' } } } } },
|
||||
})
|
||||
res.json({ success: true, data: plans })
|
||||
} catch (err) { next(err) }
|
||||
})
|
||||
|
||||
// 创建福利方案
|
||||
router.post('/plans', async (req: AuthRequest, res: Response, next: NextFunction) => {
|
||||
try {
|
||||
const data = planSchema.parse(req.body)
|
||||
const plan = await prisma.employeeBenefitPlan.create({
|
||||
data: { ...data, orgId: req.user!.orgId, createdBy: req.user!.id },
|
||||
})
|
||||
res.json({ success: true, data: plan })
|
||||
} catch (err) { next(err) }
|
||||
})
|
||||
|
||||
// 更新福利方案
|
||||
router.put('/plans/:planId', async (req: AuthRequest, res: Response, next: NextFunction) => {
|
||||
try {
|
||||
const data = planSchema.partial().parse(req.body)
|
||||
const plan = await prisma.employeeBenefitPlan.update({
|
||||
where: { id: req.params.planId, orgId: req.user!.orgId },
|
||||
data,
|
||||
})
|
||||
res.json({ success: true, data: plan })
|
||||
} catch (err) { next(err) }
|
||||
})
|
||||
|
||||
// 删除福利方案
|
||||
router.delete('/plans/:planId', async (req: AuthRequest, res: Response, next: NextFunction) => {
|
||||
try {
|
||||
await prisma.employeeBenefitPlan.delete({
|
||||
where: { id: req.params.planId, orgId: req.user!.orgId },
|
||||
})
|
||||
res.json({ success: true })
|
||||
} catch (err) { next(err) }
|
||||
})
|
||||
|
||||
// 方案参保人员
|
||||
router.get('/plans/:planId/enrollments', async (req: AuthRequest, res: Response, next: NextFunction) => {
|
||||
try {
|
||||
const enrollments = await prisma.employeeBenefitEnrollment.findMany({
|
||||
where: { orgId: req.user!.orgId, planId: req.params.planId },
|
||||
include: { employee: { select: { id: true, name: true, department: true } } },
|
||||
orderBy: { createdAt: 'desc' },
|
||||
})
|
||||
const data = enrollments.map((e: any) => ({
|
||||
id: e.id,
|
||||
employeeId: e.employeeId,
|
||||
name: e.employee.name,
|
||||
department: e.employee.department,
|
||||
effectiveFrom: e.effectiveFrom,
|
||||
effectiveTo: e.effectiveTo,
|
||||
amount: e.amount,
|
||||
status: e.status,
|
||||
}))
|
||||
res.json({ success: true, data })
|
||||
} catch (err) { next(err) }
|
||||
})
|
||||
|
||||
// 批量参保
|
||||
router.post('/plans/:planId/enroll', async (req: AuthRequest, res: Response, next: NextFunction) => {
|
||||
try {
|
||||
const { employeeIds, effectiveFrom } = req.body as { employeeIds: string[]; effectiveFrom: string }
|
||||
const plan = await prisma.employeeBenefitPlan.findFirst({ where: { id: req.params.planId, orgId: req.user!.orgId } })
|
||||
if (!plan) return res.status(404).json({ success: false, error: { message: '方案不存在' } })
|
||||
|
||||
const existing = await prisma.employeeBenefitEnrollment.findMany({
|
||||
where: { planId: plan.id, employeeId: { in: employeeIds }, status: 'ACTIVE' },
|
||||
select: { employeeId: true },
|
||||
})
|
||||
const existingIds = new Set(existing.map((e: any) => e.employeeId))
|
||||
const newIds = employeeIds.filter((id) => !existingIds.has(id))
|
||||
|
||||
if (newIds.length > 0) {
|
||||
await prisma.employeeBenefitEnrollment.createMany({
|
||||
data: newIds.map((empId) => ({
|
||||
orgId: req.user!.orgId,
|
||||
planId: plan.id,
|
||||
employeeId: empId,
|
||||
effectiveFrom: effectiveFrom || new Date().toISOString().slice(0, 7),
|
||||
})),
|
||||
})
|
||||
}
|
||||
res.json({ success: true, data: { enrolled: newIds.length, skipped: existingIds.size } })
|
||||
} catch (err) { next(err) }
|
||||
})
|
||||
|
||||
// 退福利
|
||||
router.post('/enrollments/:enrollmentId/terminate', async (req: AuthRequest, res: Response, next: NextFunction) => {
|
||||
try {
|
||||
const { effectiveTo } = req.body as { effectiveTo: string }
|
||||
const enrollment = await prisma.employeeBenefitEnrollment.update({
|
||||
where: { id: req.params.enrollmentId, orgId: req.user!.orgId },
|
||||
data: { status: 'TERMINATED', effectiveTo: effectiveTo || new Date().toISOString().slice(0, 7) },
|
||||
})
|
||||
res.json({ success: true, data: enrollment })
|
||||
} catch (err) { next(err) }
|
||||
})
|
||||
|
||||
// 员工福利汇总(按员工维度)
|
||||
router.get('/employee-summary', async (req: AuthRequest, res: Response, next: NextFunction) => {
|
||||
try {
|
||||
const enrollments = await prisma.employeeBenefitEnrollment.findMany({
|
||||
where: { orgId: req.user!.orgId, status: 'ACTIVE' },
|
||||
include: {
|
||||
employee: { select: { id: true, name: true, department: true } },
|
||||
plan: { select: { id: true, name: true, category: true, amount: true } },
|
||||
},
|
||||
})
|
||||
const summary: Record<string, any> = {}
|
||||
for (const e of enrollments) {
|
||||
if (!summary[e.employeeId]) {
|
||||
summary[e.employeeId] = {
|
||||
employeeId: e.employeeId,
|
||||
name: e.employee.name,
|
||||
department: e.employee.department,
|
||||
benefits: [],
|
||||
totalMonthly: 0,
|
||||
}
|
||||
}
|
||||
const amount = e.amount ?? e.plan.amount
|
||||
summary[e.employeeId].benefits.push({
|
||||
planId: e.planId,
|
||||
planName: e.plan.name,
|
||||
category: e.plan.category,
|
||||
categoryLabel: BENEFIT_CATEGORIES[e.plan.category] || e.plan.category,
|
||||
amount,
|
||||
})
|
||||
if (e.plan.frequency === 'MONTHLY') {
|
||||
summary[e.employeeId].totalMonthly += amount
|
||||
}
|
||||
}
|
||||
res.json({ success: true, data: Object.values(summary) })
|
||||
} catch (err) { next(err) }
|
||||
})
|
||||
|
||||
export default router
|
||||
@@ -0,0 +1,132 @@
|
||||
import { Router, Response, NextFunction } from 'express'
|
||||
import { z } from 'zod'
|
||||
import prisma from '../lib/prisma'
|
||||
import { authMiddleware, AuthRequest } from '../middleware/auth'
|
||||
|
||||
const router = Router()
|
||||
router.use(authMiddleware)
|
||||
|
||||
const planSchema = z.object({
|
||||
name: z.string().min(1),
|
||||
type: z.string(),
|
||||
provider: z.string().min(1),
|
||||
policyNo: z.string().optional(),
|
||||
premium: z.number().default(0),
|
||||
coverageAmount: z.number().default(0),
|
||||
effectiveFrom: z.string(),
|
||||
effectiveTo: z.string().optional(),
|
||||
description: z.string().optional(),
|
||||
})
|
||||
|
||||
// 方案列表
|
||||
router.get('/plans', async (req: AuthRequest, res: Response, next: NextFunction) => {
|
||||
try {
|
||||
const plans = await prisma.commercialInsurancePlan.findMany({
|
||||
where: { orgId: req.user!.orgId },
|
||||
orderBy: { createdAt: 'desc' },
|
||||
include: { _count: { select: { enrollments: { where: { status: 'ACTIVE' } } } } },
|
||||
})
|
||||
res.json({ success: true, data: plans })
|
||||
} catch (err) { next(err) }
|
||||
})
|
||||
|
||||
// 方案详情(含参保人员)
|
||||
router.get('/plans/:planId/enrollments', async (req: AuthRequest, res: Response, next: NextFunction) => {
|
||||
try {
|
||||
const enrollments = await prisma.commercialInsuranceEnrollment.findMany({
|
||||
where: { orgId: req.user!.orgId, planId: req.params.planId },
|
||||
include: {
|
||||
employee: { select: { id: true, name: true, department: true, idCardNumber: true } },
|
||||
},
|
||||
orderBy: { createdAt: 'desc' },
|
||||
})
|
||||
const data = enrollments.map((e: any) => ({
|
||||
id: e.id,
|
||||
employeeId: e.employeeId,
|
||||
name: e.employee.name,
|
||||
department: e.employee.department,
|
||||
idCardMasked: e.employee.idCardNumber ? e.employee.idCardNumber.slice(0, 3) + '****' + e.employee.idCardNumber.slice(-4) : null,
|
||||
premium: e.premium,
|
||||
effectiveFrom: e.effectiveFrom,
|
||||
effectiveTo: e.effectiveTo,
|
||||
status: e.status,
|
||||
}))
|
||||
res.json({ success: true, data })
|
||||
} catch (err) { next(err) }
|
||||
})
|
||||
|
||||
// 创建方案
|
||||
router.post('/plans', async (req: AuthRequest, res: Response, next: NextFunction) => {
|
||||
try {
|
||||
const data = planSchema.parse(req.body)
|
||||
const plan = await prisma.commercialInsurancePlan.create({
|
||||
data: { ...data, orgId: req.user!.orgId, createdBy: req.user!.id },
|
||||
})
|
||||
res.json({ success: true, data: plan })
|
||||
} catch (err) { next(err) }
|
||||
})
|
||||
|
||||
// 更新方案
|
||||
router.put('/plans/:planId', async (req: AuthRequest, res: Response, next: NextFunction) => {
|
||||
try {
|
||||
const data = planSchema.partial().parse(req.body)
|
||||
const plan = await prisma.commercialInsurancePlan.update({
|
||||
where: { id: req.params.planId, orgId: req.user!.orgId },
|
||||
data,
|
||||
})
|
||||
res.json({ success: true, data: plan })
|
||||
} catch (err) { next(err) }
|
||||
})
|
||||
|
||||
// 删除方案
|
||||
router.delete('/plans/:planId', async (req: AuthRequest, res: Response, next: NextFunction) => {
|
||||
try {
|
||||
await prisma.commercialInsurancePlan.delete({
|
||||
where: { id: req.params.planId, orgId: req.user!.orgId },
|
||||
})
|
||||
res.json({ success: true })
|
||||
} catch (err) { next(err) }
|
||||
})
|
||||
|
||||
// 批量参保
|
||||
router.post('/plans/:planId/enroll', async (req: AuthRequest, res: Response, next: NextFunction) => {
|
||||
try {
|
||||
const { employeeIds, premium, effectiveFrom } = req.body as { employeeIds: string[]; premium: number; effectiveFrom: string }
|
||||
const plan = await prisma.commercialInsurancePlan.findFirst({ where: { id: req.params.planId, orgId: req.user!.orgId } })
|
||||
if (!plan) return res.status(404).json({ success: false, error: { message: '方案不存在' } })
|
||||
|
||||
const existing = await prisma.commercialInsuranceEnrollment.findMany({
|
||||
where: { planId: plan.id, employeeId: { in: employeeIds }, status: 'ACTIVE' },
|
||||
select: { employeeId: true },
|
||||
})
|
||||
const existingIds = new Set(existing.map((e: any) => e.employeeId))
|
||||
const newIds = employeeIds.filter((id) => !existingIds.has(id))
|
||||
|
||||
if (newIds.length > 0) {
|
||||
await prisma.commercialInsuranceEnrollment.createMany({
|
||||
data: newIds.map((empId) => ({
|
||||
orgId: req.user!.orgId,
|
||||
planId: plan.id,
|
||||
employeeId: empId,
|
||||
premium: premium || plan.premium,
|
||||
effectiveFrom: effectiveFrom || plan.effectiveFrom,
|
||||
})),
|
||||
})
|
||||
}
|
||||
res.json({ success: true, data: { enrolled: newIds.length, skipped: existingIds.size } })
|
||||
} catch (err) { next(err) }
|
||||
})
|
||||
|
||||
// 退保
|
||||
router.post('/enrollments/:enrollmentId/terminate', async (req: AuthRequest, res: Response, next: NextFunction) => {
|
||||
try {
|
||||
const { effectiveTo } = req.body as { effectiveTo: string }
|
||||
const enrollment = await prisma.commercialInsuranceEnrollment.update({
|
||||
where: { id: req.params.enrollmentId, orgId: req.user!.orgId },
|
||||
data: { status: 'TERMINATED', effectiveTo: effectiveTo || new Date().toISOString().slice(0, 10) },
|
||||
})
|
||||
res.json({ success: true, data: enrollment })
|
||||
} catch (err) { next(err) }
|
||||
})
|
||||
|
||||
export default router
|
||||
@@ -0,0 +1,149 @@
|
||||
import { Router, Response, NextFunction } from 'express'
|
||||
import { z } from 'zod'
|
||||
import prisma from '../lib/prisma'
|
||||
import { authMiddleware, AuthRequest } from '../middleware/auth'
|
||||
|
||||
const router = Router()
|
||||
router.use(authMiddleware)
|
||||
|
||||
const createSignSchema = z.object({
|
||||
contractId: z.string().optional(),
|
||||
employeeId: z.string().min(1),
|
||||
documentTitle: z.string().min(1),
|
||||
documentContent: z.string().optional(),
|
||||
remark: z.string().optional(),
|
||||
})
|
||||
|
||||
// 签署记录列表
|
||||
router.get('/', async (req: AuthRequest, res: Response, next: NextFunction) => {
|
||||
try {
|
||||
const status = req.query.status as string | undefined
|
||||
const records = await prisma.eSignRecord.findMany({
|
||||
where: {
|
||||
orgId: req.user!.orgId,
|
||||
...(status && { status }),
|
||||
},
|
||||
include: {
|
||||
employee: { select: { id: true, name: true, department: true, phone: true } },
|
||||
},
|
||||
orderBy: { createdAt: 'desc' },
|
||||
})
|
||||
res.json({ success: true, data: records })
|
||||
} catch (err) { next(err) }
|
||||
})
|
||||
|
||||
// 发起签署
|
||||
// TODO: 对接易签宝 API — 此处为框架预留
|
||||
// 1. 调用易签宝创建签署流程
|
||||
// 2. 获取签署链接
|
||||
// 3. 保存 flowId 和 signUrl
|
||||
router.post('/create', async (req: AuthRequest, res: Response, next: NextFunction) => {
|
||||
try {
|
||||
const data = createSignSchema.parse(req.body)
|
||||
|
||||
// 预留:调用易签宝 API 创建签署流程
|
||||
// const esignResult = await esignApi.createFlow({
|
||||
// title: data.documentTitle,
|
||||
// signerPhone: employee.phone,
|
||||
// signerName: employee.name,
|
||||
// content: data.documentContent,
|
||||
// })
|
||||
// const flowId = esignResult.flowId
|
||||
// const signUrl = esignResult.signUrl
|
||||
|
||||
const record = await prisma.eSignRecord.create({
|
||||
data: {
|
||||
orgId: req.user!.orgId,
|
||||
contractId: data.contractId || null,
|
||||
employeeId: data.employeeId,
|
||||
documentTitle: data.documentTitle,
|
||||
documentContent: data.documentContent || null,
|
||||
// flowId: esignResult.flowId, // TODO: 易签宝对接后启用
|
||||
// signUrl: esignResult.signUrl, // TODO: 易签宝对接后启用
|
||||
status: 'PENDING',
|
||||
initiatedBy: req.user!.id,
|
||||
createdBy: req.user!.id,
|
||||
remark: data.remark || null,
|
||||
expiredAt: new Date(Date.now() + 30 * 24 * 60 * 60 * 1000), // 30天过期
|
||||
},
|
||||
})
|
||||
|
||||
res.json({
|
||||
success: true,
|
||||
data: record,
|
||||
message: '签署记录已创建。对接易签宝API后,将自动生成签署链接并发送给员工。',
|
||||
})
|
||||
} catch (err) { next(err) }
|
||||
})
|
||||
|
||||
// 查询签署状态
|
||||
// TODO: 对接易签宝 API — 查询流程状态并同步
|
||||
router.get('/:id/status', async (req: AuthRequest, res: Response, next: NextFunction) => {
|
||||
try {
|
||||
const record = await prisma.eSignRecord.findFirst({
|
||||
where: { id: req.params.id, orgId: req.user!.orgId },
|
||||
})
|
||||
if (!record) return res.status(404).json({ success: false, error: { message: '记录不存在' } })
|
||||
|
||||
// 预留:调用易签宝 API 查询流程状态
|
||||
// const esignStatus = await esignApi.getFlowStatus(record.flowId)
|
||||
// if (esignStatus !== record.status) {
|
||||
// await prisma.eSignRecord.update({ where: { id: record.id }, data: { status: esignStatus } })
|
||||
// }
|
||||
|
||||
res.json({ success: true, data: record })
|
||||
} catch (err) { next(err) }
|
||||
})
|
||||
|
||||
// 易签宝回调接口(无需认证)
|
||||
router.post('/callback', async (req, res: Response, next: NextFunction) => {
|
||||
try {
|
||||
const { flowId, status, signedPdfUrl, ...rest } = req.body
|
||||
|
||||
// TODO: 验证易签宝回调签名
|
||||
// if (!verifyEsignCallback(req.headers, req.body)) {
|
||||
// return res.status(401).json({ success: false, error: { message: '无效回调' } })
|
||||
// }
|
||||
|
||||
if (flowId) {
|
||||
const record = await prisma.eSignRecord.findFirst({ where: { flowId } })
|
||||
if (record) {
|
||||
await prisma.eSignRecord.update({
|
||||
where: { id: record.id },
|
||||
data: {
|
||||
status: status || 'COMPLETED',
|
||||
signedPdfUrl: signedPdfUrl || null,
|
||||
completedAt: status === 'COMPLETED' ? new Date() : null,
|
||||
callbackData: rest as any,
|
||||
},
|
||||
})
|
||||
|
||||
// 如果关联了合同,更新合同的签署方式和电子合同URL
|
||||
if (record.contractId && status === 'COMPLETED') {
|
||||
await prisma.laborContract.update({
|
||||
where: { id: record.contractId },
|
||||
data: {
|
||||
signMethod: 'ELECTRONIC',
|
||||
electronicContractUrl: signedPdfUrl || null,
|
||||
},
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
res.json({ success: true })
|
||||
} catch (err) { next(err) }
|
||||
})
|
||||
|
||||
// 取消签署
|
||||
router.post('/:id/cancel', async (req: AuthRequest, res: Response, next: NextFunction) => {
|
||||
try {
|
||||
const record = await prisma.eSignRecord.update({
|
||||
where: { id: req.params.id, orgId: req.user!.orgId },
|
||||
data: { status: 'CANCELLED' },
|
||||
})
|
||||
res.json({ success: true, data: record })
|
||||
} catch (err) { next(err) }
|
||||
})
|
||||
|
||||
export default router
|
||||
@@ -52,6 +52,9 @@ const OnboardingProgress = lazy(() => import('./pages/portal/OnboardingProgress'
|
||||
const ResignationApply = lazy(() => import('./pages/portal/ResignationApply'))
|
||||
const RiskCenter = lazy(() => import('./pages/compliance/RiskCenter'))
|
||||
const SalaryDashboard = lazy(() => import('./pages/SalaryDashboard'))
|
||||
const CommercialInsurance = lazy(() => import('./pages/CommercialInsurance'))
|
||||
const EmployeeBenefits = lazy(() => import('./pages/EmployeeBenefits'))
|
||||
const ESign = lazy(() => import('./pages/ESign'))
|
||||
|
||||
// 平台管理端
|
||||
const PlatformLogin = lazy(() => import('./pages/platform/PlatformLogin'))
|
||||
@@ -198,6 +201,9 @@ export default function App() {
|
||||
<Route path="/leave-approval" element={<ProtectedRoute><AdminLayout><LeaveApproval /></AdminLayout></ProtectedRoute>} />
|
||||
<Route path="/risk-center" element={<ProtectedRoute><AdminLayout><RiskCenter /></AdminLayout></ProtectedRoute>} />
|
||||
<Route path="/salary-dashboard" element={<ProtectedRoute><AdminLayout><SalaryDashboard /></AdminLayout></ProtectedRoute>} />
|
||||
<Route path="/commercial-insurance" element={<ProtectedRoute><AdminLayout><CommercialInsurance /></AdminLayout></ProtectedRoute>} />
|
||||
<Route path="/benefits" element={<ProtectedRoute><AdminLayout><EmployeeBenefits /></AdminLayout></ProtectedRoute>} />
|
||||
<Route path="/esign" element={<ProtectedRoute><AdminLayout><ESign /></AdminLayout></ProtectedRoute>} />
|
||||
|
||||
{/* 平台管理端 */}
|
||||
<Route path="/platform/login" element={<Suspense fallback={<SkeletonPage />}><PlatformLogin /></Suspense>} />
|
||||
|
||||
@@ -15,6 +15,7 @@ import {
|
||||
Bell, ScrollText, Settings,
|
||||
ChevronDown, ChevronRight,
|
||||
Building2, CalendarDays, ClipboardList, Heart, CalendarClock,
|
||||
Gift, PenTool, Umbrella,
|
||||
} from 'lucide-react'
|
||||
import Logo from '../ui/Logo'
|
||||
import { settingsApi } from '../../lib/api-services'
|
||||
@@ -55,6 +56,14 @@ const navGroups: NavGroup[] = [
|
||||
{ path: '/salary-dashboard', label: '薪酬分析', icon: BarChart3 },
|
||||
],
|
||||
},
|
||||
{
|
||||
title: '福利保障',
|
||||
items: [
|
||||
{ path: '/commercial-insurance', label: '商业保险', icon: Umbrella },
|
||||
{ path: '/benefits', label: '员工福利', icon: Gift },
|
||||
{ path: '/esign', label: '电子签署', icon: PenTool },
|
||||
],
|
||||
},
|
||||
{
|
||||
title: '时间',
|
||||
items: [
|
||||
|
||||
@@ -572,6 +572,42 @@ export const commercialInsuranceApi = {
|
||||
/** 删除方案 */
|
||||
removePlan: (id: string) =>
|
||||
del(`/commercial-insurance/plans/${id}`),
|
||||
/** 批量参保 */
|
||||
enroll: (planId: string, data: { employeeIds: string[]; premium?: number; effectiveFrom?: string }) =>
|
||||
post(`/commercial-insurance/plans/${planId}/enroll`, data),
|
||||
/** 退保 */
|
||||
terminateEnrollment: (enrollmentId: string, effectiveTo?: string) =>
|
||||
post(`/commercial-insurance/enrollments/${enrollmentId}/terminate`, { effectiveTo }),
|
||||
}
|
||||
|
||||
// ========== 员工福利 ==========
|
||||
export const benefitApi = {
|
||||
plans: () =>
|
||||
get('/benefits/plans').then(unwrap<any[]>()),
|
||||
savePlan: (data: Record<string, unknown>, editId?: string) =>
|
||||
editId ? put(`/benefits/plans/${editId}`, data) : post('/benefits/plans', data),
|
||||
removePlan: (id: string) =>
|
||||
del(`/benefits/plans/${id}`),
|
||||
enrollments: (planId: string) =>
|
||||
get(`/benefits/plans/${planId}/enrollments`).then(unwrap<any[]>()),
|
||||
enroll: (planId: string, data: { employeeIds: string[]; effectiveFrom?: string }) =>
|
||||
post(`/benefits/plans/${planId}/enroll`, data),
|
||||
terminateEnrollment: (enrollmentId: string, effectiveTo?: string) =>
|
||||
post(`/benefits/enrollments/${enrollmentId}/terminate`, { effectiveTo }),
|
||||
employeeSummary: () =>
|
||||
get('/benefits/employee-summary').then(unwrap<any[]>()),
|
||||
}
|
||||
|
||||
// ========== 电子签署(易签宝) ==========
|
||||
export const esignApi = {
|
||||
list: (status?: string) =>
|
||||
get('/esign', { params: status ? { status } : {} }).then(unwrap<any[]>()),
|
||||
create: (data: { contractId?: string; employeeId: string; documentTitle: string; documentContent?: string; remark?: string }) =>
|
||||
post('/esign/create', data),
|
||||
status: (id: string) =>
|
||||
get(`/esign/${id}/status`).then(unwrap<any>()),
|
||||
cancel: (id: string) =>
|
||||
post(`/esign/${id}/cancel`),
|
||||
}
|
||||
|
||||
// ========== 离职相关 ==========
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
import { Shield } from 'lucide-react'
|
||||
import PageGuide from '../components/ui/PageGuide'
|
||||
import CommercialInsuranceTab from './social-insurance/CommercialInsuranceTab'
|
||||
|
||||
export default function CommercialInsurance() {
|
||||
return (
|
||||
<div className="space-y-4">
|
||||
<div className="flex items-center gap-2">
|
||||
<Shield className="h-5 w-5 text-primary" />
|
||||
<div>
|
||||
<h1 className="text-base font-semibold">商业保险</h1>
|
||||
<p className="mt-1 text-sm text-gray-500">管理商业保险方案、参保人员及保单信息</p>
|
||||
</div>
|
||||
</div>
|
||||
<PageGuide>
|
||||
商业保险是社保之外的自愿性补充保障,包括意外伤害险、补充医疗、雇主责任险等。
|
||||
点击「新增方案」创建商险计划,选择方案后可查看参保人员列表。
|
||||
<span className="text-primary"> 商业保险是系统增值服务模块,支持方案管理、参保人员追踪、保费统计。</span>
|
||||
</PageGuide>
|
||||
<CommercialInsuranceTab />
|
||||
</div>
|
||||
)
|
||||
}
|
||||
@@ -0,0 +1,233 @@
|
||||
import { useState } from 'react'
|
||||
import { toast } from 'sonner'
|
||||
import { useQuery, useMutation, useQueryClient } from '@tanstack/react-query'
|
||||
import { PenTool, Plus, X, RefreshCw, ExternalLink, FileText, AlertCircle } from 'lucide-react'
|
||||
import { esignApi, rosterApi } from '../lib/api-services'
|
||||
import PageGuide from '../components/ui/PageGuide'
|
||||
import Card from '../components/ui/Card'
|
||||
import Button from '../components/ui/Button'
|
||||
import { Input, Label } from '../components/ui/Input'
|
||||
import { InlineAlert } from '../components/ui/InlineAlert'
|
||||
import Modal from '../components/ui/Modal'
|
||||
|
||||
const STATUS_CONFIG: Record<string, { label: string; color: string }> = {
|
||||
PENDING: { label: '待签署', color: 'bg-yellow-50 text-yellow-700' },
|
||||
SIGNING: { label: '签署中', color: 'bg-blue-50 text-blue-700' },
|
||||
COMPLETED: { label: '已完成', color: 'bg-green-50 text-safe' },
|
||||
REJECTED: { label: '已拒绝', color: 'bg-red-50 text-danger' },
|
||||
EXPIRED: { label: '已过期', color: 'bg-gray-100 text-gray-500' },
|
||||
CANCELLED: { label: '已取消', color: 'bg-gray-100 text-gray-500' },
|
||||
}
|
||||
|
||||
export default function ESign() {
|
||||
const queryClient = useQueryClient()
|
||||
const [filterStatus, setFilterStatus] = useState('')
|
||||
const [showCreate, setShowCreate] = useState(false)
|
||||
const [formData, setFormData] = useState({
|
||||
employeeId: '',
|
||||
documentTitle: '',
|
||||
remark: '',
|
||||
})
|
||||
|
||||
const { data: records = [], isLoading } = useQuery<any[]>({
|
||||
queryKey: ['esign-records', filterStatus],
|
||||
queryFn: async () => {
|
||||
return await esignApi.list(filterStatus || undefined)
|
||||
},
|
||||
})
|
||||
|
||||
const { data: rosterData } = useQuery<any>({
|
||||
queryKey: ['roster-for-esign'],
|
||||
queryFn: async () => {
|
||||
return await rosterApi.list({ search: '', page: 1, pageSize: 200 } as any) as any
|
||||
},
|
||||
enabled: showCreate,
|
||||
})
|
||||
|
||||
const createMutation = useMutation({
|
||||
mutationFn: async (data: { employeeId: string; documentTitle: string; remark?: string }) =>
|
||||
esignApi.create(data) as any,
|
||||
onSuccess: () => {
|
||||
queryClient.invalidateQueries({ queryKey: ['esign-records'] })
|
||||
setShowCreate(false)
|
||||
setFormData({ employeeId: '', documentTitle: '', remark: '' })
|
||||
toast.success('签署记录已创建,待对接易签宝后将自动发送签署链接')
|
||||
},
|
||||
onError: () => toast.error('创建失败'),
|
||||
})
|
||||
|
||||
const cancelMutation = useMutation({
|
||||
mutationFn: (id: string) => esignApi.cancel(id),
|
||||
onSuccess: () => {
|
||||
queryClient.invalidateQueries({ queryKey: ['esign-records'] })
|
||||
toast.success('已取消签署')
|
||||
},
|
||||
})
|
||||
|
||||
const refreshStatusMutation = useMutation({
|
||||
mutationFn: (id: string) => esignApi.status(id),
|
||||
onSuccess: () => {
|
||||
queryClient.invalidateQueries({ queryKey: ['esign-records'] })
|
||||
toast.success('状态已刷新')
|
||||
},
|
||||
})
|
||||
|
||||
const handleCreate = () => {
|
||||
if (!formData.employeeId) { toast.error('请选择员工'); return }
|
||||
if (!formData.documentTitle.trim()) { toast.error('请填写文件标题'); return }
|
||||
createMutation.mutate(formData)
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="space-y-4">
|
||||
<div className="flex items-center gap-2">
|
||||
<PenTool className="h-5 w-5 text-primary" />
|
||||
<div>
|
||||
<h1 className="text-base font-semibold">电子签署</h1>
|
||||
<p className="mt-1 text-sm text-gray-500">对接易签宝实现在线合同签署</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<PageGuide>
|
||||
通过易签宝平台发起电子合同签署,员工在线完成签署后自动回传签署状态和PDF文件。
|
||||
<span className="text-amber-600"> 当前为框架预留阶段,对接易签宝API后将自动启用在线签署功能。</span>
|
||||
</PageGuide>
|
||||
|
||||
<InlineAlert type="info" className="flex items-start gap-2">
|
||||
<AlertCircle className="w-4 h-4 mt-0.5 shrink-0" />
|
||||
<div>
|
||||
<span className="font-medium">对接状态:框架已就绪,待接入易签宝API</span>
|
||||
<div className="mt-1 text-xs">
|
||||
需要提供易签宝的 AppId、AppSecret 和 API 基础地址。对接后可实现:
|
||||
① HR在系统发起签署 → ② 调用易签宝创建签署流程 → ③ 员工收到签署链接 → ④ 签署完成自动回调更新状态 → ⑤ 合同自动关联电子版PDF
|
||||
</div>
|
||||
</div>
|
||||
</InlineAlert>
|
||||
|
||||
<div className="flex items-center justify-between">
|
||||
<div className="flex gap-2">
|
||||
<select
|
||||
value={filterStatus}
|
||||
onChange={(e) => setFilterStatus(e.target.value)}
|
||||
className="h-9 rounded-md border border-gray-200 bg-white px-3 text-sm text-gray-700 shadow-sm outline-none transition focus:border-primary focus:ring-2 focus:ring-primary/10"
|
||||
>
|
||||
<option value="">全部状态</option>
|
||||
{Object.entries(STATUS_CONFIG).map(([k, v]) => <option key={k} value={k}>{v.label}</option>)}
|
||||
</select>
|
||||
</div>
|
||||
<Button size="sm" onClick={() => setShowCreate(true)}>
|
||||
<Plus className="w-4 h-4 mr-1" />发起签署
|
||||
</Button>
|
||||
</div>
|
||||
|
||||
{/* 签署记录列表 */}
|
||||
<Card>
|
||||
{isLoading ? (
|
||||
<div className="text-center py-8 text-gray-400">加载中...</div>
|
||||
) : records.length === 0 ? (
|
||||
<div className="text-center py-8 text-gray-400 text-sm">暂无签署记录,点击「发起签署」创建</div>
|
||||
) : (
|
||||
<div className="overflow-x-auto">
|
||||
<table className="w-full text-sm">
|
||||
<thead>
|
||||
<tr className="border-b text-xs text-gray-500">
|
||||
<th className="py-2 px-3 text-left">文件标题</th>
|
||||
<th className="py-2 px-3 text-left">签署人</th>
|
||||
<th className="py-2 px-3 text-left">部门</th>
|
||||
<th className="py-2 px-3 text-left">状态</th>
|
||||
<th className="py-2 px-3 text-left">发起时间</th>
|
||||
<th className="py-2 px-3 text-left">完成时间</th>
|
||||
<th className="py-2 px-3 text-right">操作</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{records.map((r: any) => {
|
||||
const statusCfg = STATUS_CONFIG[r.status] || STATUS_CONFIG.PENDING
|
||||
return (
|
||||
<tr key={r.id} className="border-b last:border-0 hover:bg-gray-50">
|
||||
<td className="py-2 px-3">
|
||||
<div className="flex items-center gap-1.5">
|
||||
<FileText className="w-3.5 h-3.5 text-gray-400 shrink-0" />
|
||||
<span className="font-medium truncate max-w-[200px]">{r.documentTitle}</span>
|
||||
</div>
|
||||
{r.remark && <div className="text-xs text-gray-400 mt-0.5">{r.remark}</div>}
|
||||
</td>
|
||||
<td className="py-2 px-3">{r.employee?.name || '—'}</td>
|
||||
<td className="py-2 px-3 text-gray-500">{r.employee?.department || '—'}</td>
|
||||
<td className="py-2 px-3">
|
||||
<span className={`px-2 py-0.5 rounded text-xs ${statusCfg.color}`}>{statusCfg.label}</span>
|
||||
</td>
|
||||
<td className="py-2 px-3 text-gray-500 text-xs">{new Date(r.createdAt).toLocaleString('zh-CN')}</td>
|
||||
<td className="py-2 px-3 text-gray-500 text-xs">{r.completedAt ? new Date(r.completedAt).toLocaleString('zh-CN') : '—'}</td>
|
||||
<td className="py-2 px-3 text-right">
|
||||
<div className="flex items-center justify-end gap-1">
|
||||
{r.status === 'COMPLETED' && r.signedPdfUrl && (
|
||||
<a href={r.signedPdfUrl} target="_blank" rel="noopener noreferrer"
|
||||
className="text-xs text-primary hover:underline flex items-center gap-0.5">
|
||||
<ExternalLink className="w-3 h-3" />查看PDF
|
||||
</a>
|
||||
)}
|
||||
{(r.status === 'PENDING' || r.status === 'SIGNING') && (
|
||||
<>
|
||||
<button className="text-xs text-gray-400 hover:text-primary" onClick={() => refreshStatusMutation.mutate(r.id)}
|
||||
title="刷新状态">
|
||||
<RefreshCw className={`w-3.5 h-3.5 ${refreshStatusMutation.isPending ? 'animate-spin' : ''}`} />
|
||||
</button>
|
||||
<button className="text-xs text-gray-400 hover:text-danger" onClick={() => {
|
||||
if (confirm('确定取消此签署任务吗?')) cancelMutation.mutate(r.id)
|
||||
}}>取消</button>
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
)
|
||||
})}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
)}
|
||||
</Card>
|
||||
|
||||
{/* 发起签署 Modal */}
|
||||
{showCreate && (
|
||||
<Modal open={true} onClose={() => setShowCreate(false)} title="发起电子签署" size="md">
|
||||
<div className="space-y-3">
|
||||
<InlineAlert type="info">
|
||||
选择员工并填写文件标题,系统将创建签署记录。对接易签宝后,将自动生成签署链接并发送给员工。
|
||||
</InlineAlert>
|
||||
<div>
|
||||
<Label>签署员工 *</Label>
|
||||
<select
|
||||
className="h-9 w-full rounded-md border border-gray-200 bg-white px-3 text-sm text-gray-700 shadow-sm outline-none transition focus:border-primary focus:ring-2 focus:ring-primary/10"
|
||||
value={formData.employeeId}
|
||||
onChange={(e) => setFormData({ ...formData, employeeId: e.target.value })}
|
||||
>
|
||||
<option value="">请选择员工</option>
|
||||
{rosterData?.items?.filter((e: any) => e.status === 'ACTIVE').map((emp: any) => (
|
||||
<option key={emp.id} value={emp.id}>{emp.name} - {emp.department}</option>
|
||||
))}
|
||||
</select>
|
||||
</div>
|
||||
<div>
|
||||
<Label>文件标题 *</Label>
|
||||
<Input value={formData.documentTitle} onChange={(e) => setFormData({ ...formData, documentTitle: e.target.value })}
|
||||
placeholder="如:2024年度劳动合同" />
|
||||
</div>
|
||||
<div>
|
||||
<Label>备注</Label>
|
||||
<Input value={formData.remark} onChange={(e) => setFormData({ ...formData, remark: e.target.value })}
|
||||
placeholder="可选" />
|
||||
</div>
|
||||
<div className="flex justify-end gap-2 pt-2">
|
||||
<Button variant="secondary" size="sm" onClick={() => setShowCreate(false)}>取消</Button>
|
||||
<Button size="sm" onClick={handleCreate} disabled={createMutation.isPending}>
|
||||
{createMutation.isPending ? '创建中...' : '发起签署'}
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
</Modal>
|
||||
)}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
@@ -0,0 +1,459 @@
|
||||
import { useState } from 'react'
|
||||
import { toast } from 'sonner'
|
||||
import { useQuery, useMutation, useQueryClient } from '@tanstack/react-query'
|
||||
import { useConfirm } from '../hooks/useConfirm'
|
||||
import { Gift, Plus, Settings as SettingsIcon, X, Users } from 'lucide-react'
|
||||
import { benefitApi, rosterApi } from '../lib/api-services'
|
||||
import PageGuide from '../components/ui/PageGuide'
|
||||
import Card from '../components/ui/Card'
|
||||
import Button from '../components/ui/Button'
|
||||
import { Input, Label } from '../components/ui/Input'
|
||||
import { InlineAlert } from '../components/ui/InlineAlert'
|
||||
import Modal from '../components/ui/Modal'
|
||||
|
||||
const fmt = (n: number) => (n || 0).toLocaleString('zh-CN', { minimumFractionDigits: 2, maximumFractionDigits: 2 })
|
||||
|
||||
const BENEFIT_CATEGORIES: Record<string, { label: string; color: string }> = {
|
||||
TRANSPORT: { label: '交通补贴', color: 'bg-blue-50 text-blue-700 border border-blue-200' },
|
||||
MEAL: { label: '餐补', color: 'bg-orange-50 text-orange-700 border border-orange-200' },
|
||||
HOUSING: { label: '住房补贴', color: 'bg-teal-50 text-teal-700 border border-teal-200' },
|
||||
COMMUNICATION: { label: '通讯补贴', color: 'bg-purple-50 text-purple-700 border border-purple-200' },
|
||||
HEALTH_CHECK: { label: '体检', color: 'bg-green-50 text-green-700 border border-green-200' },
|
||||
HOLIDAY: { label: '节日福利', color: 'bg-red-50 text-red-700 border border-red-200' },
|
||||
BIRTHDAY: { label: '生日福利', color: 'bg-pink-50 text-pink-700 border border-pink-200' },
|
||||
OTHER: { label: '其他', color: 'bg-gray-50 text-gray-700 border border-gray-200' },
|
||||
}
|
||||
|
||||
const FREQUENCY_LABELS: Record<string, string> = {
|
||||
MONTHLY: '每月',
|
||||
QUARTERLY: '每季',
|
||||
YEARLY: '每年',
|
||||
ONE_TIME: '一次性',
|
||||
}
|
||||
|
||||
const DEFAULT_PLAN = {
|
||||
name: '', category: 'TRANSPORT', amount: 0, frequency: 'MONTHLY',
|
||||
taxDeductible: false, description: '',
|
||||
}
|
||||
|
||||
export default function EmployeeBenefits() {
|
||||
const queryClient = useQueryClient()
|
||||
const confirm = useConfirm()
|
||||
const [tab, setTab] = useState<'plans' | 'summary'>('plans')
|
||||
const [showAddPlan, setShowAddPlan] = useState(false)
|
||||
const [editingPlan, setEditingPlan] = useState<any>(null)
|
||||
const [selectedPlanId, setSelectedPlanId] = useState<string | null>(null)
|
||||
const [newPlan, setNewPlan] = useState<any>({ ...DEFAULT_PLAN })
|
||||
const [showEnrollModal, setShowEnrollModal] = useState(false)
|
||||
const [enrollEmployeeIds, setEnrollEmployeeIds] = useState<string[]>([])
|
||||
const [enrollEffectiveFrom, setEnrollEffectiveFrom] = useState(new Date().toISOString().slice(0, 7))
|
||||
|
||||
const { data: plans = [], isLoading } = useQuery<any[]>({
|
||||
queryKey: ['benefit-plans'],
|
||||
queryFn: async () => {
|
||||
return await benefitApi.plans()
|
||||
},
|
||||
})
|
||||
|
||||
const { data: enrollments = [], isLoading: enrollLoading } = useQuery<any[]>({
|
||||
queryKey: ['benefit-enrollments', selectedPlanId],
|
||||
queryFn: async () => {
|
||||
if (!selectedPlanId) return []
|
||||
return await benefitApi.enrollments(selectedPlanId)
|
||||
},
|
||||
enabled: !!selectedPlanId,
|
||||
})
|
||||
|
||||
const { data: employeeSummary = [] } = useQuery<any[]>({
|
||||
queryKey: ['benefit-employee-summary'],
|
||||
queryFn: async () => {
|
||||
return await benefitApi.employeeSummary()
|
||||
},
|
||||
enabled: tab === 'summary',
|
||||
})
|
||||
|
||||
const { data: rosterData } = useQuery<any>({
|
||||
queryKey: ['roster-for-benefit', ''],
|
||||
queryFn: async () => {
|
||||
return await rosterApi.list({ search: '', page: 1, pageSize: 200 } as any) as any
|
||||
},
|
||||
enabled: showEnrollModal,
|
||||
})
|
||||
|
||||
const savePlanMutation = useMutation({
|
||||
mutationFn: async (data: any) => {
|
||||
if (editingPlan) {
|
||||
return benefitApi.savePlan(data, editingPlan.id) as any
|
||||
}
|
||||
return benefitApi.savePlan(data) as any
|
||||
},
|
||||
onSuccess: () => {
|
||||
queryClient.invalidateQueries({ queryKey: ['benefit-plans'] })
|
||||
setShowAddPlan(false)
|
||||
setEditingPlan(null)
|
||||
setNewPlan({ ...DEFAULT_PLAN })
|
||||
toast.success(editingPlan ? '福利方案已更新' : '福利方案已创建')
|
||||
},
|
||||
onError: () => toast.error('保存失败'),
|
||||
})
|
||||
|
||||
const deletePlanMutation = useMutation({
|
||||
mutationFn: (id: string) => benefitApi.removePlan(id),
|
||||
onSuccess: () => {
|
||||
queryClient.invalidateQueries({ queryKey: ['benefit-plans'] })
|
||||
setSelectedPlanId(null)
|
||||
toast.success('福利方案已删除')
|
||||
},
|
||||
})
|
||||
|
||||
const enrollMutation = useMutation({
|
||||
mutationFn: async (data: { employeeIds: string[]; effectiveFrom: string }) =>
|
||||
benefitApi.enroll(selectedPlanId!, data) as any,
|
||||
onSuccess: (res: any) => {
|
||||
queryClient.invalidateQueries({ queryKey: ['benefit-enrollments'] })
|
||||
queryClient.invalidateQueries({ queryKey: ['benefit-employee-summary'] })
|
||||
setShowEnrollModal(false)
|
||||
setEnrollEmployeeIds([])
|
||||
toast.success(`已添加 ${res.data?.enrolled || 0} 名员工`)
|
||||
},
|
||||
onError: () => toast.error('参保失败'),
|
||||
})
|
||||
|
||||
const terminateMutation = useMutation({
|
||||
mutationFn: (enrollmentId: string) => benefitApi.terminateEnrollment(enrollmentId),
|
||||
onSuccess: () => {
|
||||
queryClient.invalidateQueries({ queryKey: ['benefit-enrollments'] })
|
||||
queryClient.invalidateQueries({ queryKey: ['benefit-employee-summary'] })
|
||||
toast.success('已终止福利')
|
||||
},
|
||||
})
|
||||
|
||||
const handleEdit = (plan: any) => {
|
||||
setEditingPlan(plan)
|
||||
setNewPlan({ ...plan })
|
||||
setShowAddPlan(true)
|
||||
}
|
||||
|
||||
const handleSave = () => {
|
||||
if (!newPlan.name?.trim()) { toast.error('请填写方案名称'); return }
|
||||
savePlanMutation.mutate(newPlan)
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="space-y-4">
|
||||
<div className="flex items-center gap-2">
|
||||
<Gift className="h-5 w-5 text-primary" />
|
||||
<div>
|
||||
<h1 className="text-base font-semibold">员工福利</h1>
|
||||
<p className="mt-1 text-sm text-gray-500">管理员工福利方案、参保人员及福利汇总</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<PageGuide>
|
||||
员工福利包括交通补贴、餐补、住房补贴、通讯补贴、体检、节日福利等。
|
||||
管理福利方案、批量参保、查看员工福利汇总。
|
||||
<span className="text-primary"> 员工福利是系统增值服务模块,支持按方案/按员工维度管理福利,可关联薪资计算。</span>
|
||||
</PageGuide>
|
||||
|
||||
{/* Tab 切换 */}
|
||||
<div className="flex items-center gap-4 border-b">
|
||||
{(['plans', 'summary'] as const).map((t) => (
|
||||
<button
|
||||
key={t}
|
||||
className={`px-4 py-2 text-sm font-medium border-b-2 transition-colors ${
|
||||
tab === t ? 'border-primary text-primary' : 'border-transparent text-gray-500 hover:text-gray-700'
|
||||
}`}
|
||||
onClick={() => setTab(t)}
|
||||
>
|
||||
{t === 'plans' ? '福利方案' : '员工汇总'}
|
||||
</button>
|
||||
))}
|
||||
{tab === 'plans' && (
|
||||
<Button size="sm" className="ml-auto" onClick={() => { setEditingPlan(null); setNewPlan({ ...DEFAULT_PLAN }); setShowAddPlan(true) }}>
|
||||
<Plus className="w-4 h-4 mr-1" />新增方案
|
||||
</Button>
|
||||
)}
|
||||
</div>
|
||||
|
||||
{/* ========== 福利方案 Tab ========== */}
|
||||
{tab === 'plans' && (
|
||||
<>
|
||||
{isLoading ? (
|
||||
<Card><div className="text-center py-8 text-gray-400">加载中...</div></Card>
|
||||
) : plans.length === 0 ? (
|
||||
<Card><div className="text-center py-8 text-gray-400 text-sm">暂无福利方案,点击「新增方案」创建</div></Card>
|
||||
) : (
|
||||
<div className="grid gap-3 md:grid-cols-2 lg:grid-cols-3">
|
||||
{plans.map((plan: any) => {
|
||||
const catCfg = BENEFIT_CATEGORIES[plan.category] || BENEFIT_CATEGORIES.OTHER
|
||||
const isSelected = selectedPlanId === plan.id
|
||||
return (
|
||||
<Card
|
||||
key={plan.id}
|
||||
className={`cursor-pointer transition-all ${isSelected ? 'ring-2 ring-primary/20' : 'hover:shadow-md'}`}
|
||||
>
|
||||
<div onClick={() => setSelectedPlanId(isSelected ? null : plan.id)}>
|
||||
<div className="flex items-start justify-between mb-2">
|
||||
<div>
|
||||
<span className={`px-2 py-0.5 rounded text-xs ${catCfg.color}`}>{catCfg.label}</span>
|
||||
<h3 className="text-sm font-medium mt-1">{plan.name}</h3>
|
||||
</div>
|
||||
<div className="flex gap-1" onClick={(e) => e.stopPropagation()}>
|
||||
<button className="text-xs text-gray-400 hover:text-primary" onClick={() => handleEdit(plan)}>
|
||||
<SettingsIcon className="w-3.5 h-3.5" />
|
||||
</button>
|
||||
<button className="text-xs text-gray-400 hover:text-danger" onClick={async () => {
|
||||
if (await confirm({ title: '确认删除', message: `确定删除福利方案「${plan.name}」吗?` })) {
|
||||
deletePlanMutation.mutate(plan.id)
|
||||
}
|
||||
}}>
|
||||
<X className="w-3.5 h-3.5" />
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<div className="space-y-1 text-xs text-gray-500">
|
||||
<div className="flex justify-between"><span>金额</span><span className="text-gray-700">¥{fmt(plan.amount)} / {FREQUENCY_LABELS[plan.frequency] || plan.frequency}</span></div>
|
||||
<div className="flex justify-between"><span>税前扣除</span><span className="text-gray-700">{plan.taxDeductible ? '是' : '否'}</span></div>
|
||||
<div className="flex justify-between"><span>参保人数</span><span className="text-gray-700">{plan._count?.enrollments || 0} 人</span></div>
|
||||
</div>
|
||||
{plan.description && <p className="text-xs text-gray-400 mt-2 line-clamp-2">{plan.description}</p>}
|
||||
</div>
|
||||
</Card>
|
||||
)
|
||||
})}
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* 参保人员 */}
|
||||
{selectedPlanId && (
|
||||
<Card>
|
||||
<div className="flex items-center justify-between mb-3">
|
||||
<h3 className="text-sm font-medium">参保人员({enrollments.length}人)</h3>
|
||||
<Button size="sm" variant="secondary" onClick={() => { setEnrollEmployeeIds([]); setShowEnrollModal(true) }}>
|
||||
<Users className="w-3.5 h-3.5 mr-1" />批量参保
|
||||
</Button>
|
||||
</div>
|
||||
{enrollLoading ? (
|
||||
<div className="text-center py-4 text-gray-400 text-sm">加载中...</div>
|
||||
) : enrollments.length === 0 ? (
|
||||
<div className="text-center py-4 text-gray-400 text-sm">暂无参保人员</div>
|
||||
) : (
|
||||
<div className="overflow-x-auto">
|
||||
<table className="w-full text-sm">
|
||||
<thead>
|
||||
<tr className="border-b text-xs text-gray-500">
|
||||
<th className="py-2 text-left">姓名</th>
|
||||
<th className="py-2 text-left">部门</th>
|
||||
<th className="py-2 text-left">生效月份</th>
|
||||
<th className="py-2 text-left">截止月份</th>
|
||||
<th className="py-2 text-left">状态</th>
|
||||
<th className="py-2 text-right">操作</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{enrollments.map((e: any) => (
|
||||
<tr key={e.id || e.employeeId} className="border-b last:border-0 hover:bg-gray-50">
|
||||
<td className="py-2 font-medium">{e.name}</td>
|
||||
<td className="py-2 text-gray-500">{e.department}</td>
|
||||
<td className="py-2 text-gray-500 text-xs">{e.effectiveFrom || '—'}</td>
|
||||
<td className="py-2 text-gray-500 text-xs">{e.effectiveTo || '至今'}</td>
|
||||
<td className="py-2">
|
||||
<span className={`px-2 py-0.5 rounded text-xs ${e.status === 'ACTIVE' ? 'bg-green-50 text-safe' : 'bg-gray-100 text-gray-500'}`}>
|
||||
{e.status === 'ACTIVE' ? '有效' : '已终止'}
|
||||
</span>
|
||||
</td>
|
||||
<td className="py-2 text-right">
|
||||
{e.status === 'ACTIVE' && (
|
||||
<button className="text-xs text-gray-400 hover:text-danger" onClick={async () => {
|
||||
if (await confirm({ title: '确认终止', message: `确定终止${e.name}的福利吗?` })) {
|
||||
terminateMutation.mutate(e.id)
|
||||
}
|
||||
}}>终止</button>
|
||||
)}
|
||||
</td>
|
||||
</tr>
|
||||
))}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
)}
|
||||
</Card>
|
||||
)}
|
||||
</>
|
||||
)}
|
||||
|
||||
{/* ========== 员工汇总 Tab ========== */}
|
||||
{tab === 'summary' && (
|
||||
<Card>
|
||||
{employeeSummary.length === 0 ? (
|
||||
<div className="text-center py-8 text-gray-400 text-sm">暂无员工福利数据</div>
|
||||
) : (
|
||||
<div className="overflow-x-auto">
|
||||
<table className="w-full text-sm">
|
||||
<thead>
|
||||
<tr className="border-b text-xs text-gray-500">
|
||||
<th className="py-2 text-left">姓名</th>
|
||||
<th className="py-2 text-left">部门</th>
|
||||
<th className="py-2 text-left">福利项</th>
|
||||
<th className="py-2 text-right">月度合计</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{employeeSummary.map((e: any) => (
|
||||
<tr key={e.employeeId} className="border-b last:border-0 hover:bg-gray-50">
|
||||
<td className="py-2 font-medium">{e.name}</td>
|
||||
<td className="py-2 text-gray-500">{e.department}</td>
|
||||
<td className="py-2">
|
||||
<div className="flex flex-wrap gap-1">
|
||||
{e.benefits.map((b: any, i: number) => (
|
||||
<span key={i} className={`px-1.5 py-0.5 rounded text-xs ${BENEFIT_CATEGORIES[b.category]?.color || BENEFIT_CATEGORIES.OTHER.color}`}>
|
||||
{b.planName} ¥{fmt(b.amount)}
|
||||
</span>
|
||||
))}
|
||||
</div>
|
||||
</td>
|
||||
<td className="py-2 text-right font-medium text-primary">¥{fmt(e.totalMonthly)}</td>
|
||||
</tr>
|
||||
))}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
)}
|
||||
</Card>
|
||||
)}
|
||||
|
||||
{/* 新增/编辑方案 Modal */}
|
||||
{showAddPlan && (
|
||||
<div className="fixed inset-0 z-50 flex items-center justify-center bg-black/30" onClick={() => setShowAddPlan(false)}>
|
||||
<Card className="w-full max-w-lg mx-4">
|
||||
<div onClick={(e) => e.stopPropagation()}>
|
||||
<div className="flex items-center justify-between mb-4">
|
||||
<h3 className="text-sm font-medium">{editingPlan ? '编辑福利方案' : '新增福利方案'}</h3>
|
||||
<button onClick={() => setShowAddPlan(false)} className="text-gray-400 hover:text-gray-600"><X className="w-4 h-4" /></button>
|
||||
</div>
|
||||
<div className="space-y-3">
|
||||
<div>
|
||||
<Label>方案名称 *</Label>
|
||||
<Input value={newPlan.name} onChange={(e) => setNewPlan({ ...newPlan, name: e.target.value })} placeholder="如:2024年度交通补贴" />
|
||||
</div>
|
||||
<div className="grid grid-cols-2 gap-3">
|
||||
<div>
|
||||
<Label>福利类型</Label>
|
||||
<select
|
||||
className="h-9 w-full rounded-md border border-gray-200 bg-white px-3 text-sm text-gray-700 shadow-sm outline-none transition focus:border-primary focus:ring-2 focus:ring-primary/10"
|
||||
value={newPlan.category}
|
||||
onChange={(e) => setNewPlan({ ...newPlan, category: e.target.value })}
|
||||
>
|
||||
{Object.entries(BENEFIT_CATEGORIES).map(([k, v]) => <option key={k} value={k}>{v.label}</option>)}
|
||||
</select>
|
||||
</div>
|
||||
<div>
|
||||
<Label>发放频率</Label>
|
||||
<select
|
||||
className="h-9 w-full rounded-md border border-gray-200 bg-white px-3 text-sm text-gray-700 shadow-sm outline-none transition focus:border-primary focus:ring-2 focus:ring-primary/10"
|
||||
value={newPlan.frequency}
|
||||
onChange={(e) => setNewPlan({ ...newPlan, frequency: e.target.value })}
|
||||
>
|
||||
{Object.entries(FREQUENCY_LABELS).map(([k, v]) => <option key={k} value={k}>{v}</option>)}
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div className="grid grid-cols-2 gap-3">
|
||||
<div>
|
||||
<Label>金额(元)</Label>
|
||||
<Input type="number" value={newPlan.amount} onChange={(e) => setNewPlan({ ...newPlan, amount: parseFloat(e.target.value) || 0 })} />
|
||||
</div>
|
||||
<div>
|
||||
<Label>是否税前扣除</Label>
|
||||
<select
|
||||
className="h-9 w-full rounded-md border border-gray-200 bg-white px-3 text-sm text-gray-700 shadow-sm outline-none transition focus:border-primary focus:ring-2 focus:ring-primary/10"
|
||||
value={newPlan.taxDeductible ? 'true' : 'false'}
|
||||
onChange={(e) => setNewPlan({ ...newPlan, taxDeductible: e.target.value === 'true' })}
|
||||
>
|
||||
<option value="false">否</option>
|
||||
<option value="true">是</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<Label>备注</Label>
|
||||
<Input value={newPlan.description || ''} onChange={(e) => setNewPlan({ ...newPlan, description: e.target.value })} placeholder="适用条件、发放规则等" />
|
||||
</div>
|
||||
<div className="flex justify-end gap-2 pt-2">
|
||||
<Button variant="secondary" size="sm" onClick={() => setShowAddPlan(false)}>取消</Button>
|
||||
<Button size="sm" onClick={handleSave} disabled={savePlanMutation.isPending}>
|
||||
{savePlanMutation.isPending ? '保存中...' : '保存'}
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</Card>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* 批量参保 Modal */}
|
||||
{showEnrollModal && (
|
||||
<Modal open={true} onClose={() => setShowEnrollModal(false)} title="批量参保" size="lg">
|
||||
<div className="space-y-3">
|
||||
<InlineAlert type="info">
|
||||
选择需要参保的员工,设置生效月份后点击「确认参保」。
|
||||
</InlineAlert>
|
||||
<div className="flex items-center gap-2">
|
||||
<Label className="shrink-0">生效月份</Label>
|
||||
<Input type="month" value={enrollEffectiveFrom} onChange={(e) => setEnrollEffectiveFrom(e.target.value)} className="!w-32" />
|
||||
</div>
|
||||
<div className="max-h-80 overflow-y-auto border rounded-md">
|
||||
<table className="w-full text-sm">
|
||||
<thead className="sticky top-0 bg-white">
|
||||
<tr className="border-b text-xs text-gray-500">
|
||||
<th className="py-2 px-3 text-left w-8">
|
||||
<input type="checkbox" checked={enrollEmployeeIds.length === (rosterData?.items?.filter((e: any) => e.status === 'ACTIVE').length || 0) && enrollEmployeeIds.length > 0}
|
||||
onChange={(e) => {
|
||||
if (e.target.checked) {
|
||||
setEnrollEmployeeIds(rosterData?.items?.filter((emp: any) => emp.status === 'ACTIVE').map((emp: any) => emp.id) || [])
|
||||
} else {
|
||||
setEnrollEmployeeIds([])
|
||||
}
|
||||
}} />
|
||||
</th>
|
||||
<th className="py-2 px-3 text-left">姓名</th>
|
||||
<th className="py-2 px-3 text-left">部门</th>
|
||||
<th className="py-2 px-3 text-left">状态</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{rosterData?.items?.filter((e: any) => e.status === 'ACTIVE').map((emp: any) => (
|
||||
<tr key={emp.id} className="border-b last:border-0 hover:bg-gray-50">
|
||||
<td className="py-2 px-3">
|
||||
<input type="checkbox" checked={enrollEmployeeIds.includes(emp.id)}
|
||||
onChange={(e) => {
|
||||
if (e.target.checked) setEnrollEmployeeIds([...enrollEmployeeIds, emp.id])
|
||||
else setEnrollEmployeeIds(enrollEmployeeIds.filter((id) => id !== emp.id))
|
||||
}} />
|
||||
</td>
|
||||
<td className="py-2 px-3 font-medium">{emp.name}</td>
|
||||
<td className="py-2 px-3 text-gray-500">{emp.department}</td>
|
||||
<td className="py-2 px-3">
|
||||
<span className="px-2 py-0.5 rounded text-xs bg-green-50 text-safe">在职</span>
|
||||
</td>
|
||||
</tr>
|
||||
))}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<div className="flex items-center justify-between">
|
||||
<span className="text-xs text-gray-400">已选 {enrollEmployeeIds.length} 人</span>
|
||||
<div className="flex gap-2">
|
||||
<Button variant="secondary" size="sm" onClick={() => setShowEnrollModal(false)}>取消</Button>
|
||||
<Button size="sm" onClick={() => enrollMutation.mutate({ employeeIds: enrollEmployeeIds, effectiveFrom: enrollEffectiveFrom })}
|
||||
disabled={enrollEmployeeIds.length === 0 || enrollMutation.isPending}>
|
||||
{enrollMutation.isPending ? '参保中...' : '确认参保'}
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</Modal>
|
||||
)}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
@@ -11,7 +11,6 @@ import Button from '../components/ui/Button'
|
||||
import { Input, Label } from '../components/ui/Input'
|
||||
import { MonthlyRow, MonthlyHousingRow } from './social-insurance/MonthlyRows'
|
||||
import SpecialDeductionTab from './social-insurance/SpecialDeductionTab'
|
||||
import CommercialInsuranceTab from './social-insurance/CommercialInsuranceTab'
|
||||
|
||||
// 金额格式化:保留两位小数 + 千分位
|
||||
const fmt = (n: number) => (n || 0).toLocaleString('zh-CN', { minimumFractionDigits: 2, maximumFractionDigits: 2 })
|
||||
@@ -19,7 +18,7 @@ const fmt = (n: number) => (n || 0).toLocaleString('zh-CN', { minimumFractionDig
|
||||
export default function SocialInsurance() {
|
||||
const queryClient = useQueryClient()
|
||||
const confirm = useConfirm()
|
||||
const [tab, setTab] = useState<'monthly' | 'social' | 'housing' | 'deduction' | 'commercial'>('monthly')
|
||||
const [tab, setTab] = useState<'monthly' | 'social' | 'housing' | 'deduction'>('monthly')
|
||||
const [city, setCity] = useState<string>('北京')
|
||||
const [showAddCity, setShowAddCity] = useState(false)
|
||||
const [newCityName, setNewCityName] = useState('')
|
||||
@@ -367,7 +366,7 @@ export default function SocialInsurance() {
|
||||
|
||||
{/* Tab 切换 + 城市选择 */}
|
||||
<div className="flex items-center gap-4 border-b">
|
||||
{(['monthly', 'social', 'housing', 'deduction', 'commercial'] as const).map((t) => (
|
||||
{(['monthly', 'social', 'housing', 'deduction'] as const).map((t) => (
|
||||
<button
|
||||
key={t}
|
||||
className={`px-4 py-2 text-sm font-medium border-b-2 transition-colors ${
|
||||
@@ -375,7 +374,7 @@ export default function SocialInsurance() {
|
||||
}`}
|
||||
onClick={() => { setTab(t); setShowVersions(false); setShowNewVersion(false); setShowAdjust(false); setAdjustData(null); setEditItems({}); setEditingId(null); setMonthlyProcessed(false); setProcessStatus(null) }}
|
||||
>
|
||||
{t === 'monthly' ? '月度办理' : t === 'social' ? '社保' : t === 'housing' ? '公积金' : t === 'deduction' ? '专项附加扣除' : '商险管理'}
|
||||
{t === 'monthly' ? '月度办理' : t === 'social' ? '社保' : t === 'housing' ? '公积金' : '专项附加扣除'}
|
||||
</button>
|
||||
))}
|
||||
{(tab === 'social' || tab === 'housing') && (
|
||||
@@ -1148,11 +1147,6 @@ export default function SocialInsurance() {
|
||||
<SpecialDeductionTab month={deductionMonth} setMonth={setDeductionMonth} />
|
||||
)}
|
||||
|
||||
{/* ========== 商险管理 Tab ========== */}
|
||||
<div className={tab === 'commercial' ? '' : 'hidden'}>
|
||||
<CommercialInsuranceTab />
|
||||
</div>
|
||||
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user