list-test.vue 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  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. <uni-easyinput v-model="nowSiteName" placeholder="请输入站点名称" prefixIcon="search" @focus="InputFocus" @blur="InputBlur" />
  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: 14px; 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. // 存储点击那一项的状态
  123. const nowStatu = e.isShow;
  124. // 将每一项列表的isShow设置为false,让所有的列表都隐藏
  125. this.nowData.forEach((item) => {
  126. item.isShow = false;
  127. });
  128. // 用于再次点击该项的取反
  129. e.isShow = !nowStatu;
  130. },
  131. // 页面跳转
  132. goNowUrl(item) {
  133. if (item.siteAlarmCount) {
  134. uni.navigateTo({
  135. url: this.nowUrl + "?companyCode=" + item.companyCode,
  136. success: (res) => {},
  137. fail: () => {},
  138. complete: () => {},
  139. });
  140. }
  141. },
  142. goNowDetailUrl() {
  143. uni.navigateTo({
  144. url: this.nowDetailUrl,
  145. success: (res) => {},
  146. fail: () => {},
  147. complete: () => {},
  148. });
  149. },
  150. InputFocus(e) {
  151. this.InputBottom = e.detail.height;
  152. },
  153. InputBlur(e) {
  154. this.InputBottom = 0;
  155. },
  156. },
  157. };
  158. </script>
  159. <style lang="scss">
  160. .showDetail {
  161. position: absolute;
  162. background: #fff;
  163. box-shadow: 0 1px 6px 0 rgb(32 33 36 / 28%);
  164. padding: 0rpx 32rpx;
  165. border-radius: 10rpx;
  166. top: 42rpx;
  167. right: 0%;
  168. z-index: 3000000;
  169. font-size: $uni-font-size-base;
  170. }
  171. </style>