LoadingDialog.vue 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  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="700px"
  8. custom-class="loading-dialog-EL"
  9. align-center
  10. append-to-body
  11. >
  12. <div class="loading-content">
  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" style="display: none">{{ 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. goods_art_no: string
  51. msg_type: string
  52. name: string
  53. status: '等待处理' | '正在处理' | '处理完成' | '处理失败'
  54. current: number
  55. total: number
  56. error: number
  57. }
  58. interface Props {
  59. modelValue: boolean
  60. progress?: number
  61. message?: string
  62. disabledButton?: boolean
  63. buttonText?: string,
  64. requesting?: boolean
  65. useNewProgress?: boolean
  66. progressSteps?: StepData[]
  67. }
  68. const props = withDefaults(defineProps<Props>(), {
  69. progress: 0,
  70. message: '正在为您处理,请稍后...',
  71. disabledButton: true,
  72. buttonText: '处理完毕,点击打开最终图片目录',
  73. requesting: false,
  74. useNewProgress: false,
  75. progressSteps: () => []
  76. })
  77. const emit = defineEmits<{
  78. (e: 'update:modelValue', value: boolean): void
  79. (e: 'button-click'): void
  80. }>()
  81. const visible = ref(props.modelValue)
  82. // 监听visible变化
  83. watch(() => visible.value, (newVal) => {
  84. emit('update:modelValue', newVal)
  85. })
  86. // 监听props.modelValue变化
  87. watch(() => props.modelValue, (newVal) => {
  88. visible.value = newVal
  89. })
  90. const handleButtonClick = () => {
  91. emit('button-click')
  92. }
  93. </script>
  94. <style lang="scss">
  95. .loading-dialog-EL{
  96. border-radius: 10px;
  97. .el-dialog__header {
  98. display: none;
  99. padding: 0;
  100. }
  101. .el-dialog__body {
  102. // background-image: url(@/assets/images/Photography/loading-bg.png); /* 添加背景图片 */
  103. background-size: cover; /* 确保图片覆盖整个区域 */
  104. background-position: center; /* 图片居中显示 */
  105. background-repeat: no-repeat; /* 防止图片重复 */
  106. padding: 20px 20px; /* 添加内边距 */
  107. }
  108. }
  109. </style>
  110. <style lang="scss" scoped>
  111. .loading-dialog {
  112. :deep(.el-dialog__header) {
  113. display: none;
  114. padding: 0;
  115. }
  116. :deep(.el-dialog__body) {
  117. padding:0;
  118. }
  119. }
  120. .loading-content {
  121. display: flex;
  122. flex-direction: column;
  123. align-items: center;
  124. text-align: center;
  125. }
  126. .progress-container {
  127. width: 100%;
  128. margin-bottom: 10px;
  129. display: flex;
  130. align-items: center;
  131. gap: 10px;
  132. .progress-bar {
  133. flex: 1;
  134. height: 6px;
  135. background: #E4E7ED;
  136. border-radius: 3px;
  137. overflow: hidden;
  138. .progress-inner {
  139. height: 100%;
  140. background: linear-gradient(90deg, #2FB0FF,#B863FB);
  141. border-radius: 3px;
  142. transition: width 0.3s ease;
  143. }
  144. }
  145. .progress-text {
  146. min-width: 45px;
  147. color: #606266;
  148. font-size: 14px;
  149. }
  150. }
  151. .message {
  152. color: #606266;
  153. font-size: 14px;
  154. margin-bottom: 0px;
  155. }
  156. .action-button {
  157. padding: 10px 20px;
  158. }
  159. </style>