diff --git a/backend/src/routes/payroll2.routes.ts b/backend/src/routes/payroll2.routes.ts index be95b52..b3ae314 100644 --- a/backend/src/routes/payroll2.routes.ts +++ b/backend/src/routes/payroll2.routes.ts @@ -520,15 +520,15 @@ router.post('/batches', async (req: AuthRequest, res: Response, next: NextFuncti // 编辑批次条目(计算依据项 + 社保公积金手动覆盖) const updateEntrySchema = z.object({ - baseSalary: z.number().min(0).optional(), - overtimePay: z.number().min(0).optional(), - allowance: z.number().min(0).optional(), - deduction: z.number().min(0).optional(), - bonus: z.number().min(0).optional(), - socialEmp: z.number().min(0).optional(), - socialOrg: z.number().min(0).optional(), - housingEmp: z.number().min(0).optional(), - housingOrg: z.number().min(0).optional(), + baseSalary: z.number().optional(), + overtimePay: z.number().optional(), + allowance: z.number().optional(), + deduction: z.number().optional(), + bonus: z.number().optional(), + socialEmp: z.number().optional(), + socialOrg: z.number().optional(), + housingEmp: z.number().optional(), + housingOrg: z.number().optional(), }) router.put('/batches/:batchId/entries/:employeeId', async (req: AuthRequest, res: Response, next: NextFunction) => { @@ -546,13 +546,21 @@ router.put('/batches/:batchId/entries/:employeeId', async (req: AuthRequest, res }) if (!entry) return res.status(404).json({ success: false, error: { code: 'NOT_FOUND', message: '条目不存在' } }) - // 合并输入项 + // 合并输入项(包含细化薪资字段,避免编辑时丢失岗位工资/绩效工资等) const inputs = { baseSalary: data.baseSalary ?? entry.baseSalary, overtimePay: data.overtimePay ?? entry.overtimePay, allowance: data.allowance ?? entry.allowance, deduction: data.deduction ?? entry.deduction, bonus: data.bonus ?? entry.bonus, + positionSalary: entry.positionSalary || undefined, + performanceSalary: entry.performanceSalary || undefined, + senioritySalary: entry.senioritySalary || undefined, + transportAllowance: entry.transportAllowance || undefined, + mealAllowance: entry.mealAllowance || undefined, + housingAllowance: entry.housingAllowance || undefined, + communicationAllowance: entry.communicationAllowance || undefined, + otherDeduction: entry.otherDeduction || undefined, } // 构建社保覆盖参数(如果请求中包含社保字段)