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