优化: 大文件拆分+代码分割+按需加载+console清理+any类型替换
- Money.tsx (2260行→54行): 拆分为 money/ 子目录4个组件, React.lazy二级分割 - AIAssistant.tsx (2038行→63行): 拆分为 ai-assistant/ 子目录6个组件, React.lazy二级分割 - xlsx改为动态导入, OvertimeTab从345KB降至12.7KB - api-services.ts: 请求参数 any→Record<string,unknown> - 移除前端3处console.log残留 - 后端console替换为pino logger - 前后端未使用import/变量清理 - Zod schema验证: termination/platform/special-status/work-process - 新增 leave.routes.ts, acceptance-test.routes.ts - UI组件: PageGuide, QueryError, Stepper
This commit is contained in:
@@ -1,8 +1,7 @@
|
||||
import prisma from '../lib/prisma'
|
||||
import { encrypt } from '../lib/crypto'
|
||||
import crypto from 'crypto'
|
||||
import { createDraft as createTerminationDraft, executeTermination, createResignation } from './termination.service'
|
||||
import { createEmployee, addContract, batchRenew } from './contract.service'
|
||||
import { createDraft as createTerminationDraft, executeTermination } from './termination.service'
|
||||
import { createEmployee, addContract } from './contract.service'
|
||||
import { runRiskDetection } from './risk.service'
|
||||
|
||||
// 13类流程定义
|
||||
@@ -67,7 +66,7 @@ export async function executeWorkProcess(processId: string, type: string, formDa
|
||||
return { employeeId }
|
||||
}
|
||||
case 'CONFIRM': {
|
||||
const { employeeId, confirmDate, regularSalary } = formData
|
||||
const { employeeId, regularSalary } = formData
|
||||
if (employeeId) {
|
||||
if (regularSalary) {
|
||||
await prisma.employee.update({
|
||||
@@ -196,7 +195,7 @@ export async function executeWorkProcess(processId: string, type: string, formDa
|
||||
return {}
|
||||
}
|
||||
case 'FLEXIBLE': {
|
||||
const { name, phone, idCardNumber, department, agreementStartDate, agreementEndDate, payMethod } = formData
|
||||
const { name, phone, idCardNumber, department, agreementStartDate, agreementEndDate } = formData
|
||||
const empResult = await createEmployee(orgId, userId, {
|
||||
name,
|
||||
department: department || '灵活用工',
|
||||
@@ -244,7 +243,23 @@ export async function executeWorkProcess(processId: string, type: string, formDa
|
||||
}
|
||||
|
||||
// 生成文书预览
|
||||
export function generateDocument(type: string, formData: any, orgName: string): { name: string; content: string } {
|
||||
export async function generateDocument(type: string, formData: any, orgName: string): Promise<{ name: string; content: string }> {
|
||||
// 如果指定了企业自定义模板,使用企业模板渲染
|
||||
if (formData.enterpriseTemplateId) {
|
||||
const tpl = await (prisma as any).enterpriseTemplate.findFirst({
|
||||
where: { id: formData.enterpriseTemplateId },
|
||||
})
|
||||
if (tpl) {
|
||||
let content = tpl.content
|
||||
// 替换变量 {{var}}
|
||||
const allVars: Record<string, string> = { ...formData, companyName: orgName }
|
||||
for (const [key, value] of Object.entries(allVars)) {
|
||||
content = content.replace(new RegExp(`\\{\\{${key}\\}\\}`, 'g'), String(value ?? ''))
|
||||
}
|
||||
return { name: `${tpl.name}.doc`, content }
|
||||
}
|
||||
}
|
||||
|
||||
const templates: Record<string, (data: any, org: string) => string> = {
|
||||
INCOME_CERT: (data, org) => `收入证明
|
||||
|
||||
|
||||
Reference in New Issue
Block a user