diff --git a/inventory-web/src/views/stock/stocktake/index.vue b/inventory-web/src/views/stock/stocktake/index.vue index 2ec5cf8..65ef83f 100644 --- a/inventory-web/src/views/stock/stocktake/index.vue +++ b/inventory-web/src/views/stock/stocktake/index.vue @@ -417,8 +417,6 @@ const borrowedQuantities = ref>({}) // ★ 新增: 会话ID const currentSessionId = ref('') -// ★ 新增: 差异报告列表 -const varianceList = ref([]) const varianceLoading = ref(false) const filterType = ref('all') @@ -830,9 +828,18 @@ const stats = computed(() => { }) const varianceList = computed(() => { - return allData.value.filter(i => - !i.scanned || (i.scanned && i.qty_actual !== parseFloat(i.qty_stock as any)) - ) + return allData.value + .filter(i => !i.scanned || (i.scanned && i.qty_actual !== parseFloat(i.qty_stock as any))) + .map(i => ({ + ...i, + // 映射字段名以匹配模板 + stock_name: i.name, + stock_spec: i.standard, + stock_location: i.location || i.warehouse_loc || '', + stock_qty: i.qty_stock, + quantity: i.qty_actual, + diff_qty: i.qty_actual - parseFloat(i.qty_stock as any) + })) }) const openInventoryList = () => { showList.value = true } @@ -872,14 +879,8 @@ const finishStocktake = async () => { const openVarianceDialog = async () => { varianceLoading.value = true showVarianceDialog.value = true - try { - const res: any = await api.getVarianceReport() - varianceList.value = res.list || [] - } catch (e: any) { - ElMessage.error(e?.message || '获取差异报告失败') - } finally { - varianceLoading.value = false - } + // varianceList 已通过 computed 自动计算,无需额外 API 调用 + varianceLoading.value = false } // ★ 新增: 确认平账