dialog.vue
<template>
<el-dialog
class="com_dialog"
:visible.sync="visible"
v-bind="$attrs"
:close-on-click-modal="closeOnClickModal"
:close-on-press-escape="closeOnPressEscape"
@open="open"
@opened="opened"
@close="Cancel"
@closed="closed"
>
<slot></slot>
<span v-if="!$slots.footer" slot="footer" class="dialog-footer" v-show="footShow">
<el-button @click="Cancel" v-if="cancelShow">{{ cancelText }}</el-button>
<el-button type="primary" @click="Submit" v-if="submitShow">{{ submitText }}</el-button>
</span>
<div v-else class="com_footer" v-show="footShow">
<slot name="footer" />
</div>
</el-dialog>
</template>
<script>
export default {
inheritAttrs: true,
props: {
footShow: {
type: Boolean,
default: true
},
cancelShow: {
type: Boolean,
default: true
},
cancelText: {
type: String,
default: '取消'
},
submitShow: {
type: Boolean,
default: true
},
submitText: {
type: String,
default: '确定'
},
closeOnClickModal: {
type: Boolean,
default: false
},
closeOnPressEscape: {
type: Boolean,
default: false
},
show: {
type: Boolean,
default: false
},
},
computed: {
visible: {
get() {
return this.show;
},
set(val) {
this.$emit("update:show", val);
}
}
},
methods: {
Cancel() {
this.$emit("Cancel");
},
Submit() {
this.$emit("Submit");
},
closed() {
this.$emit("closed");
},
open() {
this.$emit("open");
},
opened() {
this.$emit("opened");
},
}
};
</script>
<template>
<div class="test">
<el-button @click="handleClick" type="danger">点击显示</el-button>
<Dialog
title="规则克隆"
:show.sync="visible"
v-if="visible"
:before-close="handleClose"
width="60%"
@Cancel="resetCopyPopup"
@Submit="zz"
>
<div>内容</div>
</Dialog>
</div>
</template>
<script>
import Dialog from './dialog.vue'
export default {
components: {
Dialog
},
data() {
return {
visible: true
};
},
methods: {
zz() { },
resetCopyPopup() {
},
handleClick() {
this.visible = true;
},
handleClose(done) {
this.$confirm('确认关闭?')
.then(_ => {
done();
})
.catch(_ => { });
}
}
}
</script>
<style lang="scss" >
.dialog-footer {
padding: 10 px 20 px 20 px;
text-align: right;
box-sizing: border-box;
}
</style>
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· 单线程的Redis速度为什么快?
· 展开说说关于C#中ORM框架的用法!
· Pantheons:用 TypeScript 打造主流大模型对话的一站式集成库
· SQL Server 2025 AI相关能力初探