refactor(产品/原材料): 重构产品及原材料信息展示与存储方式
移除BOM相关依赖,将材质、表面处理等属性直接存储在实体中 优化信息展示格式,统一使用方括号表示规格 调整表单字段,简化查询条件
This commit is contained in:
@@ -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) {
|
||||
|
||||
@@ -151,38 +151,34 @@ export default {
|
||||
},
|
||||
getLabel(item) {
|
||||
// 原材料名称[规格](参数),如果有则写,没有则省略
|
||||
if (!item.specification) {
|
||||
return `${item.rawMaterialName}(${this.getSku(item)})`
|
||||
|
||||
// 如果有sku拼接(sku), 有规格则拼接[规格], 否则只拼接原材料名称
|
||||
const sku = this.getSku(item);
|
||||
let str = item.rawMaterialName;
|
||||
if (item.specification) {
|
||||
str += `[${item.specification}]`
|
||||
}
|
||||
return `${item.rawMaterialName}[${item.specification}](${this.getSku(item)})`
|
||||
|
||||
if (sku) {
|
||||
str += `(${sku})`
|
||||
}
|
||||
return str;
|
||||
},
|
||||
getSku(item) {
|
||||
const boms = item.bomItems;
|
||||
if (!boms || boms.length === 0) {
|
||||
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 === '材质');
|
||||
|
||||
console.log(boms, item, '查找bomItems');
|
||||
// 组合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, '组合sku');
|
||||
return sku;
|
||||
},
|
||||
add() {
|
||||
|
||||
@@ -13,9 +13,9 @@
|
||||
append-to-body
|
||||
>
|
||||
<el-descriptions :column="1" border>
|
||||
<el-descriptions-item label="产品ID">
|
||||
<!-- <el-descriptions-item label="产品ID">
|
||||
{{ product.productId || '--' }}
|
||||
</el-descriptions-item>
|
||||
</el-descriptions-item> -->
|
||||
<el-descriptions-item label="产品名称">
|
||||
{{ product.productName || '--' }}
|
||||
</el-descriptions-item>
|
||||
@@ -25,8 +25,23 @@
|
||||
<el-descriptions-item label="规格">
|
||||
{{ product.specification || '--' }}
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item label="材质">
|
||||
{{ product.material || '--' }}
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item label="表面处理">
|
||||
{{ product.surfaceTreatment || '--' }}
|
||||
</el-descriptions-item>
|
||||
<!-- 锌层 -->
|
||||
<el-descriptions-item label="锌层">
|
||||
{{ product.zincLayer || '--' }}
|
||||
</el-descriptions-item>
|
||||
<!-- 厂家 -->
|
||||
<el-descriptions-item label="厂家">
|
||||
{{ product.manufacturer || '--' }}
|
||||
</el-descriptions-item>
|
||||
|
||||
</el-descriptions>
|
||||
<BomInfo :bomId="product.bomId" />
|
||||
<!-- <BomInfo :bomId="product.bomId" /> -->
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@@ -13,8 +13,22 @@
|
||||
<el-descriptions-item label="原材料名称">{{ material.rawMaterialName }}</el-descriptions-item>
|
||||
<el-descriptions-item label="原材料编码">{{ material.rawMaterialCode }}</el-descriptions-item>
|
||||
<el-descriptions-item label="规格">{{ material.specification }}</el-descriptions-item>
|
||||
<el-descriptions-item label="材质">
|
||||
{{ material.material || '--' }}
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item label="表面处理">
|
||||
{{ material.surfaceTreatment || '--' }}
|
||||
</el-descriptions-item>
|
||||
<!-- 锌层 -->
|
||||
<el-descriptions-item label="锌层">
|
||||
{{ material.zincLayer || '--' }}
|
||||
</el-descriptions-item>
|
||||
<!-- 厂家 -->
|
||||
<el-descriptions-item label="厂家">
|
||||
{{ material.manufacturer || '--' }}
|
||||
</el-descriptions-item>
|
||||
</el-descriptions>
|
||||
<BomInfo :bomId="material.bomId" />
|
||||
<!-- <BomInfo :bomId="material.bomId" /> -->
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
Reference in New Issue
Block a user