refactor(ProductSelect): 重构产品选择组件显示逻辑
- 使用 listProductWithBom 替代 listProduct 获取带BOM信息的产品列表 - 合并产品代码和SKU显示区域 - 添加调试日志便于排查BOM信息问题
This commit is contained in:
@@ -11,10 +11,7 @@
|
||||
<div>
|
||||
<div class="option-label">
|
||||
<span class="product-name">{{ item.productName }}</span>
|
||||
<span class="product-code">{{ item.productCode }}</span>
|
||||
</div>
|
||||
<div>
|
||||
<span class="product-sku">{{ getSku(item) }}</span>
|
||||
<span class="product-code">{{ getSku(item) }}</span>
|
||||
</div>
|
||||
</div>
|
||||
</el-option>
|
||||
@@ -63,7 +60,7 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { listProduct, addProduct } from '@/api/wms/product';
|
||||
import { listProductWithBom, addProduct } from '@/api/wms/product';
|
||||
import BomPanel from '../BomPanel/index.vue';
|
||||
|
||||
export default {
|
||||
@@ -125,24 +122,26 @@ export default {
|
||||
},
|
||||
methods: {
|
||||
getProductOptions() {
|
||||
listProduct({ pageNum: 1, pageSize: 1000, type: 'product' }).then(res => {
|
||||
listProductWithBom({ pageNum: 1, pageSize: 1000, type: 'product' }).then(res => {
|
||||
this.productOptions = res.rows || [];
|
||||
});
|
||||
},
|
||||
getSku(item) {
|
||||
const boms = item.bomItems || [];
|
||||
console.log(boms, '产品BOM');
|
||||
if (!boms.length) {
|
||||
return '暂无BOM信息';
|
||||
}
|
||||
// 查找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:
|
||||
let sku = '';
|
||||
if (specification) {
|
||||
@@ -154,6 +153,7 @@ export default {
|
||||
if (material) {
|
||||
sku += '材质:' + material.attrValue + ';';
|
||||
}
|
||||
console.log(sku, item, boms, '产品SKU');
|
||||
return sku;
|
||||
},
|
||||
onChange(val) {
|
||||
|
||||
Reference in New Issue
Block a user