uni-steps.vue 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302
  1. <template>
  2. <view class="uni-steps">
  3. <view :class="[direction==='column'?'uni-steps__column':'uni-steps__row']">
  4. <view :class="[direction==='column'?'uni-steps__column-container':'uni-steps__row-container']">
  5. <view :class="[direction==='column'?'uni-steps__column-line-item':'uni-steps__row-line-item']"
  6. v-for="(item,index) in options" :key="index" @click="toStep(item, index)">
  7. <view
  8. :class="[direction==='column'?'uni-steps__column-line':'uni-steps__row-line',direction==='column'?'uni-steps__column-line--before':'uni-steps__row-line--before']"
  9. :style="{backgroundColor:index<=active&&index!==0?activeColor:index===0?'transparent':deactiveColor}">
  10. </view>
  11. <view :class="[direction==='column'?'uni-steps__column-check':'uni-steps__row-check']"
  12. v-if="index === active">
  13. <view class="uni-steps__row-circle activeRound" :class="[ taskId == item.taskId ?'circleActive': 'activeRound']">{{index + 1}}</view>
  14. </view>
  15. <view :class="[direction=='column'?'uni-steps__column-circle': taskId == item.taskId ?'circleActive' :'uni-steps__row-circle']" v-else>
  16. {{index + 1}}
  17. </view>
  18. <view
  19. :class="[direction==='column'?'uni-steps__column-line':'uni-steps__row-line',direction==='column'?'uni-steps__column-line--after':'uni-steps__row-line--after']"
  20. :style="{backgroundColor:index<active&&index!==options.length-1?activeColor:index===options.length-1?'transparent':deactiveColor}">
  21. </view>
  22. </view>
  23. </view>
  24. <view :class="[direction==='column'?'uni-steps__column-text-container':'uni-steps__row-text-container']"
  25. style="margin-top:10upx;">
  26. <view v-for="(item,index) in options" :key="index"
  27. :class="[direction==='column'?'uni-steps__column-text':'uni-steps__row-text']">
  28. <text :style="{color:index<=active?activeColor:deactiveColor}"
  29. :class="[direction==='column'?'uni-steps__column-title':'uni-steps__row-title']">{{item.taskTypeName}}</text>
  30. <text :style="{color:index<=active?activeColor:deactiveColor}"
  31. :class="[direction==='column'?'uni-steps__column-desc':'uni-steps__row-desc']">{{item.desc}}</text>
  32. </view>
  33. </view>
  34. </view>
  35. </view>
  36. </template>
  37. <script>
  38. export default {
  39. name: 'UniSteps',
  40. components: {
  41. },
  42. props: {
  43. direction: {
  44. // 排列方向 row column
  45. type: String,
  46. default: 'row'
  47. },
  48. activeColor: {
  49. // 激活状态颜色
  50. type: String,
  51. default: '#157A2C'
  52. },
  53. deactiveColor: {
  54. // 未激活状态颜色
  55. type: String,
  56. default: '#999999'
  57. },
  58. active: {
  59. // 当前步骤
  60. type: Number,
  61. default: 0
  62. },
  63. options: {
  64. type: Array,
  65. default () {
  66. return []
  67. }
  68. } // 数据
  69. },
  70. data() {
  71. return {
  72. taskId: null,
  73. }
  74. },
  75. methods: {
  76. toStep(item, index) {
  77. if(item.taskId == -2) {
  78. uni.showToast({
  79. title: "工序已到完结状态",
  80. icon: "none",
  81. })
  82. return false
  83. }
  84. if(item.number > 0 || index == this.active) {
  85. this.taskId = item.taskId
  86. this.$emit('selectStep', item);
  87. } else {
  88. uni.showToast({
  89. title: "还未执行到次工序",
  90. icon: "none",
  91. })
  92. }
  93. }
  94. }
  95. }
  96. </script>
  97. <style lang="scss" scoped>
  98. .uni-steps {
  99. /* #ifndef APP-NVUE */
  100. display: flex;
  101. width: 100%;
  102. /* #endif */
  103. /* #ifdef APP-NVUE */
  104. flex: 1;
  105. /* #endif */
  106. flex-direction: column;
  107. margin-top: 10rpx;
  108. }
  109. .uni-steps__row {
  110. /* #ifndef APP-NVUE */
  111. display: flex;
  112. /* #endif */
  113. flex-direction: column;
  114. }
  115. .uni-steps__column {
  116. /* #ifndef APP-NVUE */
  117. display: flex;
  118. /* #endif */
  119. flex-direction: row-reverse;
  120. }
  121. .uni-steps__row-text-container {
  122. /* #ifndef APP-NVUE */
  123. display: flex;
  124. /* #endif */
  125. flex-direction: row;
  126. }
  127. .uni-steps__column-text-container {
  128. /* #ifndef APP-NVUE */
  129. display: flex;
  130. /* #endif */
  131. flex-direction: column;
  132. flex: 1;
  133. }
  134. .uni-steps__row-text {
  135. /* #ifndef APP-NVUE */
  136. display: inline-flex;
  137. /* #endif */
  138. flex: 1;
  139. flex-direction: column;
  140. }
  141. .uni-steps__column-text {
  142. padding: 12upx 0upx;
  143. border-bottom-style: solid;
  144. border-bottom-width: 2upx;
  145. border-bottom-color: $uni-border-color;
  146. /* #ifndef APP-NVUE */
  147. display: flex;
  148. /* #endif */
  149. flex-direction: column;
  150. }
  151. .uni-steps__row-title {
  152. font-size: 28rpx;
  153. line-height: 40upx;
  154. text-align: center;
  155. min-width: 200rpx;
  156. }
  157. .uni-steps__column-title {
  158. font-size: 28rpx;
  159. text-align: left;
  160. line-height: 40upx;
  161. }
  162. .uni-steps__row-desc {
  163. font-size: 24upx;
  164. line-height: 28upx;
  165. text-align: center;
  166. }
  167. .uni-steps__column-desc {
  168. font-size: $uni-font-size-sm;
  169. text-align: left;
  170. line-height: 36upx;
  171. }
  172. .uni-steps__row-container {
  173. height: 60upx;
  174. border: 1px soild red;
  175. /* #ifndef APP-NVUE */
  176. display: flex;
  177. /* #endif */
  178. flex-direction: row;
  179. }
  180. .uni-steps__column-container {
  181. /* #ifndef APP-NVUE */
  182. display: inline-flex;
  183. /* #endif */
  184. width: 60upx;
  185. flex-direction: column;
  186. }
  187. .uni-steps__row-line-item {
  188. /* #ifndef APP-NVUE */
  189. display: inline-flex;
  190. /* #endif */
  191. flex-direction: row;
  192. flex: 1;
  193. height: 60upx;
  194. line-height: 60upx;
  195. align-items: center;
  196. justify-content: center;
  197. min-width: 200rpx;
  198. }
  199. .uni-steps__column-line-item {
  200. /* #ifndef APP-NVUE */
  201. display: flex;
  202. /* #endif */
  203. flex-direction: column;
  204. flex: 1;
  205. align-items: center;
  206. justify-content: center;
  207. }
  208. .uni-steps__row-line {
  209. flex: 1;
  210. height: 2upx;
  211. background-color: $uni-text-color-grey;
  212. }
  213. .uni-steps__column-line {
  214. width: 2upx;
  215. background-color: $uni-text-color-grey;
  216. }
  217. .uni-steps__row-line--after {
  218. transform: translateX(1px);
  219. }
  220. .uni-steps__column-line--after {
  221. flex: 1;
  222. transform: translate(0px, 1px);
  223. }
  224. .uni-steps__row-line--before {
  225. transform: translateX(-1px);
  226. }
  227. .uni-steps__column-line--before {
  228. height: 12upx;
  229. transform: translate(0px, -1px);
  230. }
  231. .uni-steps__row-circle {
  232. border: 1px solid #999999;
  233. background: transparent;
  234. width: 50upx;
  235. height: 50upx;
  236. border-radius: 50%;
  237. text-align: center;
  238. line-height: 50upx;
  239. }
  240. .uni-steps__column-circle {
  241. width: 10upx;
  242. height: 10upx;
  243. border-radius: 200upx;
  244. background-color: $uni-text-color-grey;
  245. margin: 8upx 0upx 10upx 0upx;
  246. }
  247. .uni-steps__row-check {
  248. margin: 0upx 12upx;
  249. }
  250. .uni-steps__column-check {
  251. height: 28upx;
  252. line-height: 28upx;
  253. margin: 4upx 0upx;
  254. }
  255. .activeRound {
  256. background: $theme-color;
  257. color: #fff;
  258. }
  259. .circleActive {
  260. border: 1px solid #FFA929;
  261. background: #FFA929;
  262. width: 50upx;
  263. height: 50upx;
  264. border-radius: 50%;
  265. text-align: center;
  266. line-height: 50upx;
  267. color: #fff;
  268. }
  269. </style>