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

138 lines
3.7 KiB
Vue
Raw Normal View History

2025-07-28 18:25:02 +08:00
<template>
<div>
<span class="product-name" @click.stop="clickHandle">
<slot name="default" :product="productFull">
{{ productFull.productName || '未知' }}[{{ productFull.specification || '无规格' }}] - (材质{{ productFull.material || '无材质' }})
2025-07-29 15:00:15 +08:00
</slot>
2025-07-28 18:25:02 +08:00
</span>
2025-07-29 15:16:51 +08:00
<el-dialog
:visible="showDetail"
@close="showDetail = false"
:title="productFull.productName || '--' "
2025-07-29 15:16:51 +08:00
width="500px"
append-to-body
>
<el-descriptions :column="1" border>
2025-07-31 18:07:51 +08:00
<el-descriptions-item label="产品名称">
2025-07-29 15:16:51 +08:00
{{ product.productName || '--' }}
</el-descriptions-item>
<el-descriptions-item label="产品编码">
{{ product.productCode || '--' }}
</el-descriptions-item>
<el-descriptions-item label="规格">
{{ product.specification || '--' }}
</el-descriptions-item>
<el-descriptions-item label="材质">
{{ product.material || '--' }}
</el-descriptions-item>
<el-descriptions-item label="表面处理">
{{ product.surfaceTreatment || '--' }}
</el-descriptions-item>
<!-- 锌层 -->
<el-descriptions-item label="锌层">
{{ product.zincLayer || '--' }}
</el-descriptions-item>
<!-- 厂家 -->
<el-descriptions-item label="厂家">
{{ product.manufacturer || '--' }}
</el-descriptions-item>
2025-07-29 15:16:51 +08:00
</el-descriptions>
<!-- <BomInfo :bomId="product.bomId" /> -->
2025-07-28 18:25:02 +08:00
</el-dialog>
</div>
</template>
<script>
// import { mapState } from 'vuex';
// import BomInfo from './BomInfo.vue';
2025-07-29 15:16:51 +08:00
2025-07-28 18:25:02 +08:00
export default {
name: 'ProductInfo',
// components: {
// BomInfo
// },
2025-07-28 18:25:02 +08:00
props: {
product: {
type: Object,
// required: true,
default: () => ({})
2025-07-29 15:00:15 +08:00
},
2025-07-28 18:25:02 +08:00
},
// mounted() {
// console.log(this.productId, this.productMap);
// },
2025-07-28 18:25:02 +08:00
data() {
return {
showDetail: false,
// product: {},
2025-07-28 18:25:02 +08:00
};
},
computed: {
productFull() {
// 完整的product, 确保每个字段都有值
if (!this.product) {
return {};
}
return {
productId: this.product.productId || '',
productName: this.product.productName || '',
productCode: this.product.productCode || '',
specification: this.product.specification || '',
material: this.product.material || '',
surfaceTreatment: this.product.surfaceTreatment || '',
zincLayer: this.product.zincLayer || '',
manufacturer: this.product.manufacturer || '',
}
}
},
// computed: {
// ...mapState({
// productMap: state => state.category.productMap
// }),
// product() {
// // 检查 productMap 是否已加载
// if (!this.productMap || Object.keys(this.productMap).length === 0) {
// return {};
// }
// if (!this.productId) {
// return {};
// }
// return this.productMap[this.productId.toString()] || {};
// },
// loading() {
// return !this.productMap || Object.keys(this.productMap).length === 0
// }
// },
2025-07-29 15:00:15 +08:00
methods: {
clickHandle() {
this.showDetail = true;
}
},
// watch: {
// productId: {
// handler(newVal) {
// if (!newVal) {
// this.product = {};
// }
// const res = this.productMap[newVal.toString()] ? this.productMap[newVal.toString()] : {};
// this.product = res;
// },
// immediate: true
// }
// }
2025-07-28 18:25:02 +08:00
};
</script>
<style scoped>
.product-name {
color: #1890ff;
cursor: pointer;
text-decoration: underline;
}
2025-07-29 15:16:51 +08:00
/* 可选:调整描述列表的外边距 */
:deep(.el-descriptions) {
margin-top: -10px;
}
</style>