LoadingDialog.vue 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. <template>
  2. <el-dialog
  3. v-model="visible"
  4. :show-close="false"
  5. :close-on-click-modal="false"
  6. :close-on-press-escape="false"
  7. width="400px"
  8. custom-class="loading-dialog-EL"
  9. align-center
  10. append-to-body
  11. >
  12. <div class="loading-content mar-top-10">
  13. <div class="progress-container">
  14. <div class="progress-bar">
  15. <div
  16. class="progress-inner"
  17. :style="{ width: `${progress}%` }"
  18. ></div>
  19. </div>
  20. <span class="progress-text">{{ progress }}%</span>
  21. </div>
  22. <div class="message">{{ message }}</div>
  23. <el-button
  24. :disabled="showButton"
  25. type="primary"
  26. class="action-button button--primary1 mar-top-20"
  27. @click="handleButtonClick"
  28. >
  29. {{ buttonText }}
  30. </el-button>
  31. </div>
  32. </el-dialog>
  33. </template>
  34. <script setup lang="ts">
  35. import { ref, defineProps, defineEmits , watch } from 'vue'
  36. interface Props {
  37. modelValue: boolean
  38. progress?: number
  39. message?: string
  40. showButton?: boolean
  41. buttonText?: string
  42. }
  43. const props = withDefaults(defineProps<Props>(), {
  44. progress: 0,
  45. message: '正在为您处理,请稍后',
  46. showButton: false,
  47. buttonText: '全部处理完毕,点击打开最终图片目录'
  48. })
  49. const emit = defineEmits<{
  50. (e: 'update:modelValue', value: boolean): void
  51. (e: 'button-click'): void
  52. }>()
  53. const visible = ref(props.modelValue)
  54. // 监听visible变化
  55. watch(() => visible.value, (newVal) => {
  56. emit('update:modelValue', newVal)
  57. })
  58. // 监听props.modelValue变化
  59. watch(() => props.modelValue, (newVal) => {
  60. visible.value = newVal
  61. })
  62. const handleButtonClick = () => {
  63. emit('button-click')
  64. }
  65. </script>
  66. <style>
  67. .loading-dialog-EL{
  68. .el-dialog__header {
  69. display: none;
  70. padding: 0;
  71. }
  72. .el-dialog__body {
  73. background-image: url(@/assets/images/Photography/loading-bg.png); /* 添加背景图片 */
  74. background-size: cover; /* 确保图片覆盖整个区域 */
  75. background-position: center; /* 图片居中显示 */
  76. background-repeat: no-repeat; /* 防止图片重复 */
  77. padding: 40px 20px; /* 添加内边距 */
  78. }
  79. }
  80. </style>
  81. <style lang="scss" scoped>
  82. .loading-dialog {
  83. :deep(.el-dialog__header) {
  84. display: none;
  85. padding: 0;
  86. }
  87. :deep(.el-dialog__body) {
  88. padding:0;
  89. }
  90. }
  91. .loading-content {
  92. display: flex;
  93. flex-direction: column;
  94. align-items: center;
  95. text-align: center;
  96. }
  97. .progress-container {
  98. width: 100%;
  99. margin-bottom: 20px;
  100. display: flex;
  101. align-items: center;
  102. gap: 10px;
  103. .progress-bar {
  104. flex: 1;
  105. height: 6px;
  106. background: #E4E7ED;
  107. border-radius: 3px;
  108. overflow: hidden;
  109. .progress-inner {
  110. height: 100%;
  111. background: linear-gradient(90deg, #2FB0FF,#B863FB);
  112. border-radius: 3px;
  113. transition: width 0.3s ease;
  114. }
  115. }
  116. .progress-text {
  117. min-width: 45px;
  118. color: #606266;
  119. font-size: 14px;
  120. }
  121. }
  122. .message {
  123. color: #606266;
  124. font-size: 14px;
  125. margin-bottom: 20px;
  126. }
  127. .action-button {
  128. padding: 10px 20px;
  129. }
  130. </style>