AdminAlertModal.vue 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. <template>
  2. <Teleport to="body">
  3. <Transition name="modal-fade">
  4. <div class="admin--modal-overlay admin--alert-overlay" @click.self="handleClose">
  5. <div class="admin--modal admin--modal-sm admin--alert-modal admin--form-modal">
  6. <div class="admin--modal-header">
  7. <h4>{{ title }}</h4>
  8. <button
  9. v-if="!hideClose"
  10. @click="handleClose"
  11. class="admin--modal-close"
  12. >&times;</button>
  13. </div>
  14. <div class="admin--modal-body">
  15. <div class="admin--alert-content">
  16. <p>{{ message }}</p>
  17. </div>
  18. </div>
  19. <div class="admin--modal-footer">
  20. <button
  21. v-if="type === 'confirm'"
  22. @click="handleCancel"
  23. class="admin--btn"
  24. >
  25. 취소
  26. </button>
  27. <button
  28. @click="handleConfirm"
  29. class="admin--btn admin--btn-primary-fill ml--auto"
  30. >
  31. 확인
  32. </button>
  33. </div>
  34. </div>
  35. </div>
  36. </Transition>
  37. </Teleport>
  38. </template>
  39. <script setup>
  40. const props = defineProps({
  41. title: {
  42. type: String,
  43. default: '알림'
  44. },
  45. message: {
  46. type: String,
  47. required: true
  48. },
  49. type: {
  50. type: String,
  51. default: 'alert', // 'alert' or 'confirm'
  52. validator: (value) => ['alert', 'confirm'].includes(value)
  53. },
  54. hideClose: {
  55. type: Boolean,
  56. default: false
  57. }
  58. })
  59. const emit = defineEmits(['confirm', 'cancel', 'close'])
  60. const handleConfirm = () => {
  61. emit('confirm')
  62. emit('close')
  63. }
  64. const handleCancel = () => {
  65. emit('cancel')
  66. emit('close')
  67. }
  68. const handleClose = () => {
  69. if (!props.hideClose) {
  70. emit('close')
  71. }
  72. }
  73. </script>