From 8259a74c57a4bd032f27f95e7d7d96db17b5a128 Mon Sep 17 00:00:00 2001 From: DXC Date: Fri, 27 Mar 2026 08:56:43 +0800 Subject: [PATCH] fix(stocktake): fetch inventory baseline immediately upon session start to show correct initial stats --- .../src/views/stock/stocktake/index.vue | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/inventory-web/src/views/stock/stocktake/index.vue b/inventory-web/src/views/stock/stocktake/index.vue index 70af058..ac8b519 100644 --- a/inventory-web/src/views/stock/stocktake/index.vue +++ b/inventory-web/src/views/stock/stocktake/index.vue @@ -79,7 +79,7 @@ -
+
{{ stats.total }}
总品项
@@ -625,6 +625,9 @@ const doStartNewSession = async () => { isSessionActive.value = true // ★ 标记当前阶段为 scanning(扫码中) localStorage.setItem('stocktake_phase', 'scanning') + // ★ 立即加载统计基数 + await fetchAllStockItems() + await fetchInventoryList() ElMessage.success('新盘点会话已开始') } catch (e: any) { if (e !== 'cancel') { @@ -674,6 +677,10 @@ const resumeSession = async () => { // 直接恢复会话状态 isSessionActive.value = true + // ★ 立即加载统计基数 + await fetchAllStockItems() + await fetchInventoryList() + // ★ 智能路由:根据本地记忆的阶段决定下一步 const phase = localStorage.getItem('stocktake_phase') if (phase === 'review') { @@ -1039,9 +1046,10 @@ const openInventoryList = async () => { listPage.value = 1 listKeyword.value = '' listStatusFilter.value = 'all' - // 获取盘点基数(应盘物资清单) - await fetchAllStockItems() - // 获取已盘点列表 + // 如果基数未加载则先加载,否则只刷新已盘点记录 + if (allStockItems.value.length === 0) { + await fetchAllStockItems() + } await fetchInventoryList() }