deviceOffLine.vue 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238
  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" >
  8. <select name="" id="" placeholder="" v-model="dwtype">
  9. <option value="0">请选择设备类型</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. </view>
  20. </view>
  21. <view class="cu-bar search bg-gray filter-section">
  22. <view class="search-form round bg-white" style="margin-bottom:26rpx">
  23. <select name="" id="" placeholder="" v-model=" transfer_type">
  24. <option value="0">请选择传输方式</option>
  25. <option value="NB">NB</option>
  26. <option value="4G">4G</option>
  27. <option value="Lora">Lora</option>
  28. </select>
  29. </view>
  30. <view class="action">
  31. <button class="cu-btn bg-blue round" @click="searchData()">查询</button>
  32. </view>
  33. </view>
  34. </view>
  35. <!-- 筛选框end -->
  36. <!-- 设备列表start -->
  37. <block class="">
  38. <view class="processList">
  39. <view class="cu-list menu-avatar ">
  40. <view class="cu-item" v-for="(item,index) in deviceOffLineData" :key="index" >
  41. <view class="cu-avatar lg" style="background-image:url(../../static/device-icon.png);"></view>
  42. <view class="content">
  43. <view class="pro-title">
  44. <view class="cut">{{item.owner_name}}</view>
  45. </view>
  46. <view class="pro-des ">
  47. <view class="text-cut">
  48. {{item.unitinfo}}
  49. </view>
  50. </view>
  51. <view class="pro-date ">{{item.install_time}}</view>
  52. </view>
  53. </view>
  54. </view>
  55. </view>
  56. </block>
  57. <!-- 设备列表end -->
  58. </view>
  59. </template>
  60. <script>
  61. import json from '../../data/json.js';
  62. export default {
  63. data() {
  64. return {
  65. dwtype: 0,
  66. transfer_type: 0,
  67. dwtype1: 0,
  68. transfer_type1: 0,
  69. status_type:0,
  70. deviceOffLineData:json.deviceOffLineData,
  71. siteListRes: 0,
  72. siteName: '',
  73. type: '0',
  74. siteListData: [],
  75. modalName: null,
  76. listTouchStart: 0,
  77. listTouchDirection: null,
  78. CustomBar: this.CustomBar,
  79. };
  80. },
  81. onPullDownRefresh() {
  82. },
  83. computed: {
  84. newSiteListData() {
  85. return this.siteListData.map(item => {
  86. this.$set(item, "isShow", false)
  87. return item
  88. })
  89. }
  90. },
  91. mounted() {
  92. document.addEventListener('click', (e) => {
  93. if (e.target.className != 'showDetail') {
  94. this.siteListData.forEach(item => {
  95. item.isShow = false
  96. })
  97. }
  98. })
  99. },
  100. onLoad(option) {
  101. this.status_type=option.status_type;
  102. this.getSiteList({"status_type":option.status_type,"company_code ":uni.getStorageSync('selectedCode')});
  103. let url = "";
  104. switch (parseInt(option.status_type)) {
  105. case 1:
  106. url = "离线"
  107. break;
  108. case 2:
  109. url = "在线"
  110. break;
  111. default:
  112. break;
  113. }
  114. uni.setNavigationBarTitle({
  115. title: url+"设备",
  116. });
  117. },
  118. // 自定义导航事件
  119. onNavigationBarButtonTap(e) {
  120. if (e.float == 'right') {
  121. alert("你点击了导出");
  122. this.exportData({
  123. "status_type":this.status_type,
  124. "transfer_type":this. transfer_type1,
  125. dwtype:this.dwtype1,
  126. company_code:uni.getStorageSync('selectedCode')
  127. })
  128. return;
  129. 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}/`
  130. //#ifdef H5
  131. // window.open(URL,name,features,replace)
  132. // 通过创建a标签实现
  133. const link = document.createElement("a");
  134. link.href = exportUrl;
  135. // 对下载的文件命名
  136. // link.open = "设备注册管理数据表.xls";
  137. link.target="_blank"
  138. console.log(link)
  139. link.click();
  140. // window.open(exportUrl,true)
  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. },
  165. // 导出
  166. async exportData(params) {
  167. const res = await this.$myRequest({
  168. url: 'ExportModule/getStatusDetailsListExpor',
  169. // showLoading: true,
  170.   responseType: 'blob',
  171. data: params
  172. })
  173. console.log(res);
  174.  const blob = new Blob([res.data], { type: 'application/vnd.ms-excel' });
  175.  let url = window.URL.createObjectURL(blob);
  176.                 let aLink = document.createElement('a');
  177.                 aLink.style.display = 'none';
  178.                 aLink.href = url;
  179. aLink.target="_blank";
  180. //                 aLink.setAttribute('download', res.headers['content-disposition'].split('=')[1]);
  181.                 document.body.appendChild(aLink);
  182.                 aLink.click();
  183.                 document.body.removeChild(aLink); // 下载完成移除元素
  184.                 window.URL.revokeObjectURL(url); // 释放掉blob对象
  185. },
  186. }
  187. }
  188. </script>
  189. <style>
  190. </style>