AdminAlertModal.vue 1.6 KB

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