deviceOffLine.vue 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243
  1. <template>
  2. <view class="site-wrapper" ref="contentWrapper">
  3. <!-- 筛选框start -->
  4. <view style="height:224rpx"></view>
  5. <view class="ding">
  6. <view class="cu-bar search bg-gray filter-section" style="with:50%;">
  7. <view class="search-form round bg-white selectBox" >
  8. <select name="" id="" placeholder="" v-model="dwtype" clearable>
  9. <option value="">请选择设备类型</option>
  10. <option value="1">用传</option>
  11. <option value="2">水表</option>
  12. <option value="3">烟感</option>
  13. <option value="4">消防栓</option>
  14. <option value="5">液位</option>
  15. <option value="6">RTU</option>
  16. <option value="7">电气火灾</option>
  17. <option value="16">视频监测</option>
  18. </select>
  19. <text class="icon iconfont margin-right-sm margin-left">&#xe63d;</text>
  20. </view>
  21. </view>
  22. <view class="cu-bar search bg-gray filter-section">
  23. <view class="search-form round bg-white selectBox" style="margin-bottom:26rpx">
  24. <select name="" id="" placeholder="" v-model=" transfer_type" clearable>
  25. <option value="">请选择传输方式</option>
  26. <option value="NB">NB</option>
  27. <option value="4G">4G</option>
  28. <option value="Lora">Lora</option>
  29. </select>
  30. <text class="icon iconfont margin-right-sm margin-left">&#xe63d;</text>
  31. </view>
  32. <view class="action">
  33. <button class="cu-btn bg-blue round" @click="searchData()">查询</button>
  34. </view>
  35. </view>
  36. </view>
  37. <!-- 筛选框end -->
  38. <!-- 设备列表start -->
  39. <block class="">
  40. <view class="processList">
  41. <view class="cu-list menu-avatar ">
  42. <view class=" site-item text-center margin-top" v-if="!this.deviceOffLineData.length&&this.deviceOffLineDataRes==1">暂无数据...</view>
  43. <view class="cu-item" v-for="(item,index) in deviceOffLineData" :key="index" >
  44. <view class="cu-avatar lg">
  45. <image class="image-bg" src="/static/device-icon.png"/>
  46. </view>
  47. <view class="content">
  48. <view class="pro-title">
  49. <view class="cut">{{item.owner_name}}</view>
  50. </view>
  51. <view class="pro-des ">
  52. <view class="text-cut">
  53. {{item.unitinfo}}
  54. </view>
  55. </view>
  56. <view class="pro-date ">{{item.install_time}}</view>
  57. </view>
  58. </view>
  59. </view>
  60. </view>
  61. </block>
  62. <!-- 设备列表end -->
  63. </view>
  64. </template>
  65. <script>
  66. import json from '../../data/json.js';
  67. export default {
  68. data() {
  69. return {
  70. dwtype: '',
  71. transfer_type: '',
  72. dwtype1: 0,
  73. transfer_type1: 0,
  74. status_type:0,
  75. deviceOffLineData:[],
  76. deviceOffLineDataRes:0,
  77. siteListRes: 0,
  78. siteName: '',
  79. type: '0',
  80. siteListData: [],
  81. modalName: null,
  82. listTouchStart: 0,
  83. listTouchDirection: null,
  84. CustomBar: this.CustomBar,
  85. };
  86. },
  87. onPullDownRefresh() {
  88. },
  89. computed: {
  90. newSiteListData() {
  91. return this.siteListData.map(item => {
  92. this.$set(item, "isShow", false)
  93. return item
  94. })
  95. }
  96. },
  97. mounted() {
  98. document.addEventListener('click', (e) => {
  99. if (e.target.className != 'showDetail') {
  100. this.siteListData.forEach(item => {
  101. item.isShow = false
  102. })
  103. }
  104. })
  105. },
  106. onLoad(option) {
  107. this.status_type=option.status_type;
  108. this.getSiteList({"status_type":option.status_type,"company_code":uni.getStorageSync('selectedCode')});
  109. let url = "";
  110. switch (parseInt(option.status_type)) {
  111. case 1:
  112. url = "离线"
  113. break;
  114. case 2:
  115. url = "在线"
  116. break;
  117. default:
  118. break;
  119. }
  120. uni.setNavigationBarTitle({
  121. title: url+"设备",
  122. });
  123. },
  124. // 自定义导航事件 (导出操作)
  125. onNavigationBarButtonTap(e) {
  126. if (e.float == 'right') {
  127. //#ifdef H5
  128. let exportUrl= this.$BASE_URL+`ExportModule/getStatusDetailsListExpor/status_type/${this.status_type}/company_code/${uni.getStorageSync('selectedCode')}/ transfer_type/${this. transfer_type1}/dwtype/${this.dwtype1}/`
  129. var ua = window.navigator.userAgent.toLowerCase();
  130. if(ua.match(/MicroMessenger/i) == 'micromessenger'){
  131. uni.showModal({
  132. showCancel: false,
  133. content: '如需下载,请在默认浏览器中操作',
  134. success:function(res){
  135. window.location.href=exportUrl;
  136. }
  137. });
  138. }else{
  139. window.location.href=exportUrl;
  140. }
  141. //#endif
  142. }
  143. },
  144. methods: {
  145. searchData() {
  146. this.getSiteList({
  147. " transfer_type": this. transfer_type,
  148. "dwtype": this.dwtype,
  149. 'company_code': uni.getStorageSync('selectedCode'),
  150. "status_type":this.status_type
  151. })
  152. this. transfer_type1=this. transfer_type;
  153. this.dwtype1=this.dwtype;
  154. },
  155. async getSiteList(params) {
  156. const res = await this.$myRequest({
  157. url: 'StatusDetails/getStatusDetailsList',
  158. showLoading: true,
  159. data: params
  160. })
  161. this.siteListRes = 1;
  162. console.log(res.data.data)
  163. this.deviceOffLineData = res.data.data;
  164. this.deviceOffLineDataRes=1;
  165. //#ifdef H5
  166. if(this.deviceOffLineData.length<1){
  167. document.querySelector('.uni-page-head-ft .uni-page-head-btn .uni-btn-icon').style.display='none';
  168. }else{
  169. document.querySelector('.uni-page-head-ft .uni-page-head-btn .uni-btn-icon').style.display='block';
  170. }
  171. //#endif
  172. },
  173. // 导出
  174. async exportData(params) {
  175. const res = await this.$myRequest({
  176. url: 'ExportModule/getStatusDetailsListExpor',
  177. // showLoading: true,
  178.   responseType: 'blob',
  179. data: params
  180. })
  181. console.log(res);
  182.  const blob = new Blob([res.data], { type: 'application/vnd.ms-excel' });
  183.  let url = window.URL.createObjectURL(blob);
  184.                 let aLink = document.createElement('a');
  185.                 aLink.style.display = 'none';
  186.                 aLink.href = url;
  187. aLink.target="_blank";
  188.                 document.body.appendChild(aLink);
  189.                 aLink.click();
  190.                 document.body.removeChild(aLink); // 下载完成移除元素
  191.                 window.URL.revokeObjectURL(url); // 释放掉blob对象
  192. },
  193. }
  194. }
  195. </script>
  196. <style>
  197. </style>