siteArchive.vue 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209
  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" style="padding-bottom:60px">
  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.siteArchiveData=[],
  88. this.siteListRes = 0;
  89. this.loadData()
  90. },
  91. loadData(){
  92. this.getDataList({
  93. "site_name": this.siteName,
  94. currentPage: this.currentPage,
  95. size: this.size,
  96. })
  97. },
  98. InputFocus(e) {
  99. this.InputBottom = e.detail.height
  100. },
  101. InputBlur(e) {
  102. this.InputBottom = 0
  103. },
  104. //编辑
  105. editItem(item) {
  106. uni.navigateTo({
  107. url: '/pages/siteArchive/siteArchiveAdd/siteArchiveAdd?id=' + item.id + '',
  108. });
  109. },
  110. //数据请求
  111. async getDataList(params = {}) {
  112. const res = await this.$myRequest({
  113. url: 'Archives/getArchivesList',
  114. showLoading: true,
  115. data: params
  116. })
  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. console.log('this.siteArchiveData')
  127. console.log(this.siteArchiveData)
  128. } else {
  129. this.isLoadMore = true
  130. this.loadStatus = 'nomore'
  131. }
  132. },
  133. // 页面跳转
  134. goArchiveDetail(id) {
  135. uni.navigateTo({
  136. url: '/pages/siteArchive/archiveDetail/archiveDetail?id=' + id,
  137. });
  138. },
  139. goAddPage(item) {
  140. uni.navigateTo({
  141. url: '/pages/siteArchive/siteArchiveAdd/siteArchiveAdd',
  142. });
  143. },
  144. // ListTouch触摸开始
  145. ListTouchStart(e) {
  146. this.listTouchStart = e.touches[0].pageX
  147. },
  148. // ListTouch计算方向
  149. ListTouchMove(e) {
  150. this.listTouchDirection = e.touches[0].pageX - this.listTouchStart < -80 ? 'left' : 'right'
  151. },
  152. // ListTouch计算滚动
  153. ListTouchEnd(e) {
  154. if (this.listTouchDirection == 'left') {
  155. this.modalName = e.currentTarget.dataset.target
  156. } else {
  157. this.modalName = null
  158. }
  159. this.listTouchDirection = null
  160. }
  161. }
  162. }
  163. </script>
  164. <style lang="scss">
  165. .cu-item {
  166. height: 160rpx !important
  167. }
  168. .cu-list.menu-avatar>.cu-item .content {
  169. left: 110rpx;
  170. }
  171. .cu-list>.cu-item.move-cur {
  172. -webkit-transform: translateX(-66px);
  173. }
  174. </style>