|
|
|
@ -0,0 +1,103 @@
|
|
|
|
|
<!-- 封装弹框组件 -->
|
|
|
|
|
<template>
|
|
|
|
|
<el-dialog
|
|
|
|
|
:model-value="visible"
|
|
|
|
|
:title="title"
|
|
|
|
|
:width="width"
|
|
|
|
|
:height="height + 'px'"
|
|
|
|
|
append-to-body
|
|
|
|
|
:before-close="onClose"
|
|
|
|
|
>
|
|
|
|
|
<!-- 弹框内容通过插槽实现 -->
|
|
|
|
|
<div class="container" :style="{height: height + 'px'}">
|
|
|
|
|
<slot name="content"></slot>
|
|
|
|
|
</div>
|
|
|
|
|
<template #footer>
|
|
|
|
|
<div class="dialog-footer">
|
|
|
|
|
<el-button type="danger" @click="onClose">取消</el-button>
|
|
|
|
|
<el-button type="primary" @click="onConfirm">
|
|
|
|
|
确定
|
|
|
|
|
</el-button>
|
|
|
|
|
</div>
|
|
|
|
|
</template>
|
|
|
|
|
</el-dialog>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<script setup lang="ts">
|
|
|
|
|
// 定义参数类型
|
|
|
|
|
// 定义为可选参数
|
|
|
|
|
interface DialogProps{
|
|
|
|
|
// 弹框标题
|
|
|
|
|
title?: string;
|
|
|
|
|
// 弹框显示&隐藏
|
|
|
|
|
visible: boolean;
|
|
|
|
|
// 弹框宽高
|
|
|
|
|
width?: number;
|
|
|
|
|
height?: number;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 子组件接收父组件传递的参数
|
|
|
|
|
// withDefaults指定默认值
|
|
|
|
|
// defineProps接收父组件传递参数值
|
|
|
|
|
const props = withDefaults(defineProps<DialogProps>(),{
|
|
|
|
|
title: '标题',
|
|
|
|
|
visible: false,
|
|
|
|
|
width: 630,
|
|
|
|
|
height: 280
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
// 注册方法,在子组件中调用
|
|
|
|
|
const emits = defineEmits(['onClose','onConfirm'])
|
|
|
|
|
// 定义onClose方法,弹框关闭
|
|
|
|
|
const onClose = ()=>{
|
|
|
|
|
emits('onClose')
|
|
|
|
|
}
|
|
|
|
|
// 定义onConfirm方法,弹框确定
|
|
|
|
|
const onConfirm = ()=>{
|
|
|
|
|
emits('onConfirm')
|
|
|
|
|
}
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<style lang="scss">
|
|
|
|
|
.container{
|
|
|
|
|
overflow-x: initial;
|
|
|
|
|
overflow-y: auto;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.el-dialog{
|
|
|
|
|
border-top-left-radius: 7px !important;
|
|
|
|
|
border-top-right-radius: 7px !important;
|
|
|
|
|
padding: 0 !important;
|
|
|
|
|
.el-dialog__header{
|
|
|
|
|
padding-right: 0;
|
|
|
|
|
|
|
|
|
|
border-top-left-radius: 7px !important;
|
|
|
|
|
border-top-right-radius: 7px !important;
|
|
|
|
|
background-color: #009688 !important;
|
|
|
|
|
|
|
|
|
|
.el-dialog__title{
|
|
|
|
|
color: #fff;
|
|
|
|
|
font-size: 16px;
|
|
|
|
|
font-weight: 600;
|
|
|
|
|
line-height: 40px;
|
|
|
|
|
margin-left: 10px;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.el-dialog__headerbtn{
|
|
|
|
|
.el-dialog__close{
|
|
|
|
|
color: #fff;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.el-dialog__body{
|
|
|
|
|
padding: 10px;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.el-dialog__footer{
|
|
|
|
|
border-top: 1px solid #e8eaec !important;
|
|
|
|
|
padding: 10px;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
</style>
|