siteList.vue 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302
  1. <template>
  2. <view class="site-wrapper" ref="contentWrapper">
  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. <!-- 站点列表start -->
  33. <view class="site-items" style="margin-top: 0px">
  34. <view class="cu-list menu-avatar longPressUl">
  35. <view class="cu-item" :class="modalName=='move-box-'+ index?'move-cur':''"
  36. v-for="(item,index) in newSiteListData" :key="index" :data-target="'move-box-' + index">
  37. <view class="cu-avatar round lg" style="background-image: url(../../static/site-icon-alarm.png);">
  38. </view>
  39. <view class="content" @tap="goDeviceType(item)" @longpress="showDetail(item)">
  40. <view class="text-grey site-tit">
  41. <text style="width:350rpx;" class="inOneLine">{{item.siteName}}</text>
  42. <text style="font-size:28rpx;text-align:right">
  43. ( 共{{item.count}}个设备 )
  44. </text>
  45. </view>
  46. <view class="showDetail" v-if="item.isShow" @tap.stop="goSiteDetail(item)">查看详情</view>
  47. </view>
  48. <view class="nav-right num">
  49. <view class="text-grey">
  50. <text class="icon iconfont margin-right-xs margin-left-lg">&#xe629;</text>
  51. </view>
  52. </view>
  53. </view>
  54. </view>
  55. <view v-if="!siteListData.length&&siteListRes==1" class="text-center margin-top"> 暂无数据</view>
  56. <view v-show="isLoadMore&&this.currentPage>1">
  57. <uni-load-more :status="loadStatus"></uni-load-more>
  58. </view>
  59. </view>
  60. <!-- 站点列表end -->
  61. </view>
  62. </template>
  63. <script>
  64. import json from '../../data/json.js';
  65. export default {
  66. data() {
  67. return {
  68. siteListRes: 0,
  69. siteName: '',
  70. type: '0',
  71. siteListData: [],
  72. modalName: null,
  73. listTouchStart: 0,
  74. listTouchDirection: null,
  75. CustomBar: this.CustomBar,
  76. isShow2: false,
  77. formMess: {
  78. "siteName": "",
  79. },
  80. siteItemDataOrigin: [],
  81. siteItemData: [],
  82. currentPage: 1,
  83. size: 10,
  84. loadStatus: 'loading', //加载样式:more-加载前样式,loading-加载中样式,nomore-没有数据样式
  85. isLoadMore: false, //是否加载中
  86. };
  87. },
  88. onPullDownRefresh() {
  89. console.log('refresh');
  90. setTimeout(function() {
  91. uni.stopPullDownRefresh();
  92. }, 1000);
  93. },
  94. computed: {
  95. newSiteListData() {
  96. return this.siteListData.map(item => {
  97. this.$set(item, "isShow", false)
  98. return item
  99. })
  100. }
  101. },
  102. mounted() {
  103. document.addEventListener('click', (e) => {
  104. if (e.target.className != 'showDetail') {
  105. this.siteListData.forEach(item => {
  106. item.isShow = false
  107. })
  108. }
  109. })
  110. },
  111. onReachBottom() { //上拉触底函数
  112. if (!this.isLoadMore) { //此处判断,上锁,防止重复请求
  113. this.isLoadMore = true
  114. this.currentPage += 1;
  115. this.loadData()
  116. }
  117. },
  118. onLoad() {
  119. this.loadData();
  120. this.getRoutrBox()
  121. },
  122. methods: {
  123. //新线名称下拉数据请求
  124. async getRoutrBox(params = {}) {
  125. const res = await this.$myRequest({
  126. url: 'Archives/getRoutrBox',
  127. showLoading: true,
  128. data: params
  129. })
  130. // this.routeListData = res.data.data;
  131. // console.log(this.routeListData)
  132. this.siteItemData = res.data.data;
  133. this.siteItemDataOrigin = res.data.data;
  134. this.siteItemData = this.siteItemDataOrigin;
  135. },
  136. //选中下拉选项,隐藏框,赋值
  137. changeModel: function(item, index) {
  138. this.isShow2 = false;
  139. this.formMess.siteName = item.route_name;
  140. },
  141. // 输入框点击 显示隐藏下拉框
  142. toggleShow: function() {
  143. this.isShow2 = !this.isShow2;
  144. },
  145. //点击下拉筛选
  146. handleInput() {
  147. //将元素根据搜索内容过滤出来 这里改变了siteItemData
  148. this.siteItemData = this.siteItemDataOrigin;
  149. this.siteItemData = this.siteItemData.filter(item => item.route_name.indexOf(this.formMess.siteName) > -1);
  150. },
  151. focusfns: function(e) {
  152. //将元素根据搜索内容过滤出来 这里改变了siteItemData
  153. this.siteItemData = this.siteItemDataOrigin;
  154. this.siteItemData = this.siteItemData.filter(item => item.route_name.indexOf(this.formMess.siteName) >
  155. -1);
  156. },
  157. searchData() {
  158. this.siteListData=[]
  159. this.siteListRes=0
  160. this.currentPage=1,
  161. this.loadData()
  162. },
  163. loadData(){
  164. this.getSiteList({
  165. "siteName": this.siteName,
  166. "route_name": this.formMess.siteName,
  167. currentPage: this.currentPage,
  168. size: this.size,
  169. })
  170. },
  171. async getSiteList(ming) {
  172. const res = await this.$myRequest({
  173. url: 'OperationMonitoring/getSiteList',
  174. showLoading: true,
  175. data: ming
  176. })
  177. // this.siteListData = res.data.data
  178. if (res.data.total) {
  179. this.siteListData = this.siteListData.concat(res.data.data)
  180. if (res.data.data.length < this.size) { //判断接口返回数据量小于请求数据量,则表示此为最后一页
  181. this.isLoadMore = true
  182. this.loadStatus = 'nomore'
  183. } else {
  184. this.isLoadMore = false
  185. }
  186. } else {
  187. this.isLoadMore = true
  188. this.loadStatus = 'nomore'
  189. }
  190. if(!res.data.data.length){
  191. this.siteListRes = 1;
  192. }
  193. },
  194. // 隐藏显示
  195. showDetail(e) {
  196. // 存储点击那一项的状态
  197. const nowStatu = e.isShow;
  198. // 将每一项列表的isShow设置为false,让所有的列表都隐藏
  199. this.siteListData.forEach(item => {
  200. item.isShow = false
  201. })
  202. // 用于再次点击该项的取反
  203. e.isShow = !nowStatu
  204. },
  205. InputFocus(e) {
  206. this.InputBottom = e.detail.height
  207. },
  208. InputBlur(e) {
  209. this.InputBottom = 0
  210. },
  211. goDeviceType(item) {
  212. if (item.count) {
  213. uni.navigateTo({
  214. url: '/pages/deviceType/deviceType?companyCode=' + item.companyCode,
  215. success: res => {},
  216. fail: () => {},
  217. complete: () => {}
  218. });
  219. }
  220. },
  221. goSiteDetail(item) {
  222. uni.navigateTo({
  223. url: '/pages/siteDetail/siteDetail?id=' + item.id + '',
  224. success: res => {},
  225. fail: () => {},
  226. complete: () => {}
  227. });
  228. },
  229. }
  230. }
  231. </script>
  232. <style>
  233. .showDetail {
  234. position: absolute;
  235. background: #fff;
  236. box-shadow: 0 1px 6px 0 rgb(32 33 36 / 28%);
  237. padding: 0rpx 32rpx;
  238. border-radius: 10rpx;
  239. top: 42rpx;
  240. right: 45%;
  241. z-index: 3000000;
  242. font-size: 28rpx;
  243. }
  244. * {
  245. -webkit-touch-callout: none;
  246. -webkit-user-select: none;
  247. -khtml-user-select: none;
  248. -moz-user-select: none;
  249. -ms-user-select: none;
  250. user-select: none;
  251. }
  252. input {
  253. -webkit-touch-callout: initial !important;
  254. -webkit-user-select: initial !important;
  255. -khtml-user-select: initial !important;
  256. -moz-user-select: initial !important;
  257. -ms-user-select: initial !important;
  258. user-select: initial !important;
  259. }
  260. </style>