1
0

index.vue 1.7 KB

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