siteList.vue 7.0 KB

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