detail.vue 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  1. <template>
  2. <view>
  3. <view class="page_top">
  4. <view
  5. v-for="(v, i) in dataList.filter(item => item.type == 2)"
  6. :key="i"
  7. :class="{
  8. active: i == current,
  9. tage: true
  10. }"
  11. @click="changeFn(i)"
  12. >
  13. 数据{{ i + 1 }}
  14. </view>
  15. </view>
  16. <view class="list">
  17. <view class="list_row" v-for="(v, i) in list" :key="i">
  18. <view class="list_title"> {{ v.title }}: </view>
  19. <view class="list_right">
  20. {{ v.value }}
  21. </view>
  22. </view>
  23. </view>
  24. </view>
  25. </template>
  26. <script>
  27. import { mapState } from 'vuex'
  28. import { getUserInfo } from '@/common/utils/util'
  29. export default {
  30. data() {
  31. return {
  32. items: [
  33. '选项1',
  34. '选项2',
  35. '选项3',
  36. '选项3',
  37. '选项3',
  38. '选项3',
  39. '选项3',
  40. '选项3',
  41. '选项3',
  42. '选项3',
  43. '选项3',
  44. '选项3',
  45. '选项3',
  46. '选项3'
  47. ],
  48. current: 0,
  49. id: '',
  50. dataList: [],
  51. titleList: [],
  52. contentList: [],
  53. list: []
  54. }
  55. },
  56. computed: {
  57. ...mapState(['userInfo', 'isLogin', 'userId'])
  58. },
  59. onLoad(options) {
  60. this.id = options.id
  61. },
  62. mounted() {
  63. this.getData()
  64. },
  65. methods: {
  66. //切换数据
  67. changeFn(index) {
  68. this.current = index
  69. this.contentList = []
  70. for (let item in this.dataList?.filter(item => item.type == 2)?.[index]) {
  71. if (item.indexOf('field') !== -1) {
  72. this.contentList.push(this.dataList?.filter(item => item.type == 2)?.[index]?.[item])
  73. }
  74. }
  75. let list = []
  76. for (let i = 0; i < this.titleList.length; i++) {
  77. let obj = {
  78. title: this.titleList[i],
  79. value: this.contentList[i]
  80. }
  81. list.push(obj)
  82. }
  83. this.list = list
  84. },
  85. //获取数据
  86. async getData() {
  87. this.$api
  88. .get('/worker/comlist/record', {
  89. comListId: this.id,
  90. workerNumber: (await getUserInfo()).workerNumber
  91. })
  92. .then(({ data }) => {
  93. this.dataList = data
  94. for (let value in data[0]) {
  95. if (value.indexOf('field') !== -1) {
  96. this.titleList.push(data[0][value])
  97. }
  98. }
  99. this.changeFn(this.current)
  100. })
  101. }
  102. }
  103. }
  104. </script>
  105. <style lang="scss" scoped>
  106. .active {
  107. box-sizing: border-box;
  108. border-bottom: 2px solid #0081fd;
  109. background: #ff0000;
  110. }
  111. .page_top::-webkit-scrollbar {
  112. display: none;
  113. }
  114. .page_top {
  115. height: 88rpx;
  116. width: 750rpx;
  117. background-color: #fff;
  118. overflow-x: auto;
  119. white-space: nowrap;
  120. .tage {
  121. display: inline-block;
  122. width: 120rpx;
  123. height: 88rpx;
  124. text-align: center;
  125. line-height: 88rpx;
  126. }
  127. }
  128. .list {
  129. background-color: #fff;
  130. border-radius: 20rpx;
  131. margin: 20rpx;
  132. padding: 20rpx;
  133. // .list_left {
  134. // display: inline-block;
  135. // width: 140rpx;
  136. // // width: 120rpx;
  137. // // height: 100rpx;
  138. // .list_title {
  139. // line-height: 50rpx;
  140. // color: #909090;
  141. // border-bottom: 1px solid #f1f1f1;
  142. // }
  143. // }
  144. // .list_right {
  145. // display: inline-block;
  146. // width: 520rpx;
  147. // .list_content {
  148. // padding-left: 20rpx;
  149. // line-height: 50rpx;
  150. // color: #101010;
  151. // border-bottom: 1px solid #f1f1f1;
  152. // }
  153. // }
  154. }
  155. .list_row {
  156. display: flex;
  157. justify-content: space-between;
  158. align-items: center;
  159. font-size: 28rpx;
  160. line-height: 50rpx;
  161. border-bottom: 2rpx solid #f1f1f1;
  162. .list_title {
  163. color: #ff0000;
  164. }
  165. .list_right {
  166. color: #101010;
  167. padding-left: 20rpx;
  168. }
  169. }
  170. </style>