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

90 lines
1.9 KiB
Vue
Raw Normal View History

2025-07-28 18:25:02 +08:00
<template>
<div>
2025-07-29 15:00:15 +08:00
<span class="product-name" @click="clickHandle">
<slot name="default" :product="product">
{{ product.productName ? product.productName : '--' }}
</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-07-29 16:57:16 +08:00
:title="product.productName"
2025-07-29 15:16:51 +08:00
width="500px"
append-to-body
>
<el-descriptions :column="1" border>
<el-descriptions-item label="ID">
{{ product.productId || '--' }}
</el-descriptions-item>
<el-descriptions-item label="名称">
{{ product.productName || '--' }}
</el-descriptions-item>
<el-descriptions-item label="产品编码">
{{ product.productCode || '--' }}
</el-descriptions-item>
</el-descriptions>
<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
},
data() {
return {
showDetail: false,
2025-07-29 15:00:15 +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-07-29 15:00:15 +08:00
methods: {
clickHandle() {
console.log('clickHandle');
this.showDetail = true;
2025-07-29 15:16:51 +08:00
},
getStatusText(status) {
return status === 1 ? '启用中' : '已禁用';
2025-07-29 15:00:15 +08:00
}
},
2025-07-28 18:25:02 +08:00
watch: {
productId: {
2025-07-29 15:16:51 +08:00
handler(newVal) {
this.product = this.productMap && this.productMap[this.productId]
? { ...this.productMap[this.productId] }
: {};
2025-07-28 18:25:02 +08:00
},
immediate: true
}
}
};
</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>