feat: adjust page size, fix missing stock column, and implement smart SKU aggregation when SN is hidden
This commit is contained in:
@ -844,7 +844,7 @@ const tempCategorySuffix = ref<string>('');
|
|||||||
|
|
||||||
const queryParams = reactive<QueryParams>({
|
const queryParams = reactive<QueryParams>({
|
||||||
pageNum: 1,
|
pageNum: 1,
|
||||||
pageSize: 100,
|
pageSize: 10,
|
||||||
keyword: '',
|
keyword: '',
|
||||||
searchField: 'all',
|
searchField: 'all',
|
||||||
category: '',
|
category: '',
|
||||||
|
|||||||
@ -134,7 +134,7 @@
|
|||||||
|
|
||||||
<el-table
|
<el-table
|
||||||
v-loading="loading"
|
v-loading="loading"
|
||||||
:data="tableData"
|
:data="displayData"
|
||||||
border
|
border
|
||||||
stripe
|
stripe
|
||||||
style="width: 100%"
|
style="width: 100%"
|
||||||
@ -740,11 +740,14 @@ const permissionMap: Record<string, string> = {
|
|||||||
inbound_date: 'inbound_product:inbound_date',
|
inbound_date: 'inbound_product:inbound_date',
|
||||||
barcode: 'inbound_product:barcode',
|
barcode: 'inbound_product:barcode',
|
||||||
serial_number: 'inbound_product:serial_number',
|
serial_number: 'inbound_product:serial_number',
|
||||||
|
sn_bn: 'inbound_product:sn_bn',
|
||||||
batch_number: 'inbound_product:serial_number',
|
batch_number: 'inbound_product:serial_number',
|
||||||
status: 'inbound_product:status',
|
status: 'inbound_product:status',
|
||||||
quality_status: 'inbound_product:quality_status',
|
quality_status: 'inbound_product:quality_status',
|
||||||
in_quantity: 'inbound_product:in_quantity',
|
in_quantity: 'inbound_product:in_quantity',
|
||||||
|
qty_stock: 'inbound_product:qty_stock',
|
||||||
stock_quantity: 'inbound_product:stock_quantity',
|
stock_quantity: 'inbound_product:stock_quantity',
|
||||||
|
qty_available: 'inbound_product:qty_available',
|
||||||
available_quantity: 'inbound_product:available_quantity',
|
available_quantity: 'inbound_product:available_quantity',
|
||||||
warehouse_location: 'inbound_product:warehouse_location',
|
warehouse_location: 'inbound_product:warehouse_location',
|
||||||
bom_code: 'inbound_product:bom_code',
|
bom_code: 'inbound_product:bom_code',
|
||||||
@ -800,6 +803,37 @@ const hasColumnPermission = (prop: string) => {
|
|||||||
return code ? userStore.hasPermission(code) : false
|
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<string, any>()
|
||||||
|
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 defaultVisibleCols = ['company_name', 'material_name', 'sku', 'serial_number', 'qty_stock', 'status', 'quality_status', 'product_photo', 'sale_price', 'order_id']
|
||||||
const visibleColumnProps = ref(defaultVisibleCols)
|
const visibleColumnProps = ref(defaultVisibleCols)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user