refactor(产品/原材料): 重构产品及原材料信息展示与存储方式

移除BOM相关依赖,将材质、表面处理等属性直接存储在实体中
优化信息展示格式,统一使用方括号表示规格
调整表单字段,简化查询条件
This commit is contained in:
砂糖
2025-11-14 18:16:16 +08:00
parent c351a2b551
commit 5080a29bd6
9 changed files with 205 additions and 441 deletions

View File

@@ -147,39 +147,32 @@ export default {
},
getLabel(item) {
// 产品名称[规格](参数),如果有则写,没有则省略
if (!item.specification) {
return `${item.productName}(${this.getSku(item)})`
const sku = this.getSku(item);
let str = item.productName;
if (item.specification) {
str += `[${item.specification}]`
}
return `${item.productName}[${item.specification}](${this.getSku(item)})`
if (sku) {
str += `(${sku})`
}
return str;
},
getSku(item) {
const boms = item.bomItems || [];
console.log(boms, '产品参数');
if (!boms.length) {
return '暂无参数信息';
}
// 查找attrKey为'规格'的attrvalue
const specification = boms.find(p => p.attrKey === '规格');
// 查找attrKey为'表面处理'的attrvalue
const factory = boms.find(p => p.attrKey === '表面处理');
// 查找attrKey为'材质'的attrvalue
const material = boms.find(p => p.attrKey === '材质');
// 组合sku:
// 查询item的材质(material),表面处理(surfaceTreatmentDesc),厂家(manufacturer),锌层(zincLayer),如果有则添加到sku字符串中
let sku = '';
if (specification) {
sku += '规格' + specification.attrValue + '';
if (item.material) {
sku += '材质' + item.material + '';
}
if (factory) {
sku += '表面处理:' + factory.attrValue + '';
if (item.surfaceTreatmentDesc) {
sku += '表面处理:' + item.surfaceTreatmentDesc + '';
}
if (material) {
sku += '材质' + material.attrValue + '';
if (item.manufacturer) {
sku += '厂家' + item.manufacturer + '';
}
if (item.zincLayer) {
sku += '锌层:' + item.zincLayer + '';
}
console.log(sku, item, boms, '产品参数');
return sku;
},
onChange(val) {