fix: 5个获取操作 onSuccess 修复 res.data 多余层级

unwrap 已提取 data 字段,res 本身就是 { filled, message, ... }
之前 res.data?.filled 永远为 undefined,导致显示'无数据'
This commit is contained in:
freedakgmail
2026-08-19 08:08:12 +08:00
parent 8388672c40
commit 2f9fa8b5df
+25 -25
View File
@@ -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: () => {