diff --git a/frontend/src/pages/SocialInsurance.tsx b/frontend/src/pages/SocialInsurance.tsx index 90971e0..ecd3875 100644 --- a/frontend/src/pages/SocialInsurance.tsx +++ b/frontend/src/pages/SocialInsurance.tsx @@ -1144,22 +1144,35 @@ function SpecialDeductionTab({ month, setMonth }: { month: string; setMonth: (m: } : { children: 0, elderly: 0, housing: 0, education: 0, infant: 0, remark: '' }) } - /** 复制上月数据到编辑表单 */ - const copyFromPrevMonth = (empId: string) => { - const prev = prevRecordMap.get(empId) - if (prev) { - setEditForm({ - children: prev.children || 0, - elderly: prev.elderly || 0, - housing: prev.housing || 0, - education: prev.education || 0, - infant: prev.infant || 0, - remark: prev.remark || '', - }) - } else { - toast.info(`${prevMonth} 无该员工的扣除记录`) - } - } + /** 批量复制上月数据到当月 */ + const batchCopyMutation = useMutation({ + mutationFn: async () => { + let copied = 0 + for (const prev of prevRecords) { + await api.post('/social/special-deduction', { + employeeId: prev.employeeId, + month, + children: prev.children || 0, + elderly: prev.elderly || 0, + housing: prev.housing || 0, + education: prev.education || 0, + infant: prev.infant || 0, + remark: prev.remark || '', + }) + copied++ + } + return copied + }, + onSuccess: (copied: number) => { + queryClient.invalidateQueries({ queryKey: ['special-deduction'] }) + if (copied > 0) { + toast.success(`已复制 ${copied} 条 ${prevMonth} 的扣除数据到 ${month}`) + } else { + toast.info(`${prevMonth} 无可复制的扣除数据`) + } + }, + onError: () => toast.error('复制上月数据失败'), + }) const calcTotal = (f: any) => (f.children || 0) + (f.elderly || 0) + (f.housing || 0) + (f.education || 0) + (f.infant || 0) @@ -1167,7 +1180,17 @@ function SpecialDeductionTab({ month, setMonth }: { month: string; setMonth: (m:

专项附加扣除 — {month}

- setMonth(e.target.value)} className="!w-32" /> +
+ + setMonth(e.target.value)} className="!w-32" /> +
{isLoading ? ( @@ -1209,7 +1232,6 @@ function SpecialDeductionTab({ month, setMonth }: { month: string; setMonth: (m:
-
@@ -1270,7 +1292,6 @@ function SpecialDeductionTab({ month, setMonth }: { month: string; setMonth: (m:
-