progressBox.vue 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. <template>
  2. <div class="progress-container">
  3. <ul>
  4. <li
  5. v-for="(item, index) in list"
  6. :key="index"
  7. :class="{ active: active >= index }"
  8. >
  9. <div class="progress-box">
  10. {{index+1}}
  11. </div>
  12. <p class="name">{{ item.name }}</p>
  13. </li>
  14. </ul>
  15. </div>
  16. </template>
  17. <script>
  18. export default {
  19. props: {
  20. // active: {
  21. // type: [Number, String],
  22. // default: 3
  23. // },
  24. list:{
  25. type: Array,
  26. default: []
  27. },
  28. },
  29. data () {
  30. return {
  31. stepList: [],
  32. active:2
  33. };
  34. },
  35. watch: {
  36. list: {
  37. handler () {
  38. // if (this.list.length) {
  39. // this.stepList = this.list
  40. // this.stepList.map((item,index)=>{
  41. // item.percent = ( item.number / this.total)*100 + '%'
  42. // })
  43. // const active = this.stepList.findIndex((item) => item.number === 0)
  44. // if(active==-1){
  45. // this.active = this.stepList.length-1
  46. // }
  47. // }
  48. },
  49. immediate: true
  50. }
  51. },
  52. methods:{
  53. }
  54. };
  55. </script>
  56. <style lang="scss" scoped>
  57. .progress-container {
  58. width: 100%;
  59. overflow-x: auto;
  60. ul {
  61. list-style: none;
  62. display: flex;
  63. justify-content: flex-start;
  64. align-items: center;
  65. padding: 0 10rpx;
  66. li {
  67. display: flex;
  68. flex-wrap: wrap;
  69. justify-content: center;
  70. flex: 1;
  71. position: relative;
  72. min-width: 110px;
  73. &::after {
  74. content: '';
  75. position: absolute;
  76. left: 0;
  77. right: 0;
  78. top: 38%;
  79. transform: translateY(-50%);
  80. height: 1px;
  81. background-color: #ccc;
  82. }
  83. &:first-of-type::after {
  84. left: 50%;
  85. }
  86. &:last-of-type::after {
  87. right: 50%;
  88. }
  89. &.active {
  90. &::after {
  91. background-color:#157a2c;
  92. }
  93. .progress-box {
  94. border-color:#157a2c;
  95. display: flex;
  96. align-items: center;
  97. justify-content: center;
  98. color: #fff;
  99. background:#157a2c;
  100. }
  101. }
  102. .el-tooltip{
  103. width: 100%;
  104. text-align: center;
  105. white-space: nowrap; /* 不换行 */
  106. overflow: hidden; /* 超出部分隐藏 */
  107. text-overflow: ellipsis; /* 显示省略号 */
  108. }
  109. .name{
  110. width: 100%;
  111. text-align: center;
  112. color: #157a2c;
  113. }
  114. .progress-box {
  115. position: relative;
  116. z-index: 1;
  117. width: 32px;
  118. height: 32px;
  119. margin: 10px 0;
  120. border-radius: 50%;
  121. background: #fff;
  122. border: 1px solid #ccc;
  123. display: flex;
  124. align-items: center;
  125. justify-content: center;
  126. color: #ccc;
  127. }
  128. }
  129. }
  130. }
  131. </style>