LoadingDialog.vue 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  1. <template>
  2. <el-dialog
  3. v-model="visible"
  4. :show-close="!requesting"
  5. :close-on-click-modal="false"
  6. :close-on-press-escape="false"
  7. width="1000px"
  8. custom-class="loading-dialog-EL"
  9. align-center
  10. append-to-body
  11. >
  12. <div class="loading-content mar-top-10">
  13. <!-- 新的步骤进度条 -->
  14. <ProgressSteps
  15. v-if="useNewProgress && progressSteps.length > 0"
  16. :steps="progressSteps"
  17. @complete="handleButtonClick"
  18. />
  19. <!-- 原有的简单进度条 -->
  20. <div v-else class="progress-container">
  21. <div class="progress-bar">
  22. <div
  23. class="progress-inner"
  24. :style="{ width: `${progress}%` }"
  25. ></div>
  26. </div>
  27. <span class="progress-text">{{ progress.toFixed(2) }}%</span>
  28. </div>
  29. <div class="message">{{ message }}</div>
  30. <!-- 错误信息插槽 -->
  31. <slot name="errList"></slot>
  32. <!-- 进度消息插槽 -->
  33. <slot name="progressMessages"></slot>
  34. <el-button
  35. v-if="!disabledButton && !useNewProgress"
  36. :disabled="disabledButton"
  37. type="primary"
  38. class="action-button button--primary1 mar-top-20"
  39. @click="handleButtonClick"
  40. >
  41. {{ buttonText }}
  42. </el-button>
  43. </div>
  44. </el-dialog>
  45. </template>
  46. <script setup lang="ts">
  47. import { ref, defineProps, defineEmits , watch } from 'vue'
  48. import ProgressSteps from './ProgressSteps.vue'
  49. interface StepData {
  50. msg_type: string
  51. name: string
  52. status: '等待处理' | '正在处理' | '处理完成' | '处理失败'
  53. current: number
  54. total: number
  55. error: number
  56. }
  57. interface Props {
  58. modelValue: boolean
  59. progress?: number
  60. message?: string
  61. disabledButton?: boolean
  62. buttonText?: string,
  63. requesting?: boolean
  64. useNewProgress?: boolean
  65. progressSteps?: StepData[]
  66. }
  67. const props = withDefaults(defineProps<Props>(), {
  68. progress: 0,
  69. message: '正在为您处理,请稍后...',
  70. disabledButton: true,
  71. buttonText: '处理完毕,点击打开最终图片目录',
  72. requesting: false,
  73. useNewProgress: false,
  74. progressSteps: () => []
  75. })
  76. const emit = defineEmits<{
  77. (e: 'update:modelValue', value: boolean): void
  78. (e: 'button-click'): void
  79. }>()
  80. const visible = ref(props.modelValue)
  81. // 监听visible变化
  82. watch(() => visible.value, (newVal) => {
  83. emit('update:modelValue', newVal)
  84. })
  85. // 监听props.modelValue变化
  86. watch(() => props.modelValue, (newVal) => {
  87. visible.value = newVal
  88. })
  89. const handleButtonClick = () => {
  90. emit('button-click')
  91. }
  92. </script>
  93. <style>
  94. .loading-dialog-EL{
  95. .el-dialog__header {
  96. display: none;
  97. padding: 0;
  98. }
  99. .el-dialog__body {
  100. background-image: url(@/assets/images/Photography/loading-bg.png); /* 添加背景图片 */
  101. background-size: cover; /* 确保图片覆盖整个区域 */
  102. background-position: center; /* 图片居中显示 */
  103. background-repeat: no-repeat; /* 防止图片重复 */
  104. padding: 40px 20px; /* 添加内边距 */
  105. }
  106. }
  107. </style>
  108. <style lang="scss" scoped>
  109. .loading-dialog {
  110. :deep(.el-dialog__header) {
  111. display: none;
  112. padding: 0;
  113. }
  114. :deep(.el-dialog__body) {
  115. padding:0;
  116. }
  117. }
  118. .loading-content {
  119. display: flex;
  120. flex-direction: column;
  121. align-items: center;
  122. text-align: center;
  123. }
  124. .progress-container {
  125. width: 100%;
  126. margin-bottom: 10px;
  127. display: flex;
  128. align-items: center;
  129. gap: 10px;
  130. .progress-bar {
  131. flex: 1;
  132. height: 6px;
  133. background: #E4E7ED;
  134. border-radius: 3px;
  135. overflow: hidden;
  136. .progress-inner {
  137. height: 100%;
  138. background: linear-gradient(90deg, #2FB0FF,#B863FB);
  139. border-radius: 3px;
  140. transition: width 0.3s ease;
  141. }
  142. }
  143. .progress-text {
  144. min-width: 45px;
  145. color: #606266;
  146. font-size: 14px;
  147. }
  148. }
  149. .message {
  150. color: #606266;
  151. font-size: 14px;
  152. margin-bottom: 0px;
  153. }
  154. .action-button {
  155. padding: 10px 20px;
  156. }
  157. </style>