fix(stocktake): auto-refresh inventory drafts silently after scanning to ensure real-time outer stats

This commit is contained in:
DXC
2026-03-27 09:23:10 +08:00
parent b2ce9d31f8
commit 4b023a4002

View File

@ -889,6 +889,8 @@ const syncToBackend = (uuid: string, quantity: number, remark: string) => {
api.addDraft({ uuid, quantity, remark }) api.addDraft({ uuid, quantity, remark })
.then(() => { .then(() => {
syncStatus.value = 'success' syncStatus.value = 'success'
// 静默刷新统计数字
fetchInventoryList(true)
}) })
.catch(() => { .catch(() => {
syncStatus.value = 'failed' syncStatus.value = 'failed'
@ -970,8 +972,9 @@ const filteredVarianceList = computed(() => {
}) })
// ★ 新增: 获取盘点清单数据(合并全量应盘物资 + 已盘点记录) // ★ 新增: 获取盘点清单数据(合并全量应盘物资 + 已盘点记录)
const fetchInventoryList = async () => { // silent: 是否静默模式(不显示 loading不报错
listLoading.value = true const fetchInventoryList = async (silent = false) => {
if (!silent) listLoading.value = true
try { try {
// 1. 获取已盘点记录 // 1. 获取已盘点记录
const res: any = await request({ const res: any = await request({
@ -983,9 +986,9 @@ const fetchInventoryList = async () => {
keyword: listKeyword.value keyword: listKeyword.value
} }
}) })
const scannedDrafts = res?.items || [] const scannedDrafts = res?.items || []
// 保存全量草稿记录用于全局统计 // 保存全量草稿记录用于全局统计
allScannedDrafts.value = scannedDrafts allScannedDrafts.value = scannedDrafts
@ -1034,9 +1037,9 @@ const fetchInventoryList = async () => {
listData.value = mergedData.slice(start, start + listLimit.value) listData.value = mergedData.slice(start, start + listLimit.value)
} catch (e) { } catch (e) {
ElMessage.error('获取盘点清单失败') if (!silent) ElMessage.error('获取盘点清单失败')
} finally { } finally {
listLoading.value = false if (!silent) listLoading.value = false
} }
} }