u-steps.vue 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233
  1. <template>
  2. <view class="">
  3. <view class="u-steps" :style="{
  4. flexDirection: direction
  5. }">
  6. <view class="u-steps__item" :class="['u-steps__item--' + direction]" v-for="(item, index) in list"
  7. :key="index">
  8. <view class="u-steps__item__num" v-if="mode == 'number' && item.processingStatus!=3" :style="{
  9. backgroundColor: current < index ? 'transparent' : activeColor,
  10. borderColor: current < index ? unActiveColor : activeColor
  11. }">
  12. <text v-if="current < index" :style="{
  13. color: current < index ? unActiveColor : activeColor,
  14. }">
  15. {{ index+1 }}
  16. </text>
  17. <u-icon v-else size="22" color="#ffffff" :name="item.processingStatus==3?icon1:icon"></u-icon>
  18. </view>
  19. <view class="u-steps__item__num" v-if="mode == 'number' && item.processingStatus==3" :style="{
  20. backgroundColor: current < index ? 'transparent' : 'red',
  21. borderColor: current < index ? unActiveColor : 'red'
  22. }">
  23. <text v-if="current < index" :style="{
  24. color: current < index ? unActiveColor : activeColor,
  25. }">
  26. {{ index+1 }}
  27. </text>
  28. <u-icon v-else size="22" color="#ffffff" :name="icon1"></u-icon>
  29. </view>
  30. <view class="u-steps__item__dot" v-if="mode == 'dot'" :style="{
  31. backgroundColor: index <= current ? activeColor : unActiveColor
  32. }"></view>
  33. <view class="dis f-c ">
  34. <text class="u-line-1" :style="{
  35. color: index <= current ? activeColor : unActiveColor,
  36. }" :class="['u-steps__item__text--' + direction]">
  37. <text class="dis f-c a-start pathTraceColor" :key="index">{{item.processingStatusName}}</text>
  38. </text>
  39. <text class="u-line-1" :style="{
  40. color: index <= current ? activeColor : unActiveColor,
  41. }" :class="['u-steps__item__text--' + direction]">
  42. <text class="dis f-c a-start pathTraceColor" :key="index">{{item.processingDate}}</text>
  43. </text>
  44. </view>
  45. <view class="u-steps__item__line" :class="['u-steps__item__line--' + mode]"
  46. v-if="index < list.length - 1">
  47. <u-line :direction="direction" length="100%" :hair-line="false" :color="unActiveColor"
  48. margin="10px 0"></u-line>
  49. </view>
  50. </view>
  51. </view>
  52. </view>
  53. </template>
  54. <script>
  55. /**
  56. * steps 步骤条
  57. * @description 该组件一般用于完成一个任务要分几个步骤,标识目前处于第几步的场景。
  58. * @tutorial https://www.uviewui.com/components/steps.html
  59. * @property {String} mode 设置模式(默认dot)
  60. * @property {Array} list 数轴条数据,数组。具体见上方示例
  61. * @property {String} type type主题(默认primary)
  62. * @property {String} direction row-横向,column-竖向(默认row)
  63. * @property {Number String} current 设置当前处于第几步
  64. * @property {String} active-color 已完成步骤的激活颜色,如设置,type值会失效
  65. * @property {String} un-active-color 未激活的颜色,用于表示未完成步骤的颜色(默认#606266)
  66. * @example <u-steps :list="numList" active-color="#fa3534"></u-steps>
  67. */
  68. export default {
  69. name: 'u-steps',
  70. props: {
  71. // 步骤条的类型,dot|number
  72. mode: {
  73. type: String,
  74. default: 'dot'
  75. },
  76. // 步骤条的数据
  77. list: {
  78. type: Array,
  79. default () {
  80. return [];
  81. }
  82. },
  83. // 主题类型, primary|success|info|warning|error
  84. type: {
  85. type: String,
  86. default: 'primary'
  87. },
  88. // 当前哪一步是激活的
  89. current: {
  90. type: [Number, String],
  91. default: 0
  92. },
  93. // 激活步骤的颜色
  94. activeColor: {
  95. type: String,
  96. default: '#2979ff'
  97. },
  98. // 未激活的颜色
  99. unActiveColor: {
  100. type: String,
  101. default: '#909399'
  102. },
  103. // 自定义图标
  104. icon: {
  105. type: String,
  106. default: 'checkmark'
  107. },
  108. icon1: {
  109. type: String,
  110. default: 'close'
  111. },
  112. // step的排列方向,row-横向,column-竖向
  113. direction: {
  114. type: String,
  115. default: 'row'
  116. }
  117. },
  118. data() {
  119. return {};
  120. },
  121. };
  122. </script>
  123. <style lang="scss" scoped>
  124. @import '../../libs/css/style.components.scss';
  125. $u-steps-item-number-width: 44rpx;
  126. $u-steps-item-dot-width: 20rpx;
  127. .u-steps {
  128. @include vue-flex;
  129. .u-steps__item__num {
  130. font-size: 15px;
  131. }
  132. .u-steps__item {
  133. flex: 1;
  134. text-align: center;
  135. position: relative;
  136. min-width: 100rpx;
  137. font-size: 26rpx;
  138. color: #8799a3;
  139. @include vue-flex;
  140. justify-content: center;
  141. flex-direction: column;
  142. align-items: center;
  143. &--row {
  144. @include vue-flex;
  145. flex-direction: column;
  146. .u-steps__item__line {
  147. position: absolute;
  148. z-index: 0;
  149. left: 75%;
  150. width: 50%;
  151. &--dot {
  152. top: calc(#{$u-steps-item-dot-width} / 2);
  153. }
  154. &--number {
  155. top: calc(#{$u-steps-item-number-width} / 2);
  156. }
  157. }
  158. }
  159. &--column {
  160. @include vue-flex;
  161. flex-direction: row;
  162. justify-content: flex-start;
  163. align-items: baseline;
  164. min-height: 120rpx;
  165. .u-steps__item__line {
  166. position: absolute;
  167. z-index: 0;
  168. height: calc(100% - 25px);
  169. top: 17px;
  170. &--dot {
  171. left: calc(#{$u-steps-item-dot-width} / 2);
  172. }
  173. &--number {
  174. left: calc(#{$u-steps-item-number-width} / 2);
  175. }
  176. }
  177. }
  178. &__num {
  179. @include vue-flex;
  180. align-items: center;
  181. justify-content: center;
  182. width: $u-steps-item-number-width;
  183. height: $u-steps-item-number-width;
  184. border: 1px solid #8799a3;
  185. border-radius: 50%;
  186. overflow: hidden;
  187. }
  188. &__dot {
  189. width: $u-steps-item-dot-width;
  190. height: $u-steps-item-dot-width;
  191. @include vue-flex;
  192. border-radius: 50%;
  193. }
  194. &__text--row {
  195. margin-top: 14rpx;
  196. }
  197. &__text--column {
  198. margin-left: 20rpx;
  199. }
  200. }
  201. }
  202. .pathTraceColor {
  203. font-size: 15px;
  204. color: #333;
  205. }
  206. .active {
  207. font-size: 12px;
  208. color: rgba(51, 51, 51, 0.8);
  209. }
  210. </style>