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

65 lines
1.5 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:00:15 +08:00
<el-dialog :visible="showDetail" @close="showDetail = false" title="产品信息" width="400px" append-to-body>
2025-07-28 18:25:02 +08:00
<div>
<p><strong>ID:</strong> {{ product.productId }}</p>
<p><strong>名称:</strong> {{ product.productName }}</p>
<p><strong>描述:</strong> {{ product.productCode }}</p>
</div>
</el-dialog>
</div>
</template>
<script>
import { mapState } from 'vuex';
export default {
name: 'ProductInfo',
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({
productMap: state => state.category.productMap // 假设vuex中为product模块
}),
},
2025-07-29 15:00:15 +08:00
methods: {
clickHandle() {
console.log('clickHandle');
this.showDetail = true;
}
},
2025-07-28 18:25:02 +08:00
watch: {
productId: {
2025-07-29 15:00:15 +08:00
handler: function (newVal) {
const res = this.productMap ? this.productMap[this.productId] : {};
2025-07-28 18:25:02 +08:00
console.log(this.productMap, this.productId, 'productMap', 'productId', res);
this.product = res;
},
immediate: true
}
}
};
</script>
<style scoped>
.product-name {
color: #1890ff;
cursor: pointer;
text-decoration: underline;
}
</style>