自定义弹窗组件

This commit is contained in:
2023-02-09 21:56:24 +08:00
parent a79902651a
commit 5751c38429
2 changed files with 37 additions and 16 deletions

View File

@@ -17,7 +17,7 @@
</template> </template>
</ku-table> </ku-table>
</ku-layout> </ku-layout>
<el-dialog title="编辑菜单" v-model="dialog" draggable @close="form={}" width="500"> <ku-dialog title="编辑菜单" v-model="dialog" draggable @close="form={}" width="500">
<el-form ref="MenuForm" :model="form" label-width="80px" :rules="rules"> <el-form ref="MenuForm" :model="form" label-width="80px" :rules="rules">
<el-form-item label="菜单名称" prop="name"> <el-form-item label="菜单名称" prop="name">
<el-input v-model="form.name" placeholder="请输入" clearable/> <el-input v-model="form.name" placeholder="请输入" clearable/>
@@ -56,7 +56,7 @@
<el-input v-model="form.showIndex" placeholder="请输入" clearable/> <el-input v-model="form.showIndex" placeholder="请输入" clearable/>
</el-form-item> </el-form-item>
</el-form> </el-form>
</el-dialog> </ku-dialog>
</section> </section>
</template> </template>
@@ -65,10 +65,11 @@ import KuLayout from "../components/KuLayout";
import KuSearchBar from "../components/KuSearchBar"; import KuSearchBar from "../components/KuSearchBar";
import KuTable from "../components/KuTable"; import KuTable from "../components/KuTable";
import KuSelect from "../components/KuSelect"; import KuSelect from "../components/KuSelect";
import KuDialog from "../components/KuDialog";
export default { export default {
name: "AppMenu", name: "AppMenu",
components: {KuSelect, KuTable, KuSearchBar, KuLayout}, components: {KuDialog, KuSelect, KuTable, KuSearchBar, KuLayout},
label: "菜单管理", label: "菜单管理",
data() { data() {
return { return {

View File

@@ -1,6 +1,14 @@
<template> <template>
<section class="KuDialog" v-if="show"> <section class="KuDialog">
<div class="modal" v-if="modal"/> <el-dialog :modelValue="modelValue" v-bind="$attrs" :modal="modal" :draggable="draggable">
<slot/>
<template #footer>
<el-row justify="center">
<el-button @click="$emit('update:modelValue',false)">取消</el-button>
<el-button type="primary" @click="handleConfirm">确定</el-button>
</el-row>
</template>
</el-dialog>
</section> </section>
</template> </template>
@@ -8,13 +16,18 @@
export default { export default {
name: "KuDialog", name: "KuDialog",
props: { props: {
show: Boolean, modelValue: Boolean,
modal: {type: Boolean, default: true} modal: {type: Boolean, default: true},
draggable: {default: true}
}, },
data() { data() {
return {} return {}
}, },
methods: {}, methods: {
handleConfirm() {
this.$emit("confirm")
}
},
created() { created() {
} }
} }
@@ -22,15 +35,22 @@ export default {
<style lang="scss" scoped> <style lang="scss" scoped>
.KuDialog { .KuDialog {
position: fixed; :deep(.el-dialog__header) {
z-index: 6800; border-bottom: 1px solid #ddd;
margin-right: 0;
.modal { .el-dialog__title {
position: fixed; font-weight: bold;
background: rgba(#000, .2); }
z-index: 6700; }
:deep(.el-dialog__footer) {
background-color: var(--background-color);
padding: 16px;
.el-button {
width: 92px;
}
} }
} }
</style> </style>