Files
klp-oa/klp-ui/src/components/KLPService/Renderer/RawMaterialInfo.vue
2025-07-29 15:16:51 +08:00

63 lines
1.6 KiB
Vue

<template>
<div>
<!-- 作用域插槽 -->
<span class="material-name" @click="showDetail = true">
<slot name="default" :material="material">
{{ material.rawMaterialName ? material.rawMaterialName : '--' }}
</slot>
</span>
<el-dialog :visible="showDetail" @close="showDetail = false" :title="material.name" width="400px"
append-to-body>
<el-descriptions :column="1" border>
<el-descriptions-item label="ID">{{ material.rawMaterialId }}</el-descriptions-item>
<el-descriptions-item label="名称">{{ material.rawMaterialName }}</el-descriptions-item>
<el-descriptions-item label="描述">{{ material.rawMaterialCode }}</el-descriptions-item>
</el-descriptions>
<BomInfo :bomId="material.bomId" />
</el-dialog>
</div>
</template>
<script>
import { mapState } from 'vuex';
export default {
name: 'RawMaterialInfo',
props: {
materialId: {
type: [String, Number],
required: true
}
},
data() {
return {
showDetail: false,
material: {},
};
},
computed: {
...mapState({
materialMap: state => state.category.rawMaterialMap // 假设vuex中为material模块
}),
},
watch: {
materialId: {
handler: function (newVal) {
const res = this.materialMap ? this.materialMap[this.materialId] : {};
console.log(this.materialMap, this.materialId, 'materialMap', 'materialId', res);
this.material = res;
},
immediate: true
}
}
}
</script>
<style scoped>
.material-name {
color: #1890ff;
cursor: pointer;
text-decoration: underline;
}
</style>