123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778 |
- <template>
- <teleport to="#dialog">
- <div class="dialog-bg" v-if="show">
- <div
- class="dialog"
- :class="{eh: height}"
- :style="{
- width: typeof width === 'number' ? width + 'px' : width,
- height: height ? (typeof height === 'number' ? height + 'px' : height) : 'auto',
- }"
- >
- <div class="head">
- <h3>{{ title }}</h3>
- <el-icon @click="closeHandle" v-if="showClose || cornerClose">
- <Close />
- </el-icon>
- </div>
- <div class="content">
- <slot />
- </div>
- <div class="floot" v-if="showFloor">
- <el-button type="danger" v-if="showDel" @click="deleteHandle">删 除</el-button>
- <el-button @click="closeHandle" v-if="showClose">取 消</el-button>
- <el-button type="primary" :disabled="!!disabled" @click="enterHandle">
- {{ enterText }}
- </el-button>
- </div>
- </div>
- </div>
- </teleport>
- </template>
- <script setup lang="ts">
- import { computed, ref, watch, watchEffect, nextTick } from "vue";
- import { user } from "@/store/user";
- import { operateIsPermissionByPath } from "@/directive/permission";
- import { DialogProps } from "./type";
- const props = withDefaults(defineProps<DialogProps>(), {
- width: 680,
- show: false,
- hideFloor: false,
- showClose: true,
- notSubmit: false,
- enterText: "保 存",
- });
- const emit = defineEmits<{
- (e: "update:show", show: boolean): void;
- (e: "quit"): void;
- (e: "submit"): void;
- (e: "delete"): void;
- }>();
- const showDel = ref(props.showDelete);
- const showFloor = computed(() => !props.hideFloor);
- const closeHandle = () => {
- emit("update:show", false);
- emit("quit");
- };
- const enterHandle = () => {
- emit("submit");
- };
- const deleteHandle = () => {
- emit("delete");
- };
- if (!showFloor.value && !props.notSubmit) {
- nextTick(() => enterHandle());
- }
- const disabled = computed(() => props.power && !operateIsPermissionByPath(props.power));
- </script>
- <style lang="scss" scoped>
- @import "./style.scss";
- </style>
|