From 4b023a4002c75d97d75b6abbf1e4e557e7d79cce Mon Sep 17 00:00:00 2001 From: DXC Date: Fri, 27 Mar 2026 09:23:10 +0800 Subject: [PATCH] fix(stocktake): auto-refresh inventory drafts silently after scanning to ensure real-time outer stats --- inventory-web/src/views/stock/stocktake/index.vue | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/inventory-web/src/views/stock/stocktake/index.vue b/inventory-web/src/views/stock/stocktake/index.vue index ffd1233..949214d 100644 --- a/inventory-web/src/views/stock/stocktake/index.vue +++ b/inventory-web/src/views/stock/stocktake/index.vue @@ -889,6 +889,8 @@ const syncToBackend = (uuid: string, quantity: number, remark: string) => { api.addDraft({ uuid, quantity, remark }) .then(() => { syncStatus.value = 'success' + // 静默刷新统计数字 + fetchInventoryList(true) }) .catch(() => { syncStatus.value = 'failed' @@ -970,8 +972,9 @@ const filteredVarianceList = computed(() => { }) // ★ 新增: 获取盘点清单数据(合并全量应盘物资 + 已盘点记录) -const fetchInventoryList = async () => { - listLoading.value = true +// silent: 是否静默模式(不显示 loading,不报错) +const fetchInventoryList = async (silent = false) => { + if (!silent) listLoading.value = true try { // 1. 获取已盘点记录 const res: any = await request({ @@ -983,9 +986,9 @@ const fetchInventoryList = async () => { keyword: listKeyword.value } }) - + const scannedDrafts = res?.items || [] - + // 保存全量草稿记录用于全局统计 allScannedDrafts.value = scannedDrafts @@ -1034,9 +1037,9 @@ const fetchInventoryList = async () => { listData.value = mergedData.slice(start, start + listLimit.value) } catch (e) { - ElMessage.error('获取盘点清单失败') + if (!silent) ElMessage.error('获取盘点清单失败') } finally { - listLoading.value = false + if (!silent) listLoading.value = false } }