StepMethod.vue 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  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. console.log(steps.value, '组件内');
  44. }
  45. function nextStep() {
  46. if (activeStep.value > 0 && activeStep.value < steps.value.length) {
  47. const prevStep = steps.value[activeStep.value - 1];
  48. if (prevStep.status === "2") {
  49. activeStep.value++;
  50. } else {
  51. // ElMessage({
  52. // message: prevStep.msg || '前一步骤未完成',
  53. // type: "error"
  54. // });
  55. }
  56. } else if (activeStep.value === 0) {
  57. // 如果当前是第一步,直接跳到第二步,或者根据需要处理其他逻辑
  58. activeStep.value = 1;
  59. } else {
  60. console.log("无法进行下一步,索引越界");
  61. }
  62. }
  63. // 2完成,1检测中,0未开始
  64. function setStatus(num) {
  65. if (num == 1) {
  66. return 'wait'
  67. } else if (num == 2) {
  68. return 'success'
  69. } else if (num == 0) {
  70. return "process"
  71. } else if (num == 3) {
  72. return 'error'
  73. }
  74. }
  75. onMounted(() => {
  76. reload()
  77. // setInterval(() => {
  78. // nextStep()
  79. // }, 1000);
  80. })
  81. return {
  82. activeStep,
  83. steps,
  84. nextStep,
  85. setStatus,
  86. Loading,
  87. };
  88. },
  89. };
  90. </script>
  91. <style scoped>
  92. /* */
  93. :deep(.el-step.is-vertical .el-step__title) {
  94. font-size: 14px;
  95. font-family: Source Han Sans CN, Source Han Sans CN;
  96. font-weight: 400;
  97. color: #1A2447;
  98. }
  99. </style>