list-test.vue 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205
  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" v-model="nowSiteName"></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">
  20. <view class="cu-item" :class="modalName=='move-box-'+ index?'move-cur':''" v-for="(item,index) in bindData"
  21. :key="index" :data-target="'move-box-' + index">
  22. <view class="cu-avatar round lg" v-bind:style="{ 'background-image': 'url(' + nowIcon+ ')' }"></view>
  23. <view class="content" v-if="nowType==1" @tap="goNowUrl(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.siteAlarmCount}}个未处理告警 )
  28. </text>
  29. </view>
  30. </view>
  31. <view class="content" v-else @tap="goNowUrl" @longpress="showDetail(item)">
  32. <view class="text-grey site-tit">
  33. {{item.siteName}}
  34. <text>(共3个设备)</text>
  35. </view>
  36. <view class="showDetail" v-if="item.isShow" @tap.stop="goNowDetailUrl" >查看详情</view>
  37. </view>
  38. <view class="nav-right num">
  39. <view class="text-grey">
  40. <text class="icon iconfont margin-right-xs margin-left-lg">&#xe629;</text>
  41. </view>
  42. </view>
  43. </view>
  44. </view>
  45. </view>
  46. <!-- 站点列表end -->
  47. </view>
  48. </template>
  49. <script>
  50. export default {
  51. // name: 'listTest',
  52. props:{
  53. bindType:{
  54. type:Number,
  55. default: ''
  56. },
  57. bindData:{
  58. type:Array,
  59. default: ''
  60. },
  61. bindUrl:{
  62. type:String,
  63. default: ''
  64. },
  65. bindDetailUrl:{
  66. type:String,
  67. default: ''
  68. },
  69. bindIcon:{
  70. type:String,
  71. default: ''
  72. },
  73. bindNum:{
  74. type:String,
  75. default: ''
  76. },
  77. bindSiteName:{
  78. type:String,
  79. default: ''
  80. }
  81. },
  82. data() {
  83. return {
  84. modalName: null,
  85. nowData:this.bindData,
  86. nowUrl:this.bindUrl,
  87. nowDetailUrl:this.bindDetailUrl,
  88. nowIcon:this.bindIcon,
  89. nowNum:this.bindNum,
  90. nowType:this.bindType,
  91. nowSiteName:this.bindSiteName,
  92. };
  93. },
  94. onPullDownRefresh() {
  95. console.log('refresh');
  96. setTimeout(function() {
  97. uni.stopPullDownRefresh();
  98. }, 1000);
  99. },
  100. computed: {
  101. newSiteListData() {
  102. return this.nowData.map(item => {
  103. this.$set(item, "isShow", false)
  104. return item
  105. })
  106. }
  107. },
  108. mounted() {
  109. document.addEventListener('click', (e) => {
  110. if (e.target.className != 'showDetail') {
  111. this.nowData.forEach(item => {
  112. item.isShow = false
  113. })
  114. }
  115. })
  116. },
  117. methods:{
  118. searchData(){
  119. // console.log("a: "+val, oldVal);
  120. this.$parent.getDataList({
  121. "siteName":this.nowSiteName
  122. })
  123. },
  124. // 隐藏显示
  125. showDetail(e) {
  126. // alert(1);
  127. // 存储点击那一项的状态
  128. const nowStatu = e.isShow;
  129. // 将每一项列表的isShow设置为false,让所有的列表都隐藏
  130. this.nowData.forEach(item => {
  131. item.isShow = false
  132. })
  133. // 用于再次点击该项的取反
  134. e.isShow = !nowStatu
  135. },
  136. // 页面跳转
  137. goNowUrl(item) {
  138. if(item.siteAlarmCount){
  139. uni.navigateTo({
  140. url: this.nowUrl+'?companyCode='+item.companyCode,
  141. success: res => {},
  142. fail: () => {},
  143. complete: () => {}
  144. });
  145. }
  146. },
  147. goNowDetailUrl() {
  148. uni.navigateTo({
  149. url: this.nowDetailUrl,
  150. success: res => {},
  151. fail: () => {},
  152. complete: () => {}
  153. });
  154. },
  155. InputFocus(e) {
  156. this.InputBottom = e.detail.height
  157. },
  158. InputBlur(e) {
  159. this.InputBottom = 0
  160. },
  161. }
  162. }
  163. </script>
  164. <style>
  165. .showDetail {
  166. position: absolute;
  167. background: #fff;
  168. box-shadow: 0 1px 6px 0 rgb(32 33 36 / 28%);
  169. padding: 0rpx 32rpx;
  170. border-radius: 10rpx;
  171. top: 42rpx;
  172. right: 0%;
  173. z-index: 3000000;
  174. font-size: 28rpx;
  175. }
  176. </style>