解决bomId为空时会查询所有bom的bug

This commit is contained in:
砂糖
2025-08-01 12:57:30 +08:00
parent 7725a588ee
commit 5b619eca0a
9 changed files with 119 additions and 51 deletions

View File

@@ -40,17 +40,26 @@ export default {
computed: {
...mapState('category', ['bomMap', 'productMap', 'rawMaterialMap']),
},
created() {
this.getBomInfo();
watch: {
bomId: {
handler: function (newVal) {
this.getBomInfo();
},
immediate: true
},
itemId: {
handler: function (newVal) {
this.getBomInfo();
},
immediate: true
}
},
methods: {
getBomInfo() {
const bomMap = this.$store.getters.bomMap;
console.log(bomMap)
if (!this.bomId && !this.itemType && !this.itemId) {
return;
}
console.log(this.itemType, this.itemId)
let bomId = this.bomId;
if (!bomId) {
if (this.itemType === 'product') {
@@ -59,10 +68,13 @@ export default {
bomId = this.rawMaterialMap[this.itemId].bomId;
}
}
if (!bomId) {
return;
}
if (bomMap[bomId]) {
this.bomInfo = bomMap[bomId];
} else {
listBomItem({ bomId: bomId }).then(res => {
listBomItem({ bomId }).then(res => {
this.bomInfo = res.rows;
})
}