deviceOffLine.vue 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248
  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=" site-item text-center margin-top" v-if="!this.deviceOffLineData.length&&this.deviceOffLineDataRes==1">暂无数据</view>
  41. <view class="cu-item" v-for="(item,index) in deviceOffLineData" :key="index" >
  42. <view class="cu-avatar lg">
  43. <image class="image-bg" src="/static/device-icon.png"/>
  44. </view>
  45. <view class="content">
  46. <view class="pro-title">
  47. <view class="cut">{{item.owner_name}}</view>
  48. </view>
  49. <view class="pro-des ">
  50. <view class="text-cut">
  51. {{item.unitinfo}}
  52. </view>
  53. </view>
  54. <view class="pro-date ">{{item.install_time}}</view>
  55. </view>
  56. </view>
  57. </view>
  58. </view>
  59. </block>
  60. <!-- 设备列表end -->
  61. </view>
  62. </template>
  63. <script>
  64. import json from '../../data/json.js';
  65. export default {
  66. data() {
  67. return {
  68. dwtype: 0,
  69. transfer_type: 0,
  70. dwtype1: 0,
  71. transfer_type1: 0,
  72. status_type:0,
  73. deviceOffLineData:[],
  74. deviceOffLineDataRes:0,
  75. siteListRes: 0,
  76. siteName: '',
  77. type: '0',
  78. siteListData: [],
  79. modalName: null,
  80. listTouchStart: 0,
  81. listTouchDirection: null,
  82. CustomBar: this.CustomBar,
  83. };
  84. },
  85. onPullDownRefresh() {
  86. },
  87. computed: {
  88. newSiteListData() {
  89. return this.siteListData.map(item => {
  90. this.$set(item, "isShow", false)
  91. return item
  92. })
  93. }
  94. },
  95. mounted() {
  96. document.addEventListener('click', (e) => {
  97. if (e.target.className != 'showDetail') {
  98. this.siteListData.forEach(item => {
  99. item.isShow = false
  100. })
  101. }
  102. })
  103. },
  104. onLoad(option) {
  105. this.status_type=option.status_type;
  106. this.getSiteList({"status_type":option.status_type,"company_code ":uni.getStorageSync('selectedCode')});
  107. let url = "";
  108. switch (parseInt(option.status_type)) {
  109. case 1:
  110. url = "离线"
  111. break;
  112. case 2:
  113. url = "在线"
  114. break;
  115. default:
  116. break;
  117. }
  118. uni.setNavigationBarTitle({
  119. title: url+"设备",
  120. });
  121. },
  122. // 自定义导航事件
  123. onNavigationBarButtonTap(e) {
  124. if (e.float == 'right') {
  125. alert("你点击了导出");
  126. //#ifdef H5
  127. // this.exportData({
  128. // "status_type":this.status_type,
  129. // "transfer_type":this. transfer_type1,
  130. // dwtype:this.dwtype1,
  131. // company_code:uni.getStorageSync('selectedCode')
  132. // })
  133. // return;
  134. 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}/`
  135. window.location.href=exportUrl;
  136. // window.open(URL,name,features,replace)
  137. // 通过创建a标签实现
  138. const link = document.createElement("a");
  139. link.href = exportUrl;
  140. // 对下载的文件命名
  141. // link.open = "设备注册管理数据表.xls";
  142. link.target="_blank"
  143. console.log(link)
  144. link.click();
  145. // window.open(exportUrl,true)
  146. //#endif
  147. }
  148. },
  149. methods: {
  150. searchData() {
  151. this.getSiteList({
  152. " transfer_type": this. transfer_type,
  153. "dwtype": this.dwtype,
  154. 'company_code': uni.getStorageSync('selectedCode'),
  155. "status_type":this.status_type
  156. })
  157. this. transfer_type1=this. transfer_type;
  158. this.dwtype1=this.dwtype;
  159. },
  160. async getSiteList(params) {
  161. const res = await this.$myRequest({
  162. url: 'StatusDetails/getStatusDetailsList',
  163. showLoading: true,
  164. data: params
  165. })
  166. this.siteListRes = 1;
  167. console.log(res.data.data)
  168. this.deviceOffLineData = res.data.data;
  169. this.deviceOffLineDataRes=1
  170. },
  171. // 导出
  172. async exportData(params) {
  173. const res = await this.$myRequest({
  174. url: 'ExportModule/getStatusDetailsListExpor',
  175. // showLoading: true,
  176.   responseType: 'blob',
  177. data: params
  178. })
  179. console.log(res);
  180.  const blob = new Blob([res.data], { type: 'application/vnd.ms-excel' });
  181.  let url = window.URL.createObjectURL(blob);
  182.                 let aLink = document.createElement('a');
  183.                 aLink.style.display = 'none';
  184.                 aLink.href = url;
  185. aLink.target="_blank";
  186.                 document.body.appendChild(aLink);
  187.                 aLink.click();
  188.                 document.body.removeChild(aLink); // 下载完成移除元素
  189.                 window.URL.revokeObjectURL(url); // 释放掉blob对象
  190. },
  191. }
  192. }
  193. </script>
  194. <style>
  195. </style>