2025-10-31 16:16:56 +08:00
|
|
|
<template>
|
2025-11-03 17:56:26 +08:00
|
|
|
<el-dialog
|
|
|
|
|
:visible.sync="visible"
|
|
|
|
|
:title="title"
|
|
|
|
|
:width="width"
|
|
|
|
|
destroy-on-close
|
|
|
|
|
>
|
|
|
|
|
<component
|
|
|
|
|
v-if="dynamicComponent"
|
|
|
|
|
:is="dynamicComponent"
|
|
|
|
|
ref="dynamicComponentRef"
|
|
|
|
|
v-bind="componentProps"
|
|
|
|
|
@vue:mounted="handleComponentMount"
|
|
|
|
|
/>
|
2025-11-13 17:03:24 +08:00
|
|
|
<slot></slot>
|
2025-10-31 16:16:56 +08:00
|
|
|
<template #footer>
|
|
|
|
|
<div class="dialog-footer">
|
|
|
|
|
<el-button @click="onCancel">取消</el-button>
|
|
|
|
|
<el-button type="primary" @click="onConfirm"> 确认 </el-button>
|
|
|
|
|
</div>
|
|
|
|
|
</template>
|
|
|
|
|
</el-dialog>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<script setup>
|
2025-11-03 17:56:26 +08:00
|
|
|
import { computed, ref, } from "vue";
|
|
|
|
|
const dynamicComponentRef = ref(null);
|
|
|
|
|
defineExpose({
|
|
|
|
|
dynamicComponentRef // 暴露给父组件
|
|
|
|
|
});
|
|
|
|
|
|
2025-10-31 16:16:56 +08:00
|
|
|
const props = defineProps({
|
|
|
|
|
visible: {
|
|
|
|
|
type: Boolean,
|
|
|
|
|
default: false,
|
|
|
|
|
},
|
|
|
|
|
width: {
|
|
|
|
|
type: String,
|
|
|
|
|
default: "50%",
|
|
|
|
|
},
|
|
|
|
|
title: {
|
|
|
|
|
type: String,
|
|
|
|
|
default: "",
|
|
|
|
|
},
|
2025-11-03 17:56:26 +08:00
|
|
|
dynamicComponent: {
|
|
|
|
|
type: [Object, Function],
|
|
|
|
|
default: null,
|
|
|
|
|
},
|
|
|
|
|
componentProps: {
|
|
|
|
|
type: Object,
|
|
|
|
|
default: () => ({}),
|
|
|
|
|
},
|
2025-10-31 16:16:56 +08:00
|
|
|
onConfirm: {
|
|
|
|
|
type: Function,
|
|
|
|
|
default: () => {},
|
|
|
|
|
},
|
|
|
|
|
onCancel: {
|
|
|
|
|
type: Function,
|
|
|
|
|
default: () => {},
|
|
|
|
|
},
|
|
|
|
|
});
|
2025-11-03 17:56:26 +08:00
|
|
|
|
|
|
|
|
const normalizedComponent = computed(() =>
|
|
|
|
|
props.dynamicComponent ? markRaw(props.dynamicComponent) : null
|
|
|
|
|
);
|
2025-10-31 16:16:56 +08:00
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<style>
|
|
|
|
|
</style>
|