search.vue 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231
  1. <template>
  2. <view>
  3. <view class="status_bar"></view>
  4. <view class="" style="position: relative;top: 40px;">
  5. <view style="position: fixed;z-index: 100;background-color: #FFFFFF;height: 80px;">
  6. <uni-nav-bar @clickLeft="clickLeft" left-icon="back" left-text="返回" title="设备搜索"></uni-nav-bar>
  7. <view class="search_top_input">
  8. <input type="text" value="" placeholder="请输入设备ID或设备名称" v-model="imports" @input="searchinp" />
  9. <u-icon name="search" size="40" class="icon" @click="search"></u-icon>
  10. </view>
  11. </view>
  12. <view class="prevents">
  13. <view class="prevents_item" v-for="item,index in eqlistdata" :key="index" @click="eqdetails(item)">
  14. <view class="" v-if="side_type == 5">
  15. <image
  16. :src="item.is_online==1?$imageURL+ '/bigdata_app/image/prevention/6.png':$imageURL+ '/bigdata_app/image/prevention/7.png'"
  17. mode="" class="prevents_item_img"></image>
  18. <view class="prevents_item_top">
  19. <p>设备名称:{{item.equip_name==""?"无":item.equip_name}}</p>
  20. <p :class="item.is_online==1?'green':'red'" v-text="item.is_online==1?'在线':'离线'"></p>
  21. </view>
  22. <view class="prevents_item_bot">
  23. <p>设备 ID:{{item.equip_id || item.device_id}}</p>
  24. <p>最新上报时间:{{item.uptime|timeFormat()}}</p>
  25. </view>
  26. </view>
  27. <view class="" v-if="side_type == 15">
  28. <image :src="$imageURL+ '/bigdata_app/image/prevention/6.png'" mode=""
  29. class="prevents_item_img"></image>
  30. <view class="prevents_item_top">
  31. <p>设备名称:{{item.device_name==""?"无":item.device_name}}</p>
  32. </view>
  33. <view class="prevents_item_bot">
  34. <p>设备 ID:{{item.device_id}}</p>
  35. <p>最新上报时间:{{item.uptime|timeFormat()}}</p>
  36. </view>
  37. </view>
  38. <view class="" v-if="side_type == 11 || side_type == 19 || side_type == 20">
  39. <image :src="$imageURL+ '/bigdata_app/image/prevention/6.png'" mode=""
  40. class="prevents_item_img"></image>
  41. <view class="prevents_item_top">
  42. <p>
  43. 设备名称:{{
  44. item.device_name == "" ? "暂无" : item.device_name
  45. }}
  46. </p>
  47. </view>
  48. <view class="prevents_item_bot">
  49. <p>设备 ID:{{ item.device_id }}</p>
  50. <p>最新上报时间:{{item.uptime|timeFormat()}}</p>
  51. </view>
  52. </view>
  53. </view>
  54. </view>
  55. </view>
  56. </view>
  57. </template>
  58. <script>
  59. import {
  60. Debounce,
  61. Throttle
  62. } from "../../util/anitthro.js"
  63. export default {
  64. data() {
  65. return {
  66. imports: '',
  67. eqlistdata: [],
  68. page: 1,
  69. size: 10,
  70. value: '',
  71. side_type: 5
  72. }
  73. },
  74. methods: {
  75. async eqlist() { //设备列表
  76. const res = await this.$myRequest({
  77. url: '/api/api_gateway?method=weather.weather.qxz_page',
  78. data: {
  79. device_type_id: 2,
  80. page: this.page,
  81. size: this.size,
  82. device_id: this.imports
  83. }
  84. })
  85. // console.log(res)
  86. this.eqlistdata = this.eqlistdata.concat(res.ids)
  87. console.log(this.eqlistdata)
  88. },
  89. async tubulareqlist() { //设备列表 环境监测
  90. this.loadingtf = true
  91. const res = await this.$myRequest({
  92. url: '/api/api_gateway?method=weather.weather.nd_qxz_page',
  93. data: {
  94. page: this.page,
  95. page_size: 10,
  96. device_id: this.imports
  97. }
  98. })
  99. this.loadingtf = false
  100. this.eqlistdata = this.eqlistdata.concat(res.ids)
  101. console.log(res.ids)
  102. },
  103. async getEquipList() { //设备列表 环境监测
  104. this.loadingtf = true;
  105. const res = await this.$myRequest({
  106. method: "POST",
  107. url: "/api/api_gateway?method=wheat.wheat.wheat_list",
  108. data: {
  109. device_id: this.imports,
  110. device_name: "",
  111. page: this.page,
  112. device_type: this.side_type,
  113. },
  114. });
  115. this.loadingtf = false;
  116. this.eqlistdata = this.eqlistdata.concat(res.ids);
  117. },
  118. clickLeft() {
  119. uni.navigateTo({
  120. url: "./index"
  121. })
  122. },
  123. search() {
  124. this.eqlistdata = []
  125. if (this.side_type == 5) {
  126. this.eqlist()
  127. } else if (this.side_type == 15) {
  128. this.tubulareqlist()
  129. } else if (this.side_type == 11 || this.side_type == 19 || this.side_type == 20) {
  130. this.getEquipList()
  131. }
  132. },
  133. searchinp() {
  134. Debounce(() => {
  135. this.search()
  136. }, 1000)()
  137. },
  138. eqdetails(data) {
  139. if (this.side_type == 5) {
  140. uni.navigateTo({
  141. url: "./equipment?shebei=" + JSON.stringify(data)
  142. })
  143. } else if (this.side_type == 15) {
  144. uni.navigateTo({
  145. url: "./gsequipment?shebei=" + JSON.stringify(data)
  146. })
  147. }
  148. }
  149. },
  150. onLoad(option) {
  151. this.side_type = option.type
  152. console.log(this.side_type)
  153. }
  154. }
  155. </script>
  156. <style lang="scss">
  157. .search_top_input {
  158. width: 90%;
  159. height: 54rpx;
  160. background-color: #E4E4E4;
  161. border-radius: 27rpx;
  162. position: absolute;
  163. top: 100rpx;
  164. right: 5%;
  165. padding-top: 8rpx;
  166. box-sizing: border-box;
  167. input {
  168. width: 85%;
  169. // text-indent: 1rem;
  170. font-size: 26rpx;
  171. padding-left: 20px;
  172. box-sizing: border-box;
  173. }
  174. .icon {
  175. position: absolute;
  176. top: 8rpx;
  177. right: 26rpx;
  178. }
  179. }
  180. .prevents {
  181. width: 100%;
  182. position: absolute;
  183. top: 94px;
  184. .prevents_item {
  185. width: 95%;
  186. margin: 0 auto 30rpx;
  187. border-radius: 10rpx;
  188. box-shadow: 0 0 10rpx #bcb9ca;
  189. padding: 20rpx 40rpx 20rpx 80rpx;
  190. position: relative;
  191. box-sizing: border-box;
  192. .prevents_item_img {
  193. width: 30rpx;
  194. height: 50rpx;
  195. position: absolute;
  196. top: -4rpx;
  197. left: 30rpx;
  198. }
  199. .prevents_item_top {
  200. display: flex;
  201. justify-content: space-between;
  202. height: 60rpx;
  203. border-bottom: 2rpx solid #F4F4F4;
  204. line-height: 60rpx;
  205. font-size: 26rpx;
  206. .red {
  207. color: #ff0000;
  208. }
  209. .green {
  210. color: #7DBB91;
  211. }
  212. }
  213. .prevents_item_bot {
  214. margin-top: 20rpx;
  215. font-size: 26rpx;
  216. color: #BDBDBD;
  217. }
  218. }
  219. }
  220. </style>