index.vue 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188
  1. <template>
  2. <view class="timeLine-v">
  3. <view class="timeLine" :key="key">
  4. <u-time-line v-if="option.isVertical" :class="option.isLeft?'timeLine-right':''">
  5. <u-time-line-item v-for="(item,i) in option.defaultValue" :key="i">
  6. <template v-slot:node>
  7. <view class="timeLine-dot" v-if="i==0" :style="{'background':'rgba(62, 213, 56, 0.39)'}">
  8. </view>
  9. <view class="timeLine-dot" v-else-if="i==option.defaultValue.length-1"
  10. :style="{'background':'rgba(228, 231, 237, 0.39)'}">
  11. </view>
  12. <view class="timeLine-dot" v-else :style="{'background':'rgba(25, 144, 250, 0.39)'}">
  13. </view>
  14. </template>
  15. <template v-slot:content>
  16. <view class="timeLine-content" :style="{'text-align':option.isLeft?'right':'left'}"
  17. @tap="jump(item)">
  18. <view class="u-font-24" v-if="option.isCrad">
  19. {{item.title}}
  20. </view>
  21. <view class="u-flex-col" :class="option.isCrad?'timeLine-title2':'timeLine-title'">
  22. <text class="name u-font-28">{{item.content}}</text>
  23. <text class="time u-font-28">{{item.timestamp}}</text>
  24. </view>
  25. </view>
  26. </template>
  27. </u-time-line-item>
  28. </u-time-line>
  29. <timeLine-row v-if="!option.isVertical" :list='option.defaultValue' :isCrad='option.isCrad'
  30. :isUpper="option.isUpper">
  31. </timeLine-row>
  32. </view>
  33. </view>
  34. </template>
  35. <script>
  36. import timeLineRow from './timeLine-row.vue'
  37. import {
  38. getDataInterfaceRes
  39. } from '@/api/common'
  40. export default {
  41. props: {
  42. config: {
  43. type: Object,
  44. default: () => {}
  45. }
  46. },
  47. components: {
  48. timeLineRow
  49. },
  50. data() {
  51. return {
  52. option: {},
  53. key: +new Date()
  54. }
  55. },
  56. created() {
  57. this.init()
  58. uni.$off('proRefresh')
  59. uni.$on('proRefresh', () => {
  60. this.initData()
  61. })
  62. },
  63. methods: {
  64. jump(item) {
  65. this.jnpf.solveAddressParam(item, this.config)
  66. this.jnpf.jumpLink(item.urlAddress)
  67. },
  68. init() {
  69. this.initData()
  70. if (!this.config.allRefresh.autoRefresh && this.config.refresh.autoRefresh) {
  71. setInterval(this.initData, this.config.refresh.autoRefreshTime * 60000)
  72. }
  73. },
  74. initData() {
  75. if (this.config.dataType === "dynamic") {
  76. if (!this.config.propsApi) return
  77. const query = {
  78. paramList: this.config.templateJson
  79. };
  80. getDataInterfaceRes(this.config.propsApi, query).then(res => {
  81. this.config.option.defaultValue = res.data || []
  82. this.handleAttrs()
  83. })
  84. } else {
  85. this.handleAttrs()
  86. }
  87. },
  88. handleAttrs() {
  89. if (this.config.option.sortable == 2) this.config.option.defaultValue = this.config.option.defaultValue
  90. .reverse();
  91. this.config.option.isCrad = this.config.option.styleType == 2 ? true : false
  92. this.config.option.isLeft = false
  93. this.config.option.isVertical = false
  94. this.config.option.isUpper = false
  95. if (this.config.option.layout == 1 || this.config.option.layout == 2 || this.config.option.layout ==
  96. 3 || this.config.option.layout == 4) {
  97. this.config.option.isVertical = true
  98. if (this.config.option.layout == 3) {
  99. this.config.option.isLeft = true
  100. }
  101. }
  102. if (!this.config.option.isVertical) {
  103. if (this.config.option.layout == 5 || this.config.option.layout == 6 || this.config.option
  104. .layout == 7)
  105. this.config.option.isUpper = true
  106. }
  107. this.config.option.appShowNumber = this.config.option.appShowNumber || 50
  108. if (this.config.option.appShowNumber && Array.isArray(this.config.option.defaultValue)) {
  109. this.config.option.defaultValue = this.config.option.defaultValue.slice(0, this.config.option
  110. .appShowNumber)
  111. }
  112. this.option = this.config.option
  113. this.key = +new Date()
  114. }
  115. }
  116. }
  117. </script>
  118. <style lang="scss">
  119. .timeLine-v {
  120. .timeLine {
  121. width: 100%;
  122. height: 100%;
  123. padding: 20rpx;
  124. .u-time-axis-item {
  125. .u-time-axis-node {
  126. top: 0 !important;
  127. }
  128. }
  129. .timeLine-right {
  130. padding-left: 0;
  131. padding-right: 40rpx !important;
  132. &::before {
  133. left: 670rpx !important;
  134. }
  135. .u-time-axis-item {
  136. .u-time-axis-node {
  137. left: 670rpx !important;
  138. }
  139. }
  140. }
  141. .timeLine-dot {
  142. width: 28rpx;
  143. height: 28rpx;
  144. border: 4rpx solid #FFFFFF;
  145. box-shadow: 0 6rpx 12rpx rgba(2, 7, 28, 0.16);
  146. border-radius: 50%;
  147. }
  148. .timeLine-content {
  149. padding: 0 10rpx;
  150. .timeLine-title {
  151. font-size: 30rpx;
  152. line-height: 36rpx;
  153. .name {
  154. margin-bottom: 6rpx;
  155. }
  156. }
  157. .timeLine-title2 {
  158. margin-top: 6rpx;
  159. background: rgba(255, 255, 255, 0.39);
  160. box-shadow: 0px 3px 10px rgba(0, 0, 0, 0.1);
  161. padding: 10rpx 20rpx;
  162. border-radius: 4px;
  163. }
  164. }
  165. .timeLine-desc {
  166. margin-top: 10rpx;
  167. font-size: 26rpx;
  168. line-height: 36rpx;
  169. color: #909399;
  170. margin-bottom: 10rpx;
  171. }
  172. }
  173. }
  174. </style>