You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

76 lines
1.3 KiB

3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
  1. <script setup lang="ts">
  2. import { ref, watch } from 'vue'
  3. const props = defineProps({
  4. title: {
  5. type: String,
  6. default: '',
  7. },
  8. visible: {
  9. type: Boolean,
  10. default: false,
  11. },
  12. width: {
  13. type: String,
  14. default: '50%',
  15. },
  16. okHandle: {
  17. type: Boolean,
  18. default: () => {},
  19. },
  20. })
  21. const emits = defineEmits(['update:visible', 'ok', 'cancel'])
  22. const cancel = () => {
  23. show.value = false
  24. emits('cancel')
  25. }
  26. const show = ref(false)
  27. watch(
  28. () => props.visible,
  29. (newVal) => {
  30. show.value = newVal
  31. },
  32. {
  33. // 对于对象需要深度监听
  34. deep: true,
  35. immediate: true,
  36. },
  37. )
  38. </script>
  39. <template>
  40. <el-dialog
  41. v-model="show"
  42. center
  43. :close-on-click-modal="false"
  44. :close-on-press-escape="false"
  45. :show-close="false"
  46. destroy-on-close
  47. append-to-body
  48. :title="title"
  49. :width="width"
  50. :before-close="cancel"
  51. >
  52. <slot />
  53. <template #footer>
  54. <div v-if="$slots.footer" class="dialog-footer">
  55. <slot name="footer" />
  56. </div>
  57. <div v-else class="dialog-footer">
  58. <ft-button :click-handle="cancel">
  59. 取消
  60. </ft-button>
  61. <ft-button type="primary" :click-handle="okHandle">
  62. 确认
  63. </ft-button>
  64. </div>
  65. </template>
  66. </el-dialog>
  67. </template>
  68. <style scoped lang="scss">
  69. </style>