list-test.vue 4.4 KB

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