StepMethod.vue 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. <template>
  2. <div>
  3. <div class="bigBox">
  4. <div style="display: flex;justify-content: flex-start;align-items: center;">
  5. <img style="display: block;" src="../../../assets/icon/point.png" alt="">
  6. <span style="display: block;font-size: 14px;font-size: 16px;font-weight: 400;">检测详情</span>
  7. </div>
  8. <el-steps space="10px" finish-status="success" process-status="wait" direction="vertical">
  9. <el-step v-for="(step, index) in steps" :status="setStatus(step.status)" :key="index"
  10. :description="step.description" :title="step.title">
  11. {{ step.content }}
  12. </el-step>
  13. </el-steps>
  14. <!-- <el-button @click="nextStep">下一步</el-button> -->
  15. </div>
  16. </div>
  17. </template>
  18. <script>
  19. import { ref, onMounted, toRefs, watch } from "vue";
  20. import { Edit, Picture, Upload, Loading } from '@element-plus/icons-vue'
  21. import { ElMessage } from "element-plus";
  22. export default {
  23. props: {
  24. stepList: {
  25. type: Array,
  26. required: true,
  27. }
  28. },
  29. setup(props, { emit }) {
  30. let activeStep = ref(0); // 当前激活的步骤
  31. let steps = ref([])
  32. watch(() => props.stepList, (newVal) => {
  33. steps.value = newVal.map((item, index) => {
  34. return {
  35. title: item.step_name,
  36. description: item.state_msg,
  37. status: item.state,
  38. msg: item.state_msg
  39. }
  40. })
  41. })
  42. function reload() {
  43. steps.value = props.stepList.map((item, index) => {
  44. return {
  45. title: item.step_name,
  46. description: item.state_msg,
  47. status: item.state,
  48. msg: item.state_msg
  49. }
  50. })
  51. console.log(steps.value,'steps');
  52. }
  53. function nextStep() {
  54. if (activeStep.value > 0 && activeStep.value < steps.value.length) {
  55. const prevStep = steps.value[activeStep.value - 1];
  56. if (prevStep.status === "2") {
  57. activeStep.value++;
  58. } else {
  59. // ElMessage({
  60. // message: prevStep.msg || '前一步骤未完成',
  61. // type: "error"
  62. // });
  63. }
  64. } else if (activeStep.value === 0) {
  65. // 如果当前是第一步,直接跳到第二步,或者根据需要处理其他逻辑
  66. activeStep.value = 1;
  67. } else {
  68. console.log("无法进行下一步,索引越界");
  69. }
  70. }
  71. // 2完成,1检测中,0未开始
  72. function setStatus(num) {
  73. if (num == 1) {
  74. return 'wait'
  75. } else if (num == 2) {
  76. return 'success'
  77. } else if (num == 0) {
  78. return "process"
  79. } else if (num == 3) {
  80. return 'error'
  81. }
  82. }
  83. onMounted(() => {
  84. reload()
  85. // setInterval(() => {
  86. // nextStep()
  87. // }, 1000);
  88. })
  89. return {
  90. activeStep,
  91. steps,
  92. nextStep,
  93. setStatus,
  94. Loading,
  95. };
  96. },
  97. };
  98. </script>
  99. <style scoped>
  100. /* */
  101. :deep(.el-step.is-vertical .el-step__title) {
  102. font-size: 14px;
  103. font-family: Source Han Sans CN, Source Han Sans CN;
  104. font-weight: 400;
  105. color: #1A2447;
  106. }
  107. </style>