ConfirmDialog2.vue 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. <template>
  2. <Modal
  3. :visible="visible"
  4. :width="width"
  5. :contentStyle="{ borderRadius: '15px' }"
  6. :closeButton="false"
  7. :closeOnClickMask="false"
  8. :closeOnEsc="false"
  9. @update:visible="handleVisibleChange"
  10. >
  11. <div class="clear-confirm">
  12. <div class="clear-confirm__title">{{ title }}</div>
  13. <div class="clear-confirm__content">
  14. {{ content }}
  15. </div>
  16. <div class="clear-confirm__footer">
  17. <div class="btn-c" @click="handleCancel">{{ cancelText }}</div>
  18. <div class="btn-c confirm" @click="handleConfirm">{{ confirmText }}</div>
  19. </div>
  20. </div>
  21. </Modal>
  22. </template>
  23. <script lang="ts" setup>
  24. import Modal from '@/components/Modal.vue'
  25. const props = withDefaults(defineProps<{
  26. visible: boolean
  27. title?: string
  28. content?: string
  29. confirmText?: string
  30. cancelText?: string
  31. width?: number
  32. }>(), {
  33. title: '提示',
  34. content: '',
  35. confirmText: '确认',
  36. cancelText: '取消',
  37. width: 400,
  38. })
  39. const emit = defineEmits<{
  40. (event: 'update:visible', payload: boolean): void
  41. (event: 'confirm'): void
  42. (event: 'cancel'): void
  43. }>()
  44. const handleVisibleChange = (val: boolean) => {
  45. emit('update:visible', val)
  46. }
  47. const handleConfirm = () => {
  48. emit('confirm')
  49. emit('update:visible', false)
  50. }
  51. const handleCancel = () => {
  52. emit('cancel')
  53. emit('update:visible', false)
  54. }
  55. </script>
  56. <style lang="scss" scoped>
  57. .btn-c {
  58. display: inline-block;
  59. line-height: 1;
  60. white-space: nowrap;
  61. cursor: pointer;
  62. background: #FFF;
  63. border: 1px solid #DCDFE6;
  64. color: #606266;
  65. text-align: center;
  66. box-sizing: border-box;
  67. outline: 0;
  68. margin: 0;
  69. transition: .1s;
  70. font-weight: 500;
  71. padding: 12px 20px;
  72. font-size: 14px;
  73. border-radius: 10px;
  74. +.btn-c {
  75. margin-left: 10px;
  76. }
  77. &.confirm {
  78. background: #FF9400;
  79. color: white;
  80. border: 1px solid #FF9400;
  81. &:hover {
  82. background: #FFA500;
  83. }
  84. }
  85. }
  86. </style>