LoadingDialog.vue 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188
  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. <ProgressSteps
  14. v-if="useNewProgress && progressSteps.length > 0"
  15. :steps="progressSteps"
  16. :disabled-button="disabledButton"
  17. :use-new-progress="useNewProgress"
  18. @complete="handleButtonClick"
  19. :on-open-folder="onOpenFolder"
  20. :message="message"
  21. />
  22. <div v-else class="progress-container">
  23. <div class="progress-bar">
  24. <div
  25. class="progress-inner"
  26. :style="{ width: `${progress}%` }"
  27. ></div>
  28. </div>
  29. <span class="progress-text">{{ progress.toFixed(2) }}%</span>
  30. </div>
  31. <div class="message" style="display: none">{{ message }}</div>
  32. <slot name="errList"></slot>
  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. <el-button
  44. v-if="message === '全部货号生成失败'"
  45. type="primary"
  46. class="action-button button--primary1 mar-top-20"
  47. @click="visible = false"
  48. >
  49. {{ message }}
  50. </el-button>
  51. </div>
  52. </el-dialog>
  53. </template>
  54. <script setup lang="ts">
  55. import { ref, defineProps, defineEmits , watch } from 'vue'
  56. import ProgressSteps from './ProgressSteps.vue'
  57. interface StepData {
  58. goods_art_no: string
  59. msg_type: string
  60. name: string
  61. status: '等待处理' | '正在处理' | '处理完成' | '处理失败'
  62. current: number
  63. total: number
  64. error: number
  65. folder?: string
  66. }
  67. interface Props {
  68. modelValue: boolean
  69. progress?: number
  70. message?: string
  71. disabledButton?: boolean
  72. buttonText?: string
  73. requesting?: boolean
  74. useNewProgress?: boolean
  75. progressSteps?: StepData[]
  76. onOpenFolder?: (folder: string) => void
  77. }
  78. const props = withDefaults(defineProps<Props>(), {
  79. progress: 0,
  80. message: '正在为您处理,请稍后...',
  81. disabledButton: true,
  82. buttonText: '处理完毕,点击打开最终图片目录',
  83. requesting: false,
  84. useNewProgress: false,
  85. progressSteps: () => [],
  86. onOpenFolder: () => {}
  87. })
  88. const emit = defineEmits<{
  89. (e: 'update:modelValue', value: boolean): void
  90. (e: 'button-click'): void
  91. }>()
  92. const visible = ref(props.modelValue)
  93. watch(() => visible.value, (newVal) => {
  94. emit('update:modelValue', newVal)
  95. })
  96. watch(() => props.modelValue, (newVal) => {
  97. visible.value = newVal
  98. })
  99. const handleButtonClick = () => {
  100. emit('button-click')
  101. }
  102. </script>
  103. <style lang="scss">
  104. .loading-dialog-EL{
  105. border-radius: 10px;
  106. .el-dialog__header {
  107. display: none;
  108. padding: 0;
  109. }
  110. .el-dialog__body {
  111. background-size: cover;
  112. background-position: center;
  113. background-repeat: no-repeat;
  114. padding: 20px 20px;
  115. }
  116. }
  117. </style>
  118. <style lang="scss" scoped>
  119. .loading-dialog {
  120. :deep(.el-dialog__header) {
  121. display: none;
  122. padding: 0;
  123. }
  124. :deep(.el-dialog__body) {
  125. padding:0;
  126. }
  127. }
  128. .loading-content {
  129. display: flex;
  130. flex-direction: column;
  131. align-items: center;
  132. text-align: center;
  133. }
  134. .progress-container {
  135. width: 100%;
  136. margin-bottom: 10px;
  137. display: flex;
  138. align-items: center;
  139. gap: 10px;
  140. .progress-bar {
  141. flex: 1;
  142. height: 6px;
  143. background: #E4E7ED;
  144. border-radius: 3px;
  145. overflow: hidden;
  146. .progress-inner {
  147. height: 100%;
  148. background: linear-gradient(90deg, #2FB0FF,#B863FB);
  149. border-radius: 3px;
  150. transition: width 0.3s ease;
  151. }
  152. }
  153. .progress-text {
  154. min-width: 45px;
  155. color: #606266;
  156. font-size: 14px;
  157. }
  158. }
  159. .message {
  160. color: #606266;
  161. font-size: 14px;
  162. margin-bottom: 0px;
  163. }
  164. .action-button {
  165. padding: 10px 20px;
  166. }
  167. </style>