siteList.vue 4.4 KB

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