From d53362f06fdd3907afc701896d71031e312650b8 Mon Sep 17 00:00:00 2001 From: DXC Date: Mon, 23 Mar 2026 11:13:43 +0800 Subject: [PATCH] feat: adjust page size, fix missing stock column, and implement smart SKU aggregation when SN is hidden --- inventory-web/src/views/material/list.vue | 2 +- .../src/views/stock/inbound/product.vue | 36 ++++++++++++++++++- 2 files changed, 36 insertions(+), 2 deletions(-) diff --git a/inventory-web/src/views/material/list.vue b/inventory-web/src/views/material/list.vue index 797cb21..a5bd4ff 100644 --- a/inventory-web/src/views/material/list.vue +++ b/inventory-web/src/views/material/list.vue @@ -844,7 +844,7 @@ const tempCategorySuffix = ref(''); const queryParams = reactive({ pageNum: 1, - pageSize: 100, + pageSize: 10, keyword: '', searchField: 'all', category: '', diff --git a/inventory-web/src/views/stock/inbound/product.vue b/inventory-web/src/views/stock/inbound/product.vue index bee7585..2ae5b0e 100644 --- a/inventory-web/src/views/stock/inbound/product.vue +++ b/inventory-web/src/views/stock/inbound/product.vue @@ -134,7 +134,7 @@ = { inbound_date: 'inbound_product:inbound_date', barcode: 'inbound_product:barcode', serial_number: 'inbound_product:serial_number', + sn_bn: 'inbound_product:sn_bn', batch_number: 'inbound_product:serial_number', status: 'inbound_product:status', quality_status: 'inbound_product:quality_status', in_quantity: 'inbound_product:in_quantity', + qty_stock: 'inbound_product:qty_stock', stock_quantity: 'inbound_product:stock_quantity', + qty_available: 'inbound_product:qty_available', available_quantity: 'inbound_product:available_quantity', warehouse_location: 'inbound_product:warehouse_location', bom_code: 'inbound_product:bom_code', @@ -800,6 +803,37 @@ const hasColumnPermission = (prop: string) => { return code ? userStore.hasPermission(code) : false } +// ★ 智能聚合:当无序列号权限时,按 SKU 聚合库存 +const displayData = computed(() => { + // 检查是否有序列号权限 + const hasSnPermission = hasColumnPermission('sn_bn') || hasColumnPermission('serial_number') + if (hasSnPermission || !tableData.value.length) { + return tableData.value + } + + // 无权限时,按 SKU + 规格型号聚合 + const aggMap = new Map() + for (const item of tableData.value) { + const key = `${item.sku || ''}_${item.spec_model || item.spec || ''}` + if (aggMap.has(key)) { + const existing = aggMap.get(key) + // 累加库存数量 + existing.qty_stock = (existing.qty_stock || 0) + (item.qty_stock || 0) + existing.qty_available = (existing.qty_available || 0) + (item.qty_available || 0) + existing.stock_quantity = (existing.stock_quantity || 0) + (item.stock_quantity || 0) + existing.available_quantity = (existing.available_quantity || 0) + (item.available_quantity || 0) + existing.in_quantity = (existing.in_quantity || 0) + (item.in_quantity || 0) + // 累加其他数量字段 + existing.total_price = (existing.total_price || 0) + (item.total_price || 0) + existing.raw_material_cost = (existing.raw_material_cost || 0) + (item.raw_material_cost || 0) + existing.unit_total_cost = (existing.unit_total_cost || 0) + (item.unit_total_cost || 0) + } else { + aggMap.set(key, { ...item }) + } + } + return Array.from(aggMap.values()) +}) + const defaultVisibleCols = ['company_name', 'material_name', 'sku', 'serial_number', 'qty_stock', 'status', 'quality_status', 'product_photo', 'sale_price', 'order_id'] const visibleColumnProps = ref(defaultVisibleCols)