refactor(wms): 优化库存详情页钢材品类匹配逻辑
- 调整镀锌管材匹配规则,支持更多镀锌相关品类 - 新增仓库特定品类匹配配置,不同仓库使用不同的品类优先级 - 扩展品质等级匹配逻辑,支持以字母开头和特定等级标识 - 修改数据获取方式,按仓库分别请求并去重合并数据 - 优化钢材品类匹配算法,按仓库限制的品类范围进行匹配 - 更新数据加载逻辑,使用Promise.all并行请求提升性能
This commit is contained in:
@@ -46,13 +46,22 @@ const CATEGORIES = [
|
||||
{ key: '冷硬钢卷', label: '冷硬钢卷', match: ['冷硬'] },
|
||||
{ key: '冷轧钢卷', label: '冷轧钢卷', match: ['冷轧'] },
|
||||
{ key: '镀锌钢卷', label: '镀锌钢卷', match: ['镀锌分剪卷', '镀锌卷', '镀锌'] },
|
||||
{ key: '镀锌管材', label: '镀锌管材', match: ['镀锌管'] },
|
||||
{ key: '镀锌管材', label: '镀锌管材', match: ['镀锌卷', '镀锌分剪卷', '镀锌管'] },
|
||||
{ key: '花纹板', label: '花纹板', match: ['花纹板'] },
|
||||
{ key: '镀铬', label: '镀铬', match: ['镀铬'] },
|
||||
]
|
||||
// 匹配优先级:镀锌管材必须在镀锌钢卷之前检查
|
||||
const MATCH_PRIORITY = ['镀锌管材', '冷硬钢卷', '冷轧钢卷', '镀锌钢卷', '花纹板', '镀铬']
|
||||
|
||||
// 仓库 → 允许匹配的品类(按优先级排序),未列出的仓库使用 MATCH_PRIORITY
|
||||
const WAREHOUSE_CATS = {
|
||||
'1988150099140866050': ['冷硬钢卷'],
|
||||
'1988150915591499777': ['冷轧钢卷', '花纹板'],
|
||||
'1988150323162836993': ['镀锌钢卷', '镀锌管材'],
|
||||
'1988150487185289217': ['镀锌管材'],
|
||||
'1988151132361519105': ['镀铬'],
|
||||
}
|
||||
|
||||
/**
|
||||
* 品质等级 → 分组映射
|
||||
* A/B → 'AB', C/D/O → 'CDO', 其他 → null
|
||||
@@ -60,8 +69,8 @@ const MATCH_PRIORITY = ['镀锌管材', '冷硬钢卷', '冷轧钢卷', '镀锌
|
||||
function getQualityGroup(status) {
|
||||
if (!status) return null
|
||||
const s = String(status).toUpperCase().trim()
|
||||
if (['A', 'B'].includes(s)) return 'AB'
|
||||
if (['C', 'D', 'O'].includes(s)) return 'CDO'
|
||||
if (s.startsWith('A') || s === 'B' || s === 'B级') return 'AB'
|
||||
if (s.startsWith('C') || s.startsWith('D') || s.startsWith('O')) return 'CDO'
|
||||
return null
|
||||
}
|
||||
|
||||
@@ -93,9 +102,10 @@ export default {
|
||||
let unmatchedCount = 0
|
||||
|
||||
this.rawList.forEach(item => {
|
||||
// 匹配钢材品类
|
||||
// 匹配钢材品类(按仓库限制品类范围)
|
||||
const catMap = new Map(CATEGORIES.map(c => [c.key, c]))
|
||||
const cat = MATCH_PRIORITY.map(k => catMap.get(k)).find(
|
||||
const allowed = WAREHOUSE_CATS[item.warehouseId] || MATCH_PRIORITY
|
||||
const cat = allowed.map(k => catMap.get(k)).find(
|
||||
c => item.itemName && c.match.some(m => item.itemName.includes(m))
|
||||
)
|
||||
if (!cat) { unmatchedCount++; return }
|
||||
@@ -239,14 +249,23 @@ export default {
|
||||
this.loading = true
|
||||
this.rawList = []
|
||||
|
||||
listCoilWithIds({
|
||||
selectType: 'product',
|
||||
status: 0,
|
||||
dataType: 1,
|
||||
pageSize: 99999,
|
||||
pageNum: 1,
|
||||
}).then(res => {
|
||||
this.rawList = res.rows || []
|
||||
Promise.all([
|
||||
// 酸连轧成品库 → 冷硬钢卷
|
||||
listCoilWithIds({ warehouseIds: '1988150099140866050', status: 0, dataType: 1, pageSize: 99999, pageNum: 1 }),
|
||||
// 拉矫成品库 → 冷轧钢卷 / 花纹板(按 itemName 区分)
|
||||
listCoilWithIds({ warehouseIds: '1988150915591499777', status: 0, dataType: 1, pageSize: 99999, pageNum: 1 }),
|
||||
// 镀锌成品库 → 镀锌钢卷 / 镀锌管材(按 itemName 区分)
|
||||
listCoilWithIds({ warehouseIds: '1988150323162836993', status: 0, dataType: 1, pageSize: 99999, pageNum: 1 }),
|
||||
// 镀锌纵剪分条原料库 → 镀锌管材(raw_material 镀锌卷)
|
||||
listCoilWithIds({ warehouseIds: '1988150487185289217', status: 0, dataType: 1, pageSize: 99999, pageNum: 1 }),
|
||||
// 镀铬成品库 → 镀铬
|
||||
listCoilWithIds({ warehouseIds: '1988151132361519105', status: 0, dataType: 1, pageSize: 99999, pageNum: 1 }),
|
||||
]).then(results => {
|
||||
const map = new Map()
|
||||
results.forEach(res => {
|
||||
;(res.rows || []).forEach(item => map.set(item.coilId, item))
|
||||
})
|
||||
this.rawList = Array.from(map.values())
|
||||
this.loading = false
|
||||
}).catch(() => {
|
||||
this.loading = false
|
||||
|
||||
Reference in New Issue
Block a user