siteArchive.vue 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282
  1. <template>
  2. <view class="site-wrapper">
  3. <!-- 筛选框start -->
  4. <view style="height:200rpx"></view>
  5. <view class="ding">
  6. <view class="cu-bar search bg-gray filter-section" style="padding-top:10rpx">
  7. <view class="search-form round bg-white" style="position:relative;overflow:auto">
  8. <input name="siteName" v-model="formMess.siteName" @click="toggleShow" @focus="focusfns"
  9. @input="handleInput()" placeholder="请输入或选择所属新线"/>
  10. </view>
  11. </view>
  12. <view class="cu-bar search bg-gray filter-section">
  13. <view class="search-form round bg-white">
  14. <text class="cuIcon-search"></text>
  15. <input class="" @focus="InputFocus" v-model="siteName" @blur="InputBlur" :adjust-position="false"
  16. type="text" placeholder="请输入站点"/>
  17. </view>
  18. <view class="action">
  19. <button class="cu-btn bg-blue round" @click="searchData()">查询</button>
  20. </view>
  21. </view>
  22. </view>
  23. <view class="siteItems" v-if="isShow2" style="max-height:60vh;overflow:auto;position:absolute;z-index:999; margin: 0 32rpx;
  24. width: calc(100% - 64rpx);top:100rpx">
  25. <view class=" site-item" v-if="!siteItemData.length">暂无结果</view>
  26. <view class="site-item" v-for="(item,index) in siteItemData" @click="changeModel(item,index)" :key="index"
  27. style="padding:16rpx 22rpx">
  28. {{item.route_name}}
  29. </view>
  30. </view>
  31. <!-- 筛选框end -->
  32. <view style="height: calc(100vh - 290rpx);">
  33. <view class="cu-list menu-avatar">
  34. <view class="cu-item" :class="modalName=='move-box-'+ index?'move-cur':''"
  35. v-for="(item,index) in siteArchiveData" :key="index" :data-target="'move-box-' + index"
  36. @tap="goArchiveDetail(item.id)" @touchstart="ListTouchStart" @touchmove="ListTouchMove"
  37. @touchend="ListTouchEnd">
  38. <view class="cu-avatar round lg" style="background-image:url(../../../static/archiveIcon.png)">
  39. </view>
  40. <view class="content">
  41. <view class="pro-title">
  42. <view class="cut">{{item.site_name}} (现场档案)</view>
  43. </view>
  44. </view>
  45. <view class="nav-right num">
  46. <view class="text-grey">
  47. <text class="icon iconfont margin-right-sm margin-left-lg">&#xe629;</text>
  48. </view>
  49. </view>
  50. <view class="move" style="width: 66px;">
  51. <view class="bg-grey" @click.stop="editItem(item)">编辑</view>
  52. </view>
  53. </view>
  54. </view>
  55. <view v-if="!siteArchiveData.length&&siteListRes==1" class="text-center margin-top"> 暂无数据</view>
  56. <view v-show="isLoadMore&&this.currentPage>1" style="padding-bottom:60px">
  57. <uni-load-more :status="loadStatus"></uni-load-more>
  58. </view>
  59. </view>
  60. <!-- 新增按钮start -->
  61. <view style="width: 100%;
  62. position: fixed;
  63. bottom: 0px;
  64. right: 0px;
  65. height: 64px;
  66. background: #fff">
  67. <view class="plus">
  68. <image src="../../static/plus.png" style="width:100rpx;height:100rpx" @tap="goAddPage()"></image>
  69. </view>
  70. </view>
  71. <!-- 新增按钮end -->
  72. </view>
  73. </template>
  74. <script>
  75. export default {
  76. data() {
  77. return {
  78. modalName: null,
  79. siteArchiveData: [],
  80. siteName: '',
  81. siteListRes: 0,
  82. currentPage: 1,
  83. size: 10,
  84. loadStatus: 'loading', //加载样式:more-加载前样式,loading-加载中样式,nomore-没有数据样式
  85. isLoadMore: false, //是否加载中
  86. isShow2: false,
  87. formMess: {
  88. "siteName": "",
  89. },
  90. siteItemDataOrigin: [],
  91. siteItemData: [],
  92. };
  93. },
  94. onReachBottom() { //上拉触底函数
  95. if (!this.isLoadMore) { //此处判断,上锁,防止重复请求
  96. this.isLoadMore = true
  97. this.currentPage += 1;
  98. this.loadData()
  99. }
  100. },
  101. onLoad: function(option) {
  102. this.loadData()
  103. this.getRoutrBox()
  104. },
  105. methods: {
  106. //新线名称下拉数据请求
  107. async getRoutrBox(params = {}) {
  108. const res = await this.$myRequest({
  109. url: 'Archives/getRoutrBox',
  110. showLoading: true,
  111. data: params
  112. })
  113. this.siteItemData = res.data.data;
  114. this.siteItemDataOrigin = res.data.data;
  115. this.siteItemData = this.siteItemDataOrigin;
  116. },
  117. //选中下拉选项,隐藏框,赋值
  118. changeModel: function(item, index) {
  119. this.isShow2 = false;
  120. this.formMess.siteName = item.route_name;
  121. },
  122. // 输入框点击 显示隐藏下拉框
  123. toggleShow: function() {
  124. this.isShow2 = !this.isShow2;
  125. },
  126. //点击下拉筛选
  127. handleInput() {
  128. //将元素根据搜索内容过滤出来 这里改变了siteItemData
  129. this.siteItemData = this.siteItemDataOrigin;
  130. this.siteItemData = this.siteItemData.filter(item => item.route_name.indexOf(this.formMess.siteName) > -1);
  131. },
  132. focusfns: function(e) {
  133. //将元素根据搜索内容过滤出来 这里改变了siteItemData
  134. this.siteItemData = this.siteItemDataOrigin;
  135. this.siteItemData = this.siteItemData.filter(item => item.route_name.indexOf(this.formMess.siteName) >
  136. -1);
  137. },
  138. searchData() {
  139. this.currentPage=1,
  140. this.siteArchiveData=[],
  141. this.siteListRes = 0;
  142. this.loadData()
  143. },
  144. loadData(){
  145. this.getDataList({
  146. "site_name": this.siteName,
  147. "route_name": this.formMess.siteName,
  148. currentPage: this.currentPage,
  149. size: this.size,
  150. })
  151. },
  152. InputFocus(e) {
  153. this.InputBottom = e.detail.height
  154. },
  155. InputBlur(e) {
  156. this.InputBottom = 0
  157. },
  158. //编辑
  159. editItem(item) {
  160. uni.redirectTo({
  161. url: '/pages/siteArchive/siteArchiveAdd/siteArchiveAdd?id=' + item.id + '',
  162. });
  163. },
  164. //数据请求
  165. async getDataList(params = {}) {
  166. const res = await this.$myRequest({
  167. url: 'Archives/getArchivesList',
  168. showLoading: true,
  169. data: params
  170. })
  171. this.siteListRes = 1;
  172. if (res.data.total) {
  173. this.siteArchiveData = this.siteArchiveData.concat(res.data.data)
  174. if (res.data.data.length < this.size) { //判断接口返回数据量小于请求数据量,则表示此为最后一页
  175. this.isLoadMore = true
  176. this.loadStatus = 'nomore'
  177. } else {
  178. this.isLoadMore = false
  179. }
  180. console.log('this.siteArchiveData')
  181. console.log(this.siteArchiveData)
  182. } else {
  183. this.isLoadMore = true
  184. this.loadStatus = 'nomore'
  185. }
  186. },
  187. // 页面跳转
  188. goArchiveDetail(id) {
  189. uni.navigateTo({
  190. url: '/pages/siteArchive/archiveDetail/archiveDetail?id=' + id,
  191. });
  192. },
  193. goAddPage(item) {
  194. uni.redirectTo({
  195. url: '/pages/siteArchive/siteArchiveAdd/siteArchiveAdd',
  196. });
  197. },
  198. // ListTouch触摸开始
  199. ListTouchStart(e) {
  200. this.listTouchStart = e.touches[0].pageX
  201. },
  202. // ListTouch计算方向
  203. ListTouchMove(e) {
  204. this.listTouchDirection = e.touches[0].pageX - this.listTouchStart < -80 ? 'left' : 'right'
  205. },
  206. // ListTouch计算滚动
  207. ListTouchEnd(e) {
  208. if (this.listTouchDirection == 'left') {
  209. this.modalName = e.currentTarget.dataset.target
  210. } else {
  211. this.modalName = null
  212. }
  213. this.listTouchDirection = null
  214. }
  215. }
  216. }
  217. </script>
  218. <style lang="scss">
  219. .cu-item {
  220. height: 160rpx !important
  221. }
  222. .cu-list.menu-avatar>.cu-item .content {
  223. left: 110rpx;
  224. }
  225. .cu-list>.cu-item.move-cur {
  226. -webkit-transform: translateX(-66px);
  227. }
  228. </style>