fix(consignment): 发布后即时刷新寄卖数量上限占用

This commit is contained in:
2026-11-08 11:22:55 +08:00
parent ffe7c31a87
commit caa2358bbd
2 changed files with 58 additions and 6 deletions
@@ -198,11 +198,11 @@ export default function WorkerConsignmentPage() {
}),
})
// 已发布的分类寄卖配置 → 打手端动态 tab
// 已发布的分类寄卖配置 → 打手端动态 tab。
// activeQuantity(在售+待审核占用)是动态值:不设 staleTime,进入页面/窗口聚焦都拉最新。
const consignmentProfilesQuery = useQuery({
queryKey: ['worker-consignment-profiles'],
queryFn: () => fetchWorkerConsignmentProfiles(),
staleTime: 60_000,
})
const consignmentProfiles = consignmentProfilesQuery.data?.data.profiles || []
const selectedProfile: WorkerConsignmentProfile | null =
@@ -247,10 +247,12 @@ export default function WorkerConsignmentPage() {
const contactSupporters = consignmentContactsQuery.data?.data.items || []
const firstContactSupporterId = contactSupporters[0]?.id ?? null
// 切换标签页时自动刷新最新数据
// 切换标签页时自动刷新最新数据;回到发布页时同步刷新各分类占用(activeQuantity)
useEffect(() => {
if (activeTab === 'records') {
void queryClient.invalidateQueries({ queryKey: ['worker-my-consignments'] })
} else {
void queryClient.invalidateQueries({ queryKey: ['worker-consignment-profiles'] })
}
void queryClient.invalidateQueries({ queryKey: ['worker-profile'] })
}, [activeTab, queryClient])
@@ -586,7 +588,12 @@ export default function WorkerConsignmentPage() {
setPriceState({ status: 'idle' })
lastPriceQueryKeyRef.current = ''
setIntakeImages({})
await Promise.all([myConsignmentsQuery.refetch(), profileQuery.refetch()])
await Promise.all([
myConsignmentsQuery.refetch(),
profileQuery.refetch(),
// 发布后立即刷新各分类占用,否则同一页面连续发布仍显示发布前的剩余额度
consignmentProfilesQuery.refetch(),
])
setRecordFilter('reviewing')
setActiveTab('records')
} catch (err: any) {
@@ -1123,8 +1130,10 @@ export default function WorkerConsignmentPage() {
<div className="worker-orders-header-right">
<Button
icon={<ReloadOutlined />}
loading={myConsignmentsQuery.isFetching}
onClick={() => myConsignmentsQuery.refetch()}
loading={myConsignmentsQuery.isFetching || consignmentProfilesQuery.isFetching}
onClick={() =>
Promise.all([myConsignmentsQuery.refetch(), consignmentProfilesQuery.refetch()])
}
>
刷新
</Button>