Dialog.vue 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. <template>
  2. <div class="page_dialog">
  3. <el-dialog
  4. @close="closeDialog"
  5. v-model="props.visible"
  6. :width="props.width ? props.width : '420px'"
  7. :close-on-click-modal="false"
  8. >
  9. <div class="dialog_default">
  10. <slot name="default" >
  11. 是否确认删除?
  12. </slot>
  13. </div>
  14. <template #header>
  15. <div class="custom_header">
  16. <img :src="warnIcon" alt="">
  17. <span>{{ props.title }}</span>
  18. </div>
  19. </template>
  20. <template #footer>
  21. <el-button class="button_border_gray cancel" @click="closeDialog">取 消</el-button>
  22. <el-button class="button_background" :loading="props.submitLoading" @click="handleConfirm(formRef)">确 定</el-button>
  23. </template>
  24. </el-dialog>
  25. </div>
  26. </template>
  27. <script setup lang="ts">
  28. import warnIcon from '@/assets/icon/warn.svg'
  29. const emit = defineEmits(['close','confirm'])
  30. const props = defineProps({
  31. visible:{
  32. type:Boolean,
  33. required:true
  34. },
  35. title:{
  36. type:String,
  37. default:'提示'
  38. },
  39. submitLoading:{
  40. type:Boolean,
  41. default:false,
  42. required:true
  43. },
  44. width:{
  45. type:String,
  46. required:false
  47. }
  48. })
  49. const closeDialog = () => {
  50. emit('close')
  51. }
  52. const handleConfirm = ()=>{
  53. emit('confirm')
  54. }
  55. </script>
  56. <style lang="scss" scoped>
  57. .dialog_default{
  58. text-align: center;
  59. color: #666;
  60. display: flex;
  61. flex-direction: column;
  62. gap: 20px;
  63. }
  64. .custom_header{
  65. display: flex;
  66. align-items: center;
  67. padding: 0 20px;
  68. gap: 10px;
  69. text-indent: 0;
  70. font-weight: bold;
  71. img{
  72. width: 25px;
  73. }
  74. }
  75. .page_dialog{
  76. :deep(.el-dialog){
  77. .el-dialog__body{
  78. min-height: calc(120px);
  79. display: flex;
  80. justify-content: center;
  81. align-items: center;
  82. }
  83. }
  84. }
  85. </style>