index.vue 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  1. <template>
  2. <el-dialog
  3. v-model="visible"
  4. :title="title"
  5. :close-on-click-modal="false"
  6. width="500px"
  7. class="hardware-check-dialog"
  8. >
  9. <div class="hardware-check-container">
  10. <el-timeline>
  11. <!-- Step 1 -->
  12. <el-timeline-item
  13. :type="'primary'"
  14. :hollow="true">
  15. <template #dot>
  16. <img src="@/assets/images/check/icon1.png" class="custom-timeline-icon" />
  17. </template>
  18. <div class="step-content">
  19. <div class="step-title">
  20. <template v-if="checkLoading">正在初始化检测硬件......</template>
  21. <template v-else-if="checkSuccess">硬件检测完成</template>
  22. <template v-else>初始化检测硬件失败</template>
  23. </div>
  24. <el-progress
  25. :percentage="progress"
  26. :colors="['#2FB0FF', '#B863FB']"
  27. :stroke-width="8"
  28. v-if="checkLoading"
  29. ></el-progress>
  30. <div class="check-error-result" v-else-if="!checkSuccess">失败的原因,比如请检查硬件链接</div>
  31. </div>
  32. </el-timeline-item>
  33. <!-- Step 2 -->
  34. <el-timeline-item
  35. :type="'primary'"
  36. :hollow="true">
  37. <template #dot>
  38. <img src="@/assets/images/check/icon2.png" class="custom-timeline-icon" />
  39. </template>
  40. <div class="step-content">
  41. <div class="step-title">自我检查</div>
  42. <div class="check-result">
  43. <p>补光灯电源和链接器是否正常连上。</p>
  44. <p>请检查红外线器是否正常显示。</p>
  45. </div>
  46. </div>
  47. </el-timeline-item>
  48. </el-timeline>
  49. </div>
  50. <template #footer v-if="!checkLoading">
  51. <div class="flex" v-if="!checkSuccess">
  52. <div class="check-btn" @click="reCheck">重新监测</div>
  53. </div>
  54. <div class="flex" v-else>
  55. <div class="check-btn">正常,开始下一步</div>
  56. </div>
  57. </template>
  58. </el-dialog>
  59. </template>
  60. <script setup>
  61. import { ref, computed, watch, onBeforeUnmount, nextTick } from 'vue';
  62. const props = defineProps({
  63. modelValue: {
  64. type: Boolean,
  65. default: false
  66. },
  67. title: {
  68. type: String,
  69. default: '检测硬件'
  70. }
  71. });
  72. const checkSuccess = ref(false);
  73. const checkLoading = ref(false)
  74. const emit = defineEmits(['update:modelValue', 'confirm']);
  75. const progress = ref(80);
  76. let timer = null;
  77. const visible = computed({
  78. get() {
  79. return props.modelValue;
  80. },
  81. set(val) {
  82. emit('update:modelValue', val);
  83. }
  84. });
  85. function startProgress() {
  86. progress.value = 0;
  87. checkLoading.value = true;
  88. timer = setInterval(() => {
  89. if (progress.value < 80) {
  90. progress.value += 1;
  91. } else {
  92. checkSuccess.value = false;
  93. clearInterval(timer);
  94. }
  95. }, 50);
  96. }
  97. function reCheck() {
  98. startProgress();
  99. }
  100. function handleConfirm() {
  101. emit('confirm');
  102. visible.value = false;
  103. }
  104. watch(visible, (val) => {
  105. if (val) {
  106. nextTick(() => {
  107. startProgress();
  108. });
  109. } else {
  110. clearInterval(timer);
  111. }
  112. });
  113. onBeforeUnmount(() => {
  114. clearInterval(timer);
  115. });
  116. </script>
  117. <style lang="scss" scoped>
  118. .hardware-check-container {
  119. padding: 20px 0;
  120. }
  121. .step-content {
  122. flex: 1;
  123. }
  124. .step-title {
  125. font-weight: 600;
  126. font-size: 14px;
  127. color: #000000;
  128. margin-bottom: 15px;
  129. padding-top: 4px;
  130. text-align: left;
  131. }
  132. .progress-text {
  133. text-align: right;
  134. margin-top: 5px;
  135. color: #606266;
  136. }
  137. .check-result {
  138. color: rgba(0,0,0,0.45);
  139. text-align: left;
  140. p {
  141. margin: 8px 0;
  142. }
  143. }
  144. :deep(.el-progress-bar__inner) {
  145. background-image: linear-gradient(to right, #409EFF, #7e57c2);
  146. }
  147. .custom-timeline-icon{
  148. width: 24px;
  149. height: 24px;
  150. position: relative;
  151. left: -7px;
  152. }
  153. .check-btn{
  154. width: 100px;
  155. height: 40px;
  156. background: linear-gradient( 135deg, #2FB0FF 0%, #B863FB 100%);
  157. border-radius: 4px;
  158. font-weight: 400;
  159. font-size: 16px;
  160. color: #FFFFFF;
  161. text-align: center;
  162. line-height: 40px;
  163. }
  164. .check-error-result{
  165. font-size: 14px;
  166. text-align: left;
  167. color: #FF4C00;
  168. }
  169. </style>