viewData.vue 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  1. <template>
  2. <view class="viewData-v">
  3. <view class="notice-warp">
  4. <view class="search-box">
  5. <u-search v-model="keyword" height="72" :show-action="false" @change="search" bg-color="#f0f2f6"
  6. shape="square">
  7. </u-search>
  8. </view>
  9. </view>
  10. <mescroll-body ref="mescrollRef" @init="mescrollInit" @down="downCallback" @up="upCallback" :sticky="true"
  11. :down="downOption" :up="upOption" top="60">
  12. <view class="u-flex-col tableList">
  13. <view class="u-flex list-card" v-for="(item,index) in list" :key="index">
  14. <view class="u-flex-col fieldContent u-m-l-10">
  15. <view v-for="(column,c) in onLoadData.columnOptions" :key="c" class="fieldList u-line-1 u-flex">
  16. <view class="val" v-if="column.ifShow">{{column.label+':'}} {{item[column.value]}}</view>
  17. </view>
  18. </view>
  19. </view>
  20. </view>
  21. </mescroll-body>
  22. </view>
  23. </template>
  24. <script>
  25. import {
  26. getPopSelect
  27. } from '@/api/common.js'
  28. import resources from '@/libs/resources.js'
  29. import MescrollMixin from "@/uni_modules/mescroll-uni/components/mescroll-uni/mescroll-mixins.js";
  30. export default {
  31. mixins: [MescrollMixin],
  32. data() {
  33. return {
  34. downOption: {
  35. use: true,
  36. auto: true
  37. },
  38. upOption: {
  39. page: {
  40. num: 0,
  41. size: 20,
  42. time: null
  43. },
  44. empty: {
  45. use: true,
  46. icon: resources.message.nodata,
  47. tip: this.$t('common.noData'),
  48. fixed: true,
  49. top: "300rpx",
  50. },
  51. textNoMore: this.$t('app.apply.noMoreData'),
  52. },
  53. list: [],
  54. columnOptions: '',
  55. onLoadData: {},
  56. keyword: '',
  57. listQuery: {
  58. keyword: ''
  59. }
  60. }
  61. },
  62. onLoad(e) {
  63. this.onLoadData = JSON.parse(decodeURIComponent(e.data));
  64. this.columnOptions = this.onLoadData.columnOptions.map(o => o.value).join(',')
  65. },
  66. methods: {
  67. upCallback(page) {
  68. const paramList = this.onLoadData.templateJson
  69. let query = {
  70. ...this.listQuery,
  71. currentPage: page.num,
  72. pageSize: 20,
  73. interfaceId: this.onLoadData.interfaceId,
  74. columnOptions: this.columnOptions,
  75. paramList
  76. }
  77. getPopSelect(this.onLoadData.interfaceId, query, {
  78. load: page.num == 1
  79. }).then(res => {
  80. this.mescroll.endSuccess(res.data.list.length);
  81. if (page.num == 1) this.list = [];
  82. this.list = this.list.concat(res.data.list);
  83. }).catch(() => {
  84. this.mescroll.endErr();
  85. })
  86. },
  87. search() {
  88. // 节流,避免输入过快多次请求
  89. this.searchTimer && clearTimeout(this.searchTimer)
  90. this.searchTimer = setTimeout(() => {
  91. this.list = [];
  92. this.listQuery.keyword = this.keyword
  93. this.listQuery.currentPage = 1
  94. this.mescroll.resetUpScroll();
  95. }, 300)
  96. },
  97. }
  98. }
  99. </script>
  100. <style lang="scss">
  101. page {
  102. background-color: #f0f2f6;
  103. }
  104. .viewData-v {
  105. width: 100%;
  106. height: 100%;
  107. padding-bottom: 106rpx;
  108. .notice-warp {
  109. height: 3.5rem;
  110. }
  111. .tableList {
  112. padding: 0 20rpx;
  113. .list-card {
  114. background-color: #fff;
  115. width: 100%;
  116. border-radius: 8rpx;
  117. margin-top: 20rpx;
  118. padding: 20rpx 20rpx;
  119. .fieldContent {
  120. width: 100%;
  121. margin-top: -14rpx;
  122. .fieldList {
  123. // width: 752rpx;
  124. .key {
  125. width: 136rpx;
  126. margin-right: 10rpx;
  127. text-align: right;
  128. overflow: hidden;
  129. white-space: nowrap;
  130. text-overflow: ellipsis;
  131. line-height: 60rpx;
  132. }
  133. .val {
  134. flex: 0.85;
  135. overflow: hidden;
  136. white-space: nowrap;
  137. text-overflow: ellipsis;
  138. }
  139. }
  140. }
  141. }
  142. }
  143. .nodata {
  144. margin-top: 258rpx;
  145. justify-content: center;
  146. align-items: center;
  147. image {
  148. width: 280rpx;
  149. height: 215rpx;
  150. }
  151. }
  152. }
  153. </style>