fix: 5个获取操作 onSuccess 修复 res.data 多余层级
unwrap 已提取 data 字段,res 本身就是 { filled, message, ... }
之前 res.data?.filled 永远为 undefined,导致显示'无数据'
This commit is contained in:
@@ -564,8 +564,8 @@ function BatchDetail({ batchId, onBack }: { batchId: string; onBack: () => void
|
|||||||
const importOvertimeMutation = useMutation({
|
const importOvertimeMutation = useMutation({
|
||||||
mutationFn: (force?: boolean) => payrollApi.importOvertimeToBatch(batchId, force),
|
mutationFn: (force?: boolean) => payrollApi.importOvertimeToBatch(batchId, force),
|
||||||
onSuccess: async (res: any) => {
|
onSuccess: async (res: any) => {
|
||||||
if (res.data?.needConfirm) {
|
if (res?.needConfirm) {
|
||||||
if (await confirm({ title: '跨批次重复提醒', message: res.data.message, variant: 'primary' })) {
|
if (await confirm({ title: '跨批次重复提醒', message: res.message, variant: 'primary' })) {
|
||||||
importOvertimeMutation.mutate(true)
|
importOvertimeMutation.mutate(true)
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
@@ -573,10 +573,10 @@ function BatchDetail({ batchId, onBack }: { batchId: string; onBack: () => void
|
|||||||
queryClient.invalidateQueries({ queryKey: ['batch-detail'] })
|
queryClient.invalidateQueries({ queryKey: ['batch-detail'] })
|
||||||
queryClient.invalidateQueries({ queryKey: ['batches'] })
|
queryClient.invalidateQueries({ queryKey: ['batches'] })
|
||||||
queryClient.invalidateQueries({ queryKey: ['overtime-records'] })
|
queryClient.invalidateQueries({ queryKey: ['overtime-records'] })
|
||||||
if (res.data?.imported > 0) {
|
if (res?.imported > 0) {
|
||||||
toast.success(`成功获取 ${res.data.imported} 条加班费记录`)
|
toast.success(`成功获取 ${res.imported} 条加班费记录`)
|
||||||
} else {
|
} else {
|
||||||
toast.info(res.data?.message || '没有可获取的加班记录')
|
toast.info(res?.message || '没有可获取的加班记录')
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
onError: () => {
|
onError: () => {
|
||||||
@@ -587,18 +587,18 @@ function BatchDetail({ batchId, onBack }: { batchId: string; onBack: () => void
|
|||||||
const fetchBonusMutation = useMutation({
|
const fetchBonusMutation = useMutation({
|
||||||
mutationFn: (force?: boolean) => payrollApi.fetchBonusToBatch(batchId, force),
|
mutationFn: (force?: boolean) => payrollApi.fetchBonusToBatch(batchId, force),
|
||||||
onSuccess: async (res: any) => {
|
onSuccess: async (res: any) => {
|
||||||
if (res.data?.needConfirm) {
|
if (res?.needConfirm) {
|
||||||
if (await confirm({ title: '跨批次重复提醒', message: res.data.message, variant: 'primary' })) {
|
if (await confirm({ title: '跨批次重复提醒', message: res.message, variant: 'primary' })) {
|
||||||
fetchBonusMutation.mutate(true)
|
fetchBonusMutation.mutate(true)
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
queryClient.invalidateQueries({ queryKey: ['batch-detail'] })
|
queryClient.invalidateQueries({ queryKey: ['batch-detail'] })
|
||||||
queryClient.invalidateQueries({ queryKey: ['batches'] })
|
queryClient.invalidateQueries({ queryKey: ['batches'] })
|
||||||
if (res.data?.filled > 0) {
|
if (res?.filled > 0) {
|
||||||
toast.success(res.data.message)
|
toast.success(res.message)
|
||||||
} else {
|
} else {
|
||||||
toast.info(res.data?.message || '无提成奖金数据')
|
toast.info(res?.message || '无提成奖金数据')
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
onError: () => {
|
onError: () => {
|
||||||
@@ -609,18 +609,18 @@ function BatchDetail({ batchId, onBack }: { batchId: string; onBack: () => void
|
|||||||
const fetchPerformanceMutation = useMutation({
|
const fetchPerformanceMutation = useMutation({
|
||||||
mutationFn: (force?: boolean) => payrollApi.fetchPerformanceToBatch(batchId, force),
|
mutationFn: (force?: boolean) => payrollApi.fetchPerformanceToBatch(batchId, force),
|
||||||
onSuccess: async (res: any) => {
|
onSuccess: async (res: any) => {
|
||||||
if (res.data?.needConfirm) {
|
if (res?.needConfirm) {
|
||||||
if (await confirm({ title: '跨批次重复提醒', message: res.data.message, variant: 'primary' })) {
|
if (await confirm({ title: '跨批次重复提醒', message: res.message, variant: 'primary' })) {
|
||||||
fetchPerformanceMutation.mutate(true)
|
fetchPerformanceMutation.mutate(true)
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
queryClient.invalidateQueries({ queryKey: ['batch-detail'] })
|
queryClient.invalidateQueries({ queryKey: ['batch-detail'] })
|
||||||
queryClient.invalidateQueries({ queryKey: ['batches'] })
|
queryClient.invalidateQueries({ queryKey: ['batches'] })
|
||||||
if (res.data?.filled > 0) {
|
if (res?.filled > 0) {
|
||||||
toast.success(res.data.message)
|
toast.success(res.message)
|
||||||
} else {
|
} else {
|
||||||
toast.info(res.data?.message || '无绩效工资数据')
|
toast.info(res?.message || '无绩效工资数据')
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
onError: () => {
|
onError: () => {
|
||||||
@@ -631,18 +631,18 @@ function BatchDetail({ batchId, onBack }: { batchId: string; onBack: () => void
|
|||||||
const fetchDisciplinaryMutation = useMutation({
|
const fetchDisciplinaryMutation = useMutation({
|
||||||
mutationFn: (force?: boolean) => payrollApi.fetchDisciplinaryToBatch(batchId, force),
|
mutationFn: (force?: boolean) => payrollApi.fetchDisciplinaryToBatch(batchId, force),
|
||||||
onSuccess: async (res: any) => {
|
onSuccess: async (res: any) => {
|
||||||
if (res.data?.needConfirm) {
|
if (res?.needConfirm) {
|
||||||
if (await confirm({ title: '跨批次重复提醒', message: res.data.message, variant: 'primary' })) {
|
if (await confirm({ title: '跨批次重复提醒', message: res.message, variant: 'primary' })) {
|
||||||
fetchDisciplinaryMutation.mutate(true)
|
fetchDisciplinaryMutation.mutate(true)
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
queryClient.invalidateQueries({ queryKey: ['batch-detail'] })
|
queryClient.invalidateQueries({ queryKey: ['batch-detail'] })
|
||||||
queryClient.invalidateQueries({ queryKey: ['batches'] })
|
queryClient.invalidateQueries({ queryKey: ['batches'] })
|
||||||
if (res.data?.filled > 0) {
|
if (res?.filled > 0) {
|
||||||
toast.success(res.data.message)
|
toast.success(res.message)
|
||||||
} else {
|
} else {
|
||||||
toast.info(res.data?.message || '无违纪扣款数据')
|
toast.info(res?.message || '无违纪扣款数据')
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
onError: () => {
|
onError: () => {
|
||||||
@@ -653,18 +653,18 @@ function BatchDetail({ batchId, onBack }: { batchId: string; onBack: () => void
|
|||||||
const fetchAttendanceDeductionMutation = useMutation({
|
const fetchAttendanceDeductionMutation = useMutation({
|
||||||
mutationFn: (force?: boolean) => payrollApi.fetchAttendanceDeductionToBatch(batchId, force),
|
mutationFn: (force?: boolean) => payrollApi.fetchAttendanceDeductionToBatch(batchId, force),
|
||||||
onSuccess: async (res: any) => {
|
onSuccess: async (res: any) => {
|
||||||
if (res.data?.needConfirm) {
|
if (res?.needConfirm) {
|
||||||
if (await confirm({ title: '跨批次重复提醒', message: res.data.message, variant: 'primary' })) {
|
if (await confirm({ title: '跨批次重复提醒', message: res.message, variant: 'primary' })) {
|
||||||
fetchAttendanceDeductionMutation.mutate(true)
|
fetchAttendanceDeductionMutation.mutate(true)
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
queryClient.invalidateQueries({ queryKey: ['batch-detail'] })
|
queryClient.invalidateQueries({ queryKey: ['batch-detail'] })
|
||||||
queryClient.invalidateQueries({ queryKey: ['batches'] })
|
queryClient.invalidateQueries({ queryKey: ['batches'] })
|
||||||
if (res.data?.filled > 0) {
|
if (res?.filled > 0) {
|
||||||
toast.success(res.data.message)
|
toast.success(res.message)
|
||||||
} else {
|
} else {
|
||||||
toast.info(res.data?.message || '无考勤扣款数据')
|
toast.info(res?.message || '无考勤扣款数据')
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
onError: () => {
|
onError: () => {
|
||||||
|
|||||||
Reference in New Issue
Block a user