fix: 修复批量工具首开门店状态异常
All checks were successful
Build and Deploy TenantUI / build-and-deploy (push) Successful in 50s

This commit is contained in:
2026-02-26 12:34:19 +08:00
parent 00643eae56
commit 5ec724188e
2 changed files with 22 additions and 6 deletions

View File

@@ -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'; import type { StoreListItemDto } from '#/api/store';
@@ -171,6 +171,10 @@ export function useProductBatchPage() {
importFile.value = file; importFile.value = file;
} }
async function ensureStoresLoaded() {
await loadStores();
}
watch(selectedStoreId, () => { watch(selectedStoreId, () => {
scopeType.value = 'all'; scopeType.value = 'all';
scopeCategoryIds.value = []; scopeCategoryIds.value = [];
@@ -190,11 +194,11 @@ export function useProductBatchPage() {
}); });
watch([scopeType, scopeCategoryIds, scopeProductIds], () => { watch([scopeType, scopeCategoryIds, scopeProductIds], () => {
if (scopeType.value !== 'category') { if (scopeType.value !== 'category' && scopeCategoryIds.value.length > 0) {
scopeCategoryIds.value = []; scopeCategoryIds.value = [];
} }
if (scopeType.value !== 'manual') { if (scopeType.value !== 'manual' && scopeProductIds.value.length > 0) {
scopeProductIds.value = []; 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 { return {
activeTool, activeTool,

View File

@@ -1,7 +1,7 @@
<script setup lang="ts"> <script setup lang="ts">
import { Page } from '@vben/common-ui'; import { Page } from '@vben/common-ui';
import { Alert, Empty } from 'ant-design-vue'; import { Alert, Empty, Spin } from 'ant-design-vue';
import BatchImportExportPanel from './components/BatchImportExportPanel.vue'; import BatchImportExportPanel from './components/BatchImportExportPanel.vue';
import BatchMoveCategoryPanel from './components/BatchMoveCategoryPanel.vue'; import BatchMoveCategoryPanel from './components/BatchMoveCategoryPanel.vue';
@@ -131,7 +131,11 @@ function updateExportCategoryIds(value: string[]) {
@update:selected-store-id="setSelectedStoreId" @update:selected-store-id="setSelectedStoreId"
/> />
<div v-if="!selectedStoreId" class="pbt-empty-wrap"> <div v-if="isStoreLoading && !selectedStoreId" class="pbt-empty-wrap">
<Spin tip="门店加载中..." />
</div>
<div v-else-if="!selectedStoreId" class="pbt-empty-wrap">
<Empty description="暂无门店,请先创建门店" /> <Empty description="暂无门店,请先创建门店" />
</div> </div>