feat(klp-material-picker): 增加根据规格过滤产品和原材料的功能

修改产品和原材料的过滤逻辑,使其不仅支持按名称过滤,还支持按规格字段过滤。同时移除了调试用的console.log语句。
This commit is contained in:
砂糖
2025-11-05 11:39:28 +08:00
parent f3d27a2baa
commit 7f7bb489b5

View File

@@ -244,7 +244,8 @@
this.filteredProducts = keyword
? this.products.filter(p => {
// 只基于产品名称过滤,且确保是产品数据
return p.productName && p.productName.toLowerCase().includes(keyword)
return (p.productName && p.productName.toLowerCase().includes(keyword))
|| p?.specification?.toLowerCase()?.includes(keyword)
})
: [...this.products];
},
@@ -254,8 +255,10 @@
const keyword = this.rawMaterialSearchKeyword.trim().toLowerCase();
this.filteredRawMaterials = keyword
? this.rawMaterials.filter(m => {
console.log(m.specification)
// 只基于原材料名称过滤,且确保是原材料数据
return m.rawMaterialName && m.rawMaterialName.toLowerCase().includes(keyword)
return (m.rawMaterialName && m.rawMaterialName.toLowerCase().includes(keyword))
|| m?.specification?.toLowerCase()?.includes(keyword)
})
: [...this.rawMaterials];
},