fix: 修复库存盘点已盘数量卡在500的问题
This commit is contained in:
@ -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
|
||||
|
||||
@ -486,6 +486,7 @@ const listData = ref<any[]>([])
|
||||
const listStatusFilter = ref<'all' | 'counted' | 'uncounted'>('all')
|
||||
const allStockItems = ref<any[]>([]) // 全量应盘物资(盘点基数)
|
||||
const totalStockCount = ref(0) // ★ 全量应盘物资总数(不受limit限制)
|
||||
const totalScannedCount = ref(0) // ★ 后端去重的真实已盘数量
|
||||
const allScannedDrafts = ref<any[]>([]) // 全量草稿记录(脱离分页和过滤)
|
||||
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. 使用全量应盘物资列表
|
||||
// 对于每个应盘物资,检查是否有对应的盘点记录
|
||||
|
||||
Reference in New Issue
Block a user