From 996056d46a964b6d9b3e38f844c653a2f070a792 Mon Sep 17 00:00:00 2001 From: DXC Date: Fri, 24 Apr 2026 13:19:57 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E5=BA=93=E5=AD=98?= =?UTF-8?q?=E7=9B=98=E7=82=B9=E5=B7=B2=E7=9B=98=E6=95=B0=E9=87=8F=E5=8D=A1?= =?UTF-8?q?=E5=9C=A8500=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- inventory-backend/app/api/v1/inbound/stock.py | 10 ++++++++++ inventory-web/src/views/stock/stocktake/index.vue | 14 ++++---------- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/inventory-backend/app/api/v1/inbound/stock.py b/inventory-backend/app/api/v1/inbound/stock.py index 3bafad2..2efe39c 100644 --- a/inventory-backend/app/api/v1/inbound/stock.py +++ b/inventory-backend/app/api/v1/inbound/stock.py @@ -325,11 +325,21 @@ def get_drafts(): total = len(items) start = (page - 1) * limit end = start + limit + + # 计算真实的去重"已盘数量" + counted_items_set = set() + for draft_item in items: + if draft_item.get('qty_actual') is not None: + unique_key = f"{draft_item.get('source_table', '')}_{draft_item.get('stock_id', '')}" + counted_items_set.add(unique_key) + total_scanned_unique = len(counted_items_set) + paginated_items = items[start:end] return jsonify({ 'items': paginated_items, 'total': total, + 'total_scanned': total_scanned_unique, 'page': page, 'limit': limit }), 200 diff --git a/inventory-web/src/views/stock/stocktake/index.vue b/inventory-web/src/views/stock/stocktake/index.vue index bd5c02a..790666e 100644 --- a/inventory-web/src/views/stock/stocktake/index.vue +++ b/inventory-web/src/views/stock/stocktake/index.vue @@ -486,6 +486,7 @@ const listData = ref([]) const listStatusFilter = ref<'all' | 'counted' | 'uncounted'>('all') const allStockItems = ref([]) // 全量应盘物资(盘点基数) const totalStockCount = ref(0) // ★ 全量应盘物资总数(不受limit限制) +const totalScannedCount = ref(0) // ★ 后端去重的真实已盘数量 const allScannedDrafts = ref([]) // 全量草稿记录(脱离分页和过滤) const listTotalFiltered = ref(0) // 过滤后的总数 @@ -515,18 +516,9 @@ const stats = computed(() => { const total = allStockItems.value.length if (total === 0) return { total: 0, scanned: 0, varianceItems: 0 } - // 使用完整的 allScannedDrafts 来计算"已盘"数量,绝对不依赖视图数据 - const countedItems = new Set() - allScannedDrafts.value.forEach((d: any) => { - // 只要有实盘记录就算已盘 - if (d.quantity !== undefined && d.quantity !== null) { - countedItems.add(`${d.source_table}-${d.stock_id}`) - } - }) - return { total, - scanned: countedItems.size, + scanned: totalScannedCount.value, varianceItems: 0 } }) @@ -1005,6 +997,8 @@ const fetchInventoryList = async (silent = false) => { // 保存全量草稿记录用于全局统计 allScannedDrafts.value = scannedDrafts + // 直接读取后端算好的去重已盘数 + totalScannedCount.value = res?.total_scanned || 0 // 2. 使用全量应盘物资列表 // 对于每个应盘物资,检查是否有对应的盘点记录