2025-07-31 18:07:51 +08:00
|
|
|
|
<template>
|
|
|
|
|
|
<div>
|
|
|
|
|
|
<div v-if="bomInfo.length > 0">
|
|
|
|
|
|
<el-tooltip :content="bomInfo.map(item => item.attrKey + ':' + item.attrValue).join(',')" class="bom-info" placement="top">
|
|
|
|
|
|
<span>{{ bomInfo.map(item => item.attrKey).join(',') }}</span>
|
|
|
|
|
|
</el-tooltip>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<div v-else>
|
|
|
|
|
|
-
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
|
|
<script>
|
|
|
|
|
|
// 如果传递了bomId直接使用bomId, 如果没有传递,则根据itemType和itemId获取bomId
|
|
|
|
|
|
import { listBomItem } from '@/api/wms/bomItem';
|
|
|
|
|
|
import { mapState } from 'vuex';
|
|
|
|
|
|
|
|
|
|
|
|
export default {
|
|
|
|
|
|
name: 'BomInfo',
|
|
|
|
|
|
props: {
|
|
|
|
|
|
bomId: {
|
|
|
|
|
|
type: [String, Number],
|
|
|
|
|
|
required: false
|
|
|
|
|
|
},
|
|
|
|
|
|
itemType: {
|
|
|
|
|
|
type: String,
|
|
|
|
|
|
required: false
|
|
|
|
|
|
},
|
|
|
|
|
|
itemId: {
|
|
|
|
|
|
type: [String, Number],
|
|
|
|
|
|
required: false
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
data() {
|
|
|
|
|
|
return {
|
|
|
|
|
|
bomInfo: []
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
computed: {
|
|
|
|
|
|
...mapState('category', ['bomMap', 'productMap', 'rawMaterialMap']),
|
|
|
|
|
|
},
|
2025-08-01 12:57:30 +08:00
|
|
|
|
watch: {
|
|
|
|
|
|
bomId: {
|
|
|
|
|
|
handler: function (newVal) {
|
|
|
|
|
|
this.getBomInfo();
|
|
|
|
|
|
},
|
|
|
|
|
|
immediate: true
|
|
|
|
|
|
},
|
|
|
|
|
|
itemId: {
|
|
|
|
|
|
handler: function (newVal) {
|
|
|
|
|
|
this.getBomInfo();
|
|
|
|
|
|
},
|
|
|
|
|
|
immediate: true
|
|
|
|
|
|
}
|
2025-07-31 18:07:51 +08:00
|
|
|
|
},
|
|
|
|
|
|
methods: {
|
|
|
|
|
|
getBomInfo() {
|
|
|
|
|
|
const bomMap = this.$store.getters.bomMap;
|
|
|
|
|
|
if (!this.bomId && !this.itemType && !this.itemId) {
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
let bomId = this.bomId;
|
|
|
|
|
|
if (!bomId) {
|
|
|
|
|
|
if (this.itemType === 'product') {
|
2025-08-11 16:17:27 +08:00
|
|
|
|
bomId = this.productMap[this.itemId]?.bomId;
|
2025-07-31 18:07:51 +08:00
|
|
|
|
} else if (this.itemType === 'raw_material') {
|
2025-08-11 16:17:27 +08:00
|
|
|
|
bomId = this.rawMaterialMap[this.itemId]?.bomId;
|
2025-07-31 18:07:51 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2025-08-01 12:57:30 +08:00
|
|
|
|
if (!bomId) {
|
2025-08-11 16:17:27 +08:00
|
|
|
|
this.bomInfo = [];
|
2025-08-01 12:57:30 +08:00
|
|
|
|
return;
|
|
|
|
|
|
}
|
2025-07-31 18:07:51 +08:00
|
|
|
|
if (bomMap[bomId]) {
|
|
|
|
|
|
this.bomInfo = bomMap[bomId];
|
|
|
|
|
|
} else {
|
2025-08-01 12:57:30 +08:00
|
|
|
|
listBomItem({ bomId }).then(res => {
|
2025-07-31 18:07:51 +08:00
|
|
|
|
this.bomInfo = res.rows;
|
|
|
|
|
|
})
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
|
|
<style scoped>
|
|
|
|
|
|
.bom-info {
|
|
|
|
|
|
cursor: pointer;
|
|
|
|
|
|
/* 溢出隐藏显示省略号 */
|
|
|
|
|
|
overflow: hidden;
|
|
|
|
|
|
text-overflow: ellipsis;
|
|
|
|
|
|
white-space: nowrap;
|
|
|
|
|
|
max-width: 100px;
|
|
|
|
|
|
}
|
|
|
|
|
|
</style>
|