From 2f9fa8b5dfc118d06824d152c0e749af3c95d5e0 Mon Sep 17 00:00:00 2001 From: freedakgmail Date: Wed, 19 Aug 2026 08:08:12 +0800 Subject: [PATCH] =?UTF-8?q?fix:=205=E4=B8=AA=E8=8E=B7=E5=8F=96=E6=93=8D?= =?UTF-8?q?=E4=BD=9C=20onSuccess=20=E4=BF=AE=E5=A4=8D=20res.data=20?= =?UTF-8?q?=E5=A4=9A=E4=BD=99=E5=B1=82=E7=BA=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit unwrap 已提取 data 字段,res 本身就是 { filled, message, ... } 之前 res.data?.filled 永远为 undefined,导致显示'无数据' --- frontend/src/pages/money/BatchTab.tsx | 50 +++++++++++++-------------- 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/frontend/src/pages/money/BatchTab.tsx b/frontend/src/pages/money/BatchTab.tsx index 3f6a1ea..b12efcb 100644 --- a/frontend/src/pages/money/BatchTab.tsx +++ b/frontend/src/pages/money/BatchTab.tsx @@ -564,8 +564,8 @@ function BatchDetail({ batchId, onBack }: { batchId: string; onBack: () => void const importOvertimeMutation = useMutation({ mutationFn: (force?: boolean) => payrollApi.importOvertimeToBatch(batchId, force), onSuccess: async (res: any) => { - if (res.data?.needConfirm) { - if (await confirm({ title: '跨批次重复提醒', message: res.data.message, variant: 'primary' })) { + if (res?.needConfirm) { + if (await confirm({ title: '跨批次重复提醒', message: res.message, variant: 'primary' })) { importOvertimeMutation.mutate(true) } return @@ -573,10 +573,10 @@ function BatchDetail({ batchId, onBack }: { batchId: string; onBack: () => void queryClient.invalidateQueries({ queryKey: ['batch-detail'] }) queryClient.invalidateQueries({ queryKey: ['batches'] }) queryClient.invalidateQueries({ queryKey: ['overtime-records'] }) - if (res.data?.imported > 0) { - toast.success(`成功获取 ${res.data.imported} 条加班费记录`) + if (res?.imported > 0) { + toast.success(`成功获取 ${res.imported} 条加班费记录`) } else { - toast.info(res.data?.message || '没有可获取的加班记录') + toast.info(res?.message || '没有可获取的加班记录') } }, onError: () => { @@ -587,18 +587,18 @@ function BatchDetail({ batchId, onBack }: { batchId: string; onBack: () => void const fetchBonusMutation = useMutation({ mutationFn: (force?: boolean) => payrollApi.fetchBonusToBatch(batchId, force), onSuccess: async (res: any) => { - if (res.data?.needConfirm) { - if (await confirm({ title: '跨批次重复提醒', message: res.data.message, variant: 'primary' })) { + if (res?.needConfirm) { + if (await confirm({ title: '跨批次重复提醒', message: res.message, variant: 'primary' })) { fetchBonusMutation.mutate(true) } return } queryClient.invalidateQueries({ queryKey: ['batch-detail'] }) queryClient.invalidateQueries({ queryKey: ['batches'] }) - if (res.data?.filled > 0) { - toast.success(res.data.message) + if (res?.filled > 0) { + toast.success(res.message) } else { - toast.info(res.data?.message || '无提成奖金数据') + toast.info(res?.message || '无提成奖金数据') } }, onError: () => { @@ -609,18 +609,18 @@ function BatchDetail({ batchId, onBack }: { batchId: string; onBack: () => void const fetchPerformanceMutation = useMutation({ mutationFn: (force?: boolean) => payrollApi.fetchPerformanceToBatch(batchId, force), onSuccess: async (res: any) => { - if (res.data?.needConfirm) { - if (await confirm({ title: '跨批次重复提醒', message: res.data.message, variant: 'primary' })) { + if (res?.needConfirm) { + if (await confirm({ title: '跨批次重复提醒', message: res.message, variant: 'primary' })) { fetchPerformanceMutation.mutate(true) } return } queryClient.invalidateQueries({ queryKey: ['batch-detail'] }) queryClient.invalidateQueries({ queryKey: ['batches'] }) - if (res.data?.filled > 0) { - toast.success(res.data.message) + if (res?.filled > 0) { + toast.success(res.message) } else { - toast.info(res.data?.message || '无绩效工资数据') + toast.info(res?.message || '无绩效工资数据') } }, onError: () => { @@ -631,18 +631,18 @@ function BatchDetail({ batchId, onBack }: { batchId: string; onBack: () => void const fetchDisciplinaryMutation = useMutation({ mutationFn: (force?: boolean) => payrollApi.fetchDisciplinaryToBatch(batchId, force), onSuccess: async (res: any) => { - if (res.data?.needConfirm) { - if (await confirm({ title: '跨批次重复提醒', message: res.data.message, variant: 'primary' })) { + if (res?.needConfirm) { + if (await confirm({ title: '跨批次重复提醒', message: res.message, variant: 'primary' })) { fetchDisciplinaryMutation.mutate(true) } return } queryClient.invalidateQueries({ queryKey: ['batch-detail'] }) queryClient.invalidateQueries({ queryKey: ['batches'] }) - if (res.data?.filled > 0) { - toast.success(res.data.message) + if (res?.filled > 0) { + toast.success(res.message) } else { - toast.info(res.data?.message || '无违纪扣款数据') + toast.info(res?.message || '无违纪扣款数据') } }, onError: () => { @@ -653,18 +653,18 @@ function BatchDetail({ batchId, onBack }: { batchId: string; onBack: () => void const fetchAttendanceDeductionMutation = useMutation({ mutationFn: (force?: boolean) => payrollApi.fetchAttendanceDeductionToBatch(batchId, force), onSuccess: async (res: any) => { - if (res.data?.needConfirm) { - if (await confirm({ title: '跨批次重复提醒', message: res.data.message, variant: 'primary' })) { + if (res?.needConfirm) { + if (await confirm({ title: '跨批次重复提醒', message: res.message, variant: 'primary' })) { fetchAttendanceDeductionMutation.mutate(true) } return } queryClient.invalidateQueries({ queryKey: ['batch-detail'] }) queryClient.invalidateQueries({ queryKey: ['batches'] }) - if (res.data?.filled > 0) { - toast.success(res.data.message) + if (res?.filled > 0) { + toast.success(res.message) } else { - toast.info(res.data?.message || '无考勤扣款数据') + toast.info(res?.message || '无考勤扣款数据') } }, onError: () => {