2025-07-28 18:25:02 +08:00
|
|
|
<template>
|
2025-11-15 14:11:12 +08:00
|
|
|
<div v-loading="loading" loading-text="加载中...">
|
2025-10-31 11:52:45 +08:00
|
|
|
<span class="product-name" @click.stop="clickHandle">
|
2025-07-29 15:00:15 +08:00
|
|
|
<slot name="default" :product="product">
|
2025-08-15 10:12:50 +08:00
|
|
|
{{ product && product.productName ? product.productName : '--' }}
|
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"
|
2025-08-15 10:12:50 +08:00
|
|
|
:title="product && product.productName ? product.productName : '--' "
|
2025-07-29 15:16:51 +08:00
|
|
|
width="500px"
|
|
|
|
|
append-to-body
|
|
|
|
|
>
|
|
|
|
|
<el-descriptions :column="1" border>
|
2025-11-14 18:16:16 +08:00
|
|
|
<!-- <el-descriptions-item label="产品ID">
|
2025-07-29 15:16:51 +08:00
|
|
|
{{ product.productId || '--' }}
|
2025-11-14 18:16:16 +08:00
|
|
|
</el-descriptions-item> -->
|
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>
|
2025-11-04 16:45:30 +08:00
|
|
|
<el-descriptions-item label="规格">
|
|
|
|
|
{{ product.specification || '--' }}
|
|
|
|
|
</el-descriptions-item>
|
2025-11-14 18:16:16 +08:00
|
|
|
<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>
|
2025-11-14 18:16:16 +08:00
|
|
|
<!-- <BomInfo :bomId="product.bomId" /> -->
|
2025-07-28 18:25:02 +08:00
|
|
|
</el-dialog>
|
|
|
|
|
</div>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<script>
|
|
|
|
|
import { mapState } from 'vuex';
|
2025-07-29 15:16:51 +08:00
|
|
|
import BomInfo from './BomInfo.vue';
|
|
|
|
|
|
2025-07-28 18:25:02 +08:00
|
|
|
export default {
|
|
|
|
|
name: 'ProductInfo',
|
2025-07-29 15:16:51 +08:00
|
|
|
components: {
|
|
|
|
|
BomInfo
|
|
|
|
|
},
|
2025-07-28 18:25:02 +08:00
|
|
|
props: {
|
|
|
|
|
productId: {
|
|
|
|
|
type: [String, Number],
|
|
|
|
|
required: true
|
2025-07-29 15:00:15 +08:00
|
|
|
},
|
2025-07-28 18:25:02 +08:00
|
|
|
},
|
2025-10-30 14:36:01 +08:00
|
|
|
mounted() {
|
|
|
|
|
console.log(this.productId, this.productMap);
|
|
|
|
|
},
|
2025-07-28 18:25:02 +08:00
|
|
|
data() {
|
|
|
|
|
return {
|
|
|
|
|
showDetail: false,
|
2025-11-15 14:11:12 +08:00
|
|
|
// product: {},
|
2025-07-28 18:25:02 +08:00
|
|
|
};
|
|
|
|
|
},
|
|
|
|
|
computed: {
|
|
|
|
|
...mapState({
|
2025-07-29 15:16:51 +08:00
|
|
|
productMap: state => state.category.productMap
|
2025-07-28 18:25:02 +08:00
|
|
|
}),
|
2025-11-15 14:11:12 +08:00
|
|
|
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-28 18:25:02 +08:00
|
|
|
},
|
2025-07-29 15:00:15 +08:00
|
|
|
methods: {
|
|
|
|
|
clickHandle() {
|
|
|
|
|
this.showDetail = true;
|
|
|
|
|
}
|
|
|
|
|
},
|
2025-11-15 14:11:12 +08:00
|
|
|
// 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>
|