diff --git a/apps/web-antd/src/views/product/batch/composables/useProductBatchPage.ts b/apps/web-antd/src/views/product/batch/composables/useProductBatchPage.ts index c838d04..8945381 100644 --- a/apps/web-antd/src/views/product/batch/composables/useProductBatchPage.ts +++ b/apps/web-antd/src/views/product/batch/composables/useProductBatchPage.ts @@ -1,4 +1,4 @@ -import { computed, onMounted, ref, watch } from 'vue'; +import { computed, onActivated, onMounted, ref, watch } from 'vue'; import type { StoreListItemDto } from '#/api/store'; @@ -171,6 +171,10 @@ export function useProductBatchPage() { importFile.value = file; } + async function ensureStoresLoaded() { + await loadStores(); + } + watch(selectedStoreId, () => { scopeType.value = 'all'; scopeCategoryIds.value = []; @@ -190,11 +194,11 @@ export function useProductBatchPage() { }); watch([scopeType, scopeCategoryIds, scopeProductIds], () => { - if (scopeType.value !== 'category') { + if (scopeType.value !== 'category' && scopeCategoryIds.value.length > 0) { scopeCategoryIds.value = []; } - if (scopeType.value !== 'manual') { + if (scopeType.value !== 'manual' && scopeProductIds.value.length > 0) { scopeProductIds.value = []; } }); @@ -205,7 +209,15 @@ export function useProductBatchPage() { } }); - onMounted(loadStores); + onMounted(() => { + void ensureStoresLoaded(); + }); + + onActivated(() => { + if (stores.value.length === 0 || !selectedStoreId.value) { + void ensureStoresLoaded(); + } + }); return { activeTool, diff --git a/apps/web-antd/src/views/product/batch/index.vue b/apps/web-antd/src/views/product/batch/index.vue index ec1e1c5..c903d9f 100644 --- a/apps/web-antd/src/views/product/batch/index.vue +++ b/apps/web-antd/src/views/product/batch/index.vue @@ -1,7 +1,7 @@