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