feat: idCardHash匹配、Roster分页过滤、社保基数调整修复、Modal size支持、Termination版本对比、UI优化
This commit is contained in:
@@ -0,0 +1,52 @@
|
||||
import { Router, Response } from 'express'
|
||||
import { authMiddleware, AuthRequest } from '../middleware/auth'
|
||||
import prisma from '../lib/prisma'
|
||||
import { decrypt } from '../lib/crypto'
|
||||
|
||||
const router = Router()
|
||||
|
||||
router.get('/all', authMiddleware, async (req: AuthRequest, res: Response, next) => {
|
||||
try {
|
||||
const orgId = req.user!.orgId
|
||||
|
||||
const [employees, contracts, terminations, payrollBatches, payslips, socialRecords, housingRecords, riskItems] = await Promise.all([
|
||||
prisma.employee.findMany({ where: { orgId } }),
|
||||
prisma.laborContract.findMany({ where: { orgId } }),
|
||||
prisma.terminationRecord.findMany({ where: { orgId } }),
|
||||
prisma.payrollBatch.findMany({ where: { orgId } }),
|
||||
prisma.payslip.findMany({ where: { orgId } }),
|
||||
prisma.employeeSocialInsRecord.findMany({ where: { orgId } }),
|
||||
prisma.employeeHousingFundRecord.findMany({ where: { orgId } }),
|
||||
prisma.riskItem.findMany({ where: { orgId } }),
|
||||
])
|
||||
|
||||
const safeEmployees = employees.map((e) => {
|
||||
let salary = 0
|
||||
try { salary = Number(decrypt(e.monthlySalary)) || 0 } catch { salary = Number(e.monthlySalary) || 0 }
|
||||
let idCard = null
|
||||
try { if (e.idCardNumber) idCard = decrypt(e.idCardNumber) } catch { idCard = e.idCardNumber }
|
||||
return { ...e, monthlySalary: salary, idCardNumber: idCard }
|
||||
})
|
||||
|
||||
const data = {
|
||||
exportedAt: new Date().toISOString(),
|
||||
orgId,
|
||||
employees: safeEmployees,
|
||||
contracts,
|
||||
terminations,
|
||||
payrollBatches,
|
||||
payslips,
|
||||
socialRecords,
|
||||
housingRecords,
|
||||
riskItems,
|
||||
}
|
||||
|
||||
res.setHeader('Content-Type', 'application/json')
|
||||
res.setHeader('Content-Disposition', `attachment; filename="export-${new Date().toISOString().slice(0, 10)}.json"`)
|
||||
res.json(data)
|
||||
} catch (err) {
|
||||
next(err)
|
||||
}
|
||||
})
|
||||
|
||||
export default router
|
||||
Reference in New Issue
Block a user