From 67ebb2b26f50899b5429b1dab7e034d0999c8f89 Mon Sep 17 00:00:00 2001 From: selfrelease Date: Mon, 27 Jul 2026 19:53:19 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E4=B8=93=E9=A1=B9=E9=99=84=E5=8A=A0?= =?UTF-8?q?=E6=89=A3=E9=99=A4=E6=94=B9=E4=B8=BA=E6=89=B9=E9=87=8F=E5=A4=8D?= =?UTF-8?q?=E5=88=B6=E4=B8=8A=E6=9C=88=E6=89=80=E6=9C=89=E4=BA=BA=E7=9A=84?= =?UTF-8?q?=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/src/pages/SocialInsurance.tsx | 59 +++++++++++++++++--------- 1 file changed, 40 insertions(+), 19 deletions(-) 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:
-