Files
klp-oa/klp-ui/src/components/KLPService/Renderer/BomInfo.vue

86 lines
2.0 KiB
Vue
Raw Normal View History

2025-07-29 15:16:51 +08:00
<template>
<div>
<el-descriptions :column="1" border v-if="bomInfo.length > 0">
<el-descriptions-item v-for="item in bomInfo" :key="item.attrKey" :label="item.attrKey">
{{ item.attrValue }}
</el-descriptions-item>
</el-descriptions>
2025-07-31 18:07:51 +08:00
<div v-else-if="mini">
<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>
2025-07-29 15:16:51 +08:00
<div v-else>
<el-empty description="暂无BOM信息" />
</div>
</div>
</template>
<script>
2025-07-31 18:07:51 +08:00
import { listBomItem } from '@/api/wms/bomItem';
import { mapState } from 'vuex';
2025-07-29 15:16:51 +08:00
export default {
name: 'BomInfo',
props: {
bomId: {
type: [String, Number],
2025-07-31 18:07:51 +08:00
required: false
},
itemType: {
type: String,
required: false
},
itemId: {
type: [String, Number],
required: false
2025-07-29 15:16:51 +08:00
}
},
data() {
return {
bomInfo: []
}
},
2025-07-31 18:07:51 +08:00
computed: {
...mapState('category', ['bomMap', 'productMap', 'rawMaterialMap']),
},
2025-07-29 15:16:51 +08:00
created() {
this.getBomInfo();
},
methods: {
getBomInfo() {
2025-07-31 18:07:51 +08:00
const bomMap = this.$store.getters.bomMap;
console.log(bomMap)
if (!this.bomId && !this.itemType && !this.itemId) {
return;
}
let bomId = this.bomId;
if (!bomId) {
if (this.itemType === 'product') {
bomId = this.productMap[this.itemId].bomId;
} else if (this.itemType === 'raw_material') {
bomId = this.rawMaterialMap[this.itemId].bomId;
}
}
if (bomMap[bomId]) {
this.bomInfo = bomMap[bomId];
} else {
listBomItem({ bomId: bomId }).then(res => {
this.bomInfo = res.rows;
})
}
2025-07-29 15:16:51 +08:00
}
}
}
2025-07-31 18:07:51 +08:00
</script>
<style scoped>
.bom-info {
cursor: pointer;
/* 溢出隐藏显示省略号 */
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
max-width: 100px;
}
</style>