diff --git a/frontend/src/pages/SocialInsurance.tsx b/frontend/src/pages/SocialInsurance.tsx index 2ec33e3..90971e0 100644 --- a/frontend/src/pages/SocialInsurance.tsx +++ b/frontend/src/pages/SocialInsurance.tsx @@ -1105,6 +1105,21 @@ function SpecialDeductionTab({ month, setMonth }: { month: string; setMonth: (m: }, }) + // 查询上月专项附加扣除数据(用于「复制上月」功能) + const prevMonth = (() => { + const [y, m] = month.split('-').map(Number) + const d = new Date(y, m - 2, 1) + return `${d.getFullYear()}-${String(d.getMonth() + 1).padStart(2, '0')}` + })() + const { data: prevRecords = [] } = useQuery({ + queryKey: ['special-deduction', prevMonth], + queryFn: async () => { + const res = await api.get('/social/special-deduction/batch', { params: { month: prevMonth } }) as any + return res.data || [] + }, + }) + const prevRecordMap = new Map(prevRecords.map((r: any) => [r.employeeId, r])) + const saveMutation = useMutation({ mutationFn: (data: any) => api.post('/social/special-deduction', { ...data, month }), onSuccess: () => { @@ -1129,6 +1144,23 @@ 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 calcTotal = (f: any) => (f.children || 0) + (f.elderly || 0) + (f.housing || 0) + (f.education || 0) + (f.infant || 0) return ( @@ -1177,6 +1209,7 @@ function SpecialDeductionTab({ month, setMonth }: { month: string; setMonth: (m:
+
@@ -1237,6 +1270,7 @@ function SpecialDeductionTab({ month, setMonth }: { month: string; setMonth: (m:
+