u-steps.vue 8.1 KB

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