解决bomId为空时会查询所有bom的bug
This commit is contained in:
@@ -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;
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user