🐞 fix: 部分位置需要判空

This commit is contained in:
砂糖
2025-08-11 16:17:27 +08:00
parent 542b481155
commit 6f415c44d1
7 changed files with 21 additions and 17 deletions

View File

@@ -48,7 +48,7 @@
},
_itemId: {
get() {
return this.itemId;
return this.itemId.toString();
},
set(val) {
this.$emit('update:itemId', val);

View File

@@ -63,9 +63,9 @@ export default {
let bomId = this.bomId;
if (!bomId) {
if (this.itemType === 'product') {
bomId = this.productMap[this.itemId].bomId;
bomId = this.productMap[this.itemId]?.bomId;
} else if (this.itemType === 'raw_material') {
bomId = this.rawMaterialMap[this.itemId].bomId;
bomId = this.rawMaterialMap[this.itemId]?.bomId;
}
}
if (!bomId) {

View File

@@ -63,12 +63,13 @@ export default {
let bomId = this.bomId;
if (!bomId) {
if (this.itemType === 'product') {
bomId = this.productMap[this.itemId].bomId;
bomId = this.productMap[this.itemId]?.bomId;
} else if (this.itemType === 'raw_material') {
bomId = this.rawMaterialMap[this.itemId].bomId;
bomId = this.rawMaterialMap[this.itemId]?.bomId;
}
}
if (!bomId) {
this.bomInfo = [];
return;
}
if (bomMap[bomId]) {

View File

@@ -62,9 +62,9 @@ export default {
watch: {
productId: {
handler(newVal) {
this.product = this.productMap && this.productMap[this.productId]
? { ...this.productMap[this.productId] }
: {};
const res = this.productMap[this.productId] ? this.productMap[this.productId] : {};
console.log(res)
this.product = res;
},
immediate: true
}

View File

@@ -3,7 +3,7 @@
<!-- 作用域插槽 -->
<span class="material-name" @click="showDetail = true">
<slot name="default" :material="material">
{{ material.rawMaterialName ? material.rawMaterialName : '--' }}
{{ material.rawMaterialName ? material.rawMaterialName : '-' }}
</slot>
</span>
<el-dialog :visible="showDetail" @close="showDetail = false" :title="material.rawMaterialName" width="600px"
@@ -47,7 +47,8 @@ export default {
watch: {
materialId: {
handler: function (newVal) {
const res = this.materialMap ? this.materialMap[this.materialId] : {};
const res = this.materialMap[this.materialId] ? this.materialMap[this.materialId] : {};
console.log(res)
this.material = res;
},
immediate: true