index.vue 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. <template>
  2. <teleport to="#dialog">
  3. <div class="dialog-bg" v-if="show">
  4. <div
  5. class="dialog"
  6. :class="{eh: height}"
  7. :style="{
  8. width: typeof width === 'number' ? width + 'px' : width,
  9. height: height ? (typeof height === 'number' ? height + 'px' : height) : 'auto',
  10. }"
  11. >
  12. <div class="head">
  13. <h3>{{ title }}</h3>
  14. <el-icon @click="closeHandle" v-if="showClose || cornerClose">
  15. <Close />
  16. </el-icon>
  17. </div>
  18. <div class="content">
  19. <slot />
  20. </div>
  21. <div class="floot" v-if="showFloor">
  22. <el-button type="danger" v-if="showDel" @click="deleteHandle">删 除</el-button>
  23. <el-button @click="closeHandle" v-if="showClose">取 消</el-button>
  24. <el-button type="primary" :disabled="!!disabled" @click="enterHandle">
  25. {{ enterText }}
  26. </el-button>
  27. </div>
  28. </div>
  29. </div>
  30. </teleport>
  31. </template>
  32. <script setup lang="ts">
  33. import { computed, ref, watch, watchEffect, nextTick } from "vue";
  34. import { user } from "@/store/user";
  35. import { operateIsPermissionByPath } from "@/directive/permission";
  36. import { DialogProps } from "./type";
  37. const props = withDefaults(defineProps<DialogProps>(), {
  38. width: 680,
  39. show: false,
  40. hideFloor: false,
  41. showClose: true,
  42. notSubmit: false,
  43. enterText: "保 存",
  44. });
  45. const emit = defineEmits<{
  46. (e: "update:show", show: boolean): void;
  47. (e: "quit"): void;
  48. (e: "submit"): void;
  49. (e: "delete"): void;
  50. }>();
  51. const showDel = ref(props.showDelete);
  52. const showFloor = computed(() => !props.hideFloor);
  53. const closeHandle = () => {
  54. emit("update:show", false);
  55. emit("quit");
  56. };
  57. const enterHandle = () => {
  58. emit("submit");
  59. };
  60. const deleteHandle = () => {
  61. emit("delete");
  62. };
  63. if (!showFloor.value && !props.notSubmit) {
  64. nextTick(() => enterHandle());
  65. }
  66. const disabled = computed(() => props.power && !operateIsPermissionByPath(props.power));
  67. </script>
  68. <style lang="scss" scoped>
  69. @import "./style.scss";
  70. </style>