当前位置:   article > 正文

uni-app纵向步骤条

uni-app纵向步骤条
分享一下项目中自封装的步骤条,存个档~
1. 话不多说,先看效果

2. 话还不多说,上代码
  1. <template>
  2. <!-- 获取一个数组,结构为
  3. [{
  4. nodeName:"流程发起"
  5. isAudit:false
  6. time:"2024-02-04 14:27:35"
  7. otherData:{
  8. assignee:{
  9. userId:"465"
  10. name:"XXX"
  11. company:"测试产业单位1"
  12. tenantId:"140"
  13. }
  14. }] -->
  15. <view class="bg">
  16. <view class="steps">
  17. <view class="steps_item" v-for="(i, index) in infoList" :key="index">
  18. <view class="s_r">
  19. <view class="line" :style="{ backgroundColor: index != 0 ? '#EAEAEA' : 'rgba(0,0,0,0)' }"></view>
  20. <view class="index" :style="{ backgroundColor: backgroundColor, color: color }"></view>
  21. <view
  22. class="line"
  23. :style="{ backgroundColor: index != infoList.length - 1 ? '#EAEAEA' : 'rgba(0,0,0,0)' }"
  24. ></view>
  25. </view>
  26. <view class="s_l">
  27. <view class="info_item">
  28. <!-- 真是节点名称、时间 -->
  29. <view class="top_info">
  30. <view class="title">{{ i.nodeName }}</view>
  31. <view class="date">{{ i.time }}</view>
  32. </view>
  33. <view class="info">
  34. <!-- 是否为审批节点,审批节点可显示审批状态 -->
  35. <template v-if="i.isAudit">
  36. <view
  37. class="audit-status"
  38. v-if="i.status === '1'"
  39. :style="`background-color:${auditStatus(2).bgColor};color:${auditStatus(2).color}`"
  40. >
  41. {{ auditStatus(2).text }}
  42. </view>
  43. <view
  44. class="audit-status"
  45. v-else
  46. :style="`background-color:${auditStatus(3).bgColor};color:${auditStatus(3).color}`"
  47. >
  48. {{ auditStatus(3).text }}
  49. </view>
  50. </template>
  51. <!-- 是否有其他信息需要展示,如审批人、签名、原因等 -->
  52. <template v-if="i.otherData">
  53. <view class="text-grey" v-if="i.otherData.assignee"
  54. >{{ i.otherData.assignee.name }} <text class="ml5"></text>{{ i.otherData.assignee.company }}</view
  55. >
  56. <view class="mt10" v-if="i.otherData.sign">
  57. <image
  58. style="width: 320rpx"
  59. mode="widthFix"
  60. :src="i.otherData.sign"
  61. @click="handlePreview(i.otherData.sign)"
  62. />
  63. </view>
  64. <view class="text-grey mt10" v-if="i.otherData.comment"> 原因:{{ i.otherData.comment }} </view>
  65. </template>
  66. </view>
  67. </view>
  68. </view>
  69. </view>
  70. </view>
  71. </view>
  72. </template>
  73. <script>
  74. export default {
  75. name: 'YSteps',
  76. props: {
  77. infoList: {
  78. type: Array,
  79. default: [],
  80. },
  81. color: {
  82. type: String,
  83. default: '#fff',
  84. },
  85. backgroundColor: {
  86. type: String,
  87. default: '#ff3838',
  88. },
  89. lineNum: {
  90. type: Number,
  91. default: 0,
  92. },
  93. },
  94. methods: {
  95. // 审核状态
  96. auditStatus(i) {
  97. if (i == 2) {
  98. return {
  99. text: '通过',
  100. color: '#00D288',
  101. bgColor: '#EAFFF8',
  102. }
  103. } else if (i == 3) {
  104. return {
  105. text: '驳回',
  106. color: '#FF4141',
  107. bgColor: '#FFDCD5',
  108. }
  109. }
  110. },
  111. handlePreview(url) {
  112. uni.previewImage({ urls: [url] })
  113. },
  114. },
  115. }
  116. </script>
  117. <style lang="scss" scoped>
  118. .steps {
  119. display: flex;
  120. flex-direction: column;
  121. .steps_item {
  122. display: flex;
  123. .s_r {
  124. padding: 0 20rpx;
  125. display: flex;
  126. flex-direction: column;
  127. align-items: center;
  128. .line {
  129. flex: 1;
  130. width: 5rpx;
  131. border-left: 4rpx dashed #fff;
  132. }
  133. .index {
  134. width: 24rpx;
  135. height: 24rpx;
  136. border-radius: 50rpx;
  137. border: 4rpx solid #e3eeff;
  138. box-sizing: border-box;
  139. }
  140. }
  141. .s_l {
  142. display: flex;
  143. flex-direction: column;
  144. padding: 20rpx 0;
  145. flex: 1;
  146. .info_item {
  147. background-color: #ffffff;
  148. margin-right: 30rpx;
  149. border-radius: 10rpx;
  150. display: flex;
  151. flex-direction: column;
  152. justify-content: center;
  153. padding: 30rpx 0;
  154. .top_info {
  155. display: flex;
  156. align-items: center;
  157. justify-content: space-between;
  158. }
  159. text {
  160. font-size: 24rpx;
  161. font-weight: 500;
  162. color: rgba(51, 51, 51, 1);
  163. }
  164. .title {
  165. width: calc(100vw - 330rpx);
  166. font-size: 28rpx;
  167. font-weight: 500;
  168. color: rgba(102, 102, 102, 1);
  169. overflow: hidden;
  170. text-overflow: ellipsis;
  171. display: -webkit-box;
  172. flex-direction: column;
  173. }
  174. .info {
  175. font-size: 24rpx;
  176. color: #afb4be;
  177. margin-top: 10rpx;
  178. }
  179. .date {
  180. font-size: 23rpx;
  181. color: #afb4be;
  182. }
  183. .audit-status {
  184. float: right;
  185. width: 120rpx;
  186. height: 40rpx;
  187. line-height: 40rpx;
  188. text-align: center;
  189. font-size: 22rpx;
  190. background: #eafff8;
  191. border-radius: 20rpx;
  192. }
  193. }
  194. .info_item:active {
  195. background-color: #f4f4f4;
  196. }
  197. }
  198. }
  199. }
  200. .ml5 {
  201. margin-left: 10rpx;
  202. }
  203. .mt10 {
  204. margin-top: 20rpx;
  205. }
  206. </style>

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/知新_RL/article/detail/312530
推荐阅读
相关标签
  

闽ICP备14008679号