siteList.vue 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195
  1. <template>
  2. <view class="site-wrapper" ref="contentWrapper">
  3. <!-- 筛选框start -->
  4. <view class="ding">
  5. <view class="cu-bar search bg-gray filter-section">
  6. <view class="search-form round bg-white">
  7. <text class="cuIcon-search"></text>
  8. <input class="" @focus="InputFocus" v-model="siteName" @blur="InputBlur" :adjust-position="false" type="text"
  9. placeholder="请输入站点名称" confirm-type="search"></input>
  10. </view>
  11. <view class="action">
  12. <button class="cu-btn bg-blue round" @click=searchData()>查询</button>
  13. </view>
  14. </view>
  15. </view>
  16. <!-- 筛选框end -->
  17. <!-- 站点列表start -->
  18. <view class="site-items">
  19. <view class="cu-list menu-avatar longPressUl">
  20. <view class="cu-item" :class="modalName=='move-box-'+ index?'move-cur':''" v-for="(item,index) in newSiteListData"
  21. :key="index" :data-target="'move-box-' + index">
  22. <view class="cu-avatar round lg" style="background-image: url(../../static/site-icon-alarm.png);"></view>
  23. <view class="content" @tap="goDeviceType(item)" @longpress="showDetail(item)">
  24. <view class="text-grey site-tit">
  25. <text style="width:260rpx;" class="inOneLine">{{item.siteName}}</text>
  26. <text style="font-size:28rpx;text-align:right">
  27. ( 共{{item.count}}个未处理告警 )
  28. </text>
  29. </view>
  30. <view class="showDetail" v-if="item.isShow" @tap.stop="goSiteDetail(item)">查看详情</view>
  31. </view>
  32. <view class="nav-right num">
  33. <view class="text-grey">
  34. <text class="icon iconfont margin-right-xs margin-left-lg">&#xe629;</text>
  35. </view>
  36. </view>
  37. </view>
  38. </view>
  39. <view v-if="!siteListData.length&&siteListRes==1" class="text-center margin-top"> 暂无数据</view>
  40. </view>
  41. <!-- 站点列表end -->
  42. </view>
  43. </template>
  44. <script>
  45. import json from '../../data/json.js';
  46. export default {
  47. data() {
  48. return {
  49. siteListRes: 0,
  50. siteName: '',
  51. type: '0',
  52. siteListData: [],
  53. modalName: null,
  54. listTouchStart: 0,
  55. listTouchDirection: null,
  56. CustomBar: this.CustomBar,
  57. };
  58. },
  59. onPullDownRefresh() {
  60. console.log('refresh');
  61. setTimeout(function() {
  62. uni.stopPullDownRefresh();
  63. }, 1000);
  64. },
  65. computed: {
  66. newSiteListData() {
  67. return this.siteListData.map(item => {
  68. this.$set(item, "isShow", false)
  69. return item
  70. })
  71. }
  72. },
  73. mounted() {
  74. document.addEventListener('click', (e) => {
  75. if (e.target.className != 'showDetail') {
  76. this.siteListData.forEach(item => {
  77. item.isShow = false
  78. })
  79. }
  80. })
  81. },
  82. onLoad() {
  83. this.getSiteList()
  84. },
  85. methods: {
  86. searchData() {
  87. this.getSiteList({
  88. "siteName": this.siteName
  89. })
  90. },
  91. async getSiteList(ming) {
  92. const res = await this.$myRequest({
  93. url: 'OperationMonitoring/getSiteList',
  94. showLoading: true,
  95. data: ming
  96. })
  97. this.siteListRes = 1;
  98. console.log(res.data.data)
  99. this.siteListData = res.data.data
  100. },
  101. // 隐藏显示
  102. showDetail(e) {
  103. // 存储点击那一项的状态
  104. const nowStatu = e.isShow;
  105. // 将每一项列表的isShow设置为false,让所有的列表都隐藏
  106. this.siteListData.forEach(item => {
  107. item.isShow = false
  108. })
  109. // 用于再次点击该项的取反
  110. e.isShow = !nowStatu
  111. },
  112. InputFocus(e) {
  113. this.InputBottom = e.detail.height
  114. },
  115. InputBlur(e) {
  116. this.InputBottom = 0
  117. },
  118. goDeviceType(item) {
  119. if (item.count) {
  120. uni.navigateTo({
  121. url: '/pages/deviceType/deviceType?companyCode=' + item.companyCode,
  122. success: res => {},
  123. fail: () => {},
  124. complete: () => {}
  125. });
  126. }
  127. },
  128. goSiteDetail(item) {
  129. uni.navigateTo({
  130. url: '/pages/siteDetail/siteDetail?id=' + item.id + '',
  131. success: res => {},
  132. fail: () => {},
  133. complete: () => {}
  134. });
  135. },
  136. }
  137. }
  138. </script>
  139. <style>
  140. .showDetail {
  141. position: absolute;
  142. background: #fff;
  143. box-shadow: 0 1px 6px 0 rgb(32 33 36 / 28%);
  144. padding: 0rpx 32rpx;
  145. border-radius: 10rpx;
  146. top: 42rpx;
  147. right: 45%;
  148. z-index: 3000000;
  149. font-size: 28rpx;
  150. }
  151. /* *:not(input) { */
  152. * {
  153. -webkit-touch-callout: none;
  154. -webkit-user-select: none;
  155. -khtml-user-select: none;
  156. -moz-user-select: none;
  157. -ms-user-select: none;
  158. user-select: none;
  159. }
  160. input {
  161. user-select: initial !important;
  162. }
  163. /* uni-page-head .uni-page-head-bd{
  164. user-select: none!important;
  165. } */
  166. </style>