siteArchive.vue 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203
  1. <template>
  2. <view class="site-wrapper">
  3. <!-- 筛选框start -->
  4. <view style="height:100rpx"></view>
  5. <view class="ding">
  6. <view class="cu-bar search bg-gray filter-section">
  7. <view class="search-form round bg-white">
  8. <text class="cuIcon-search"></text>
  9. <input class="" @focus="InputFocus" v-model="siteName" @blur="InputBlur" :adjust-position="false"
  10. type="text" placeholder="请输入站点"></input>
  11. </view>
  12. <view class="action">
  13. <button class="cu-btn bg-blue round" @click="searchData()">查询</button>
  14. </view>
  15. </view>
  16. </view>
  17. <!-- 筛选框end -->
  18. <view style="height: calc(100vh - 290rpx);">
  19. <view class="cu-list menu-avatar">
  20. <view class="cu-item" :class="modalName=='move-box-'+ index?'move-cur':''"
  21. v-for="(item,index) in siteArchiveData" :key="index" :data-target="'move-box-' + index"
  22. @tap="goArchiveDetail(item.id)" @touchstart="ListTouchStart" @touchmove="ListTouchMove"
  23. @touchend="ListTouchEnd">
  24. <view class="cu-avatar round lg" style="background-image:url(../../../static/archiveIcon.png)">
  25. </view>
  26. <view class="content">
  27. <view class="pro-title">
  28. <view class="cut">{{item.site_name}} (现场档案)</view>
  29. </view>
  30. </view>
  31. <view class="nav-right num">
  32. <view class="text-grey">
  33. <text class="icon iconfont margin-right-sm margin-left-lg">&#xe629;</text>
  34. </view>
  35. </view>
  36. <view class="move" style="width: 66px;">
  37. <view class="bg-grey" @click.stop="editItem(item)">编辑</view>
  38. </view>
  39. </view>
  40. </view>
  41. <view v-if="!siteArchiveData.length&&siteListRes==1" class="text-center margin-top"> 暂无数据</view>
  42. <view v-show="isLoadMore&&this.currentPage>1">
  43. <uni-load-more :status="loadStatus"></uni-load-more>
  44. </view>
  45. </view>
  46. <!-- 新增按钮start -->
  47. <view style="width: 100%;
  48. position: fixed;
  49. bottom: 0px;
  50. right: 0px;
  51. height: 64px;
  52. background: #fff;">
  53. <view class="plus">
  54. <image src="../../static/plus.png" style="width:100rpx;height:100rpx" @tap="goAddPage()"></image>
  55. </view>
  56. </view>
  57. <!-- 新增按钮end -->
  58. </view>
  59. </template>
  60. <script>
  61. export default {
  62. data() {
  63. return {
  64. modalName: null,
  65. siteArchiveData: [],
  66. siteName: '',
  67. siteListRes: 0,
  68. currentPage: 1,
  69. size: 10,
  70. loadStatus: 'loading', //加载样式:more-加载前样式,loading-加载中样式,nomore-没有数据样式
  71. isLoadMore: false, //是否加载中
  72. };
  73. },
  74. onReachBottom() { //上拉触底函数
  75. if (!this.isLoadMore) { //此处判断,上锁,防止重复请求
  76. this.isLoadMore = true
  77. this.currentPage += 1;
  78. this.loadData()
  79. }
  80. },
  81. onLoad: function(option) {
  82. this.loadData()
  83. },
  84. methods: {
  85. searchData() {
  86. this.currentPage=1,
  87. this.loadData()
  88. },
  89. loadData(){
  90. this.getDataList({
  91. "site_name": this.siteName,
  92. currentPage: this.currentPage,
  93. size: this.size,
  94. })
  95. },
  96. InputFocus(e) {
  97. this.InputBottom = e.detail.height
  98. },
  99. InputBlur(e) {
  100. this.InputBottom = 0
  101. },
  102. //编辑
  103. editItem(item) {
  104. uni.navigateTo({
  105. url: '/pages/siteArchive/siteArchiveAdd/siteArchiveAdd?id=' + item.id + '',
  106. });
  107. },
  108. //数据请求
  109. async getDataList(params = {}) {
  110. const res = await this.$myRequest({
  111. url: 'Archives/getArchivesList',
  112. showLoading: true,
  113. data: params
  114. })
  115. console.log('res.data.data')
  116. console.log(res.data.data)
  117. this.siteListRes = 1;
  118. if (res.data.total) {
  119. this.siteArchiveData = this.siteArchiveData.concat(res.data.data)
  120. if (res.data.data.length < this.size) { //判断接口返回数据量小于请求数据量,则表示此为最后一页
  121. this.isLoadMore = true
  122. this.loadStatus = 'nomore'
  123. } else {
  124. this.isLoadMore = false
  125. }
  126. } else {
  127. this.isLoadMore = true
  128. this.loadStatus = 'nomore'
  129. }
  130. },
  131. // 页面跳转
  132. goArchiveDetail(id) {
  133. uni.navigateTo({
  134. url: '/pages/siteArchive/archiveDetail/archiveDetail?id=' + id,
  135. });
  136. },
  137. goAddPage(item) {
  138. uni.navigateTo({
  139. url: '/pages/siteArchive/siteArchiveAdd/siteArchiveAdd',
  140. });
  141. },
  142. // ListTouch触摸开始
  143. ListTouchStart(e) {
  144. this.listTouchStart = e.touches[0].pageX
  145. },
  146. // ListTouch计算方向
  147. ListTouchMove(e) {
  148. this.listTouchDirection = e.touches[0].pageX - this.listTouchStart < -80 ? 'left' : 'right'
  149. },
  150. // ListTouch计算滚动
  151. ListTouchEnd(e) {
  152. if (this.listTouchDirection == 'left') {
  153. this.modalName = e.currentTarget.dataset.target
  154. } else {
  155. this.modalName = null
  156. }
  157. this.listTouchDirection = null
  158. }
  159. }
  160. }
  161. </script>
  162. <style lang="scss">
  163. .cu-item {
  164. height: 160rpx !important
  165. }
  166. .cu-list.menu-avatar>.cu-item .content {
  167. left: 110rpx;
  168. }
  169. .cu-list>.cu-item.move-cur {
  170. -webkit-transform: translateX(-66px);
  171. }
  172. </style>