index.vue 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  1. <template>
  2. <div class="app-container">
  3. <el-card class="box-card">
  4. <div class="block">
  5. <div class="conOne">
  6. <span class="demonstration">时间:</span>
  7. <el-date-picker
  8. v-model="dataTime"
  9. type="daterange"
  10. range-separator="至"
  11. start-placeholder="开始日期"
  12. end-placeholder="结束日期"
  13. :default-time="['00:00:00', '23:59:59']">
  14. </el-date-picker>
  15. </div>
  16. <div class="conOne">
  17. <span>设备:</span>
  18. <el-select v-model="eqNo" placeholder="请选择">
  19. <el-option
  20. v-for="item in equipmentAllInfo"
  21. :key="item.no"
  22. :label="item.name"
  23. :value="item.no">
  24. </el-option>
  25. </el-select>
  26. </div>
  27. <el-button :loading="btuLoading" class="myButton" type="primary" icon="el-icon-search" @click="getData">搜索</el-button>
  28. <el-button :loading="dbtuLoading" class="myButton" type="primary" icon="el-icon-download" @click="download">导出</el-button>
  29. </div>
  30. <div class="tableBox">
  31. <el-table v-loading="loading" border
  32. :data="tableAllData.slice((page.currentPage-1)*page.pageSize,page.currentPage*page.pageSize)">
  33. <el-table-column type="index" label="序号" width="55" align="center"/>
  34. <el-table-column label="时间" align="center" prop="ts" :formatter="formatDate"/>
  35. <el-table-column label="风速" align="center" prop="ws"/>
  36. <el-table-column label="风向" align="center" prop="wd"/>
  37. <el-table-column label="温度" align="center" prop="t"/>
  38. <el-table-column label="气压" align="center" prop="pa"/>
  39. <el-table-column label="湿度" align="center" prop="rh"/>
  40. </el-table>
  41. </div>
  42. <div class="block" style="float: right">
  43. <el-pagination
  44. @size-change="handleSizeChange"
  45. @current-change="handleCurrentChange"
  46. :current-page=page.currentPage
  47. :page-sizes="[10, 15, 30, 50]"
  48. :page-size=page.pageSize
  49. layout="total, sizes, prev, pager, next, jumper"
  50. :total=page.total>
  51. </el-pagination>
  52. </div>
  53. </el-card>
  54. </div>
  55. </template>
  56. <script>
  57. import {infoList} from "@/api/biz/dataQuery/weatherLook";
  58. import {list} from "@/api/biz/dataQuery/environmentalData";
  59. import download from '@/plugins/download'
  60. export default {
  61. name: "index",
  62. data() {
  63. return {
  64. loading: false,
  65. btuLoading: true,
  66. dbtuLoading: false,
  67. tableAllData: [],
  68. //时间控件 当天的零点到23:59:59
  69. dataTime: [new Date(new Date().toLocaleDateString()).getTime(), new Date(new Date().toLocaleDateString()).getTime() + 24 * 60 * 60 * 1000 -1000],
  70. page: {
  71. total: 0, // 总页数
  72. currentPage: 1, // 当前页数
  73. pageSize: 10 // 每页显示多少条
  74. },
  75. eqNo: '',
  76. equipmentAllInfo: []
  77. }
  78. },
  79. mounted() {
  80. this.getWeatherLook()
  81. },
  82. methods: {
  83. getWeatherLook() {
  84. infoList().then(res => {
  85. this.equipmentAllInfo = res.data
  86. this.eqNo = this.equipmentAllInfo[0].no
  87. this.getData()
  88. }).catch(err => {
  89. console.log('获取环境检测仪异常' + err)
  90. })
  91. },
  92. getData(){
  93. this.btuLoading = true
  94. this.loading = true
  95. let param = {
  96. startTime: new Date(this.dataTime[0]).getTime(),
  97. endTime: new Date(this.dataTime[1]).getTime(),
  98. weatherLookNo: this.eqNo,
  99. }
  100. list(param).then(res=>{
  101. this.tableAllData = res.data
  102. this.page.total = this.tableAllData.length
  103. this.btuLoading = false
  104. this.loading = false
  105. }).catch(err=>{
  106. this.btuLoading = false
  107. this.loading = false
  108. console.log('获取环境监测仪数据异常:'+err)
  109. })
  110. },
  111. download(){
  112. this.dbtuLoading = true
  113. download.weatherStationData("/environmentalData/exportAll",new Date(this.dataTime[0]).getTime(), new Date(this.dataTime[1]).getTime(), this.eqNo)
  114. const _self =this
  115. setTimeout(function (){
  116. _self.dbtuLoading = false
  117. },5000)
  118. },
  119. formatDate(row){
  120. var date = new Date(row.ts)
  121. let format = 'yyyy-MM-dd hh:mm:ss';
  122. if (date != 'Invalid Date') {
  123. var o = {
  124. "M+": date.getMonth() + 1, //month
  125. "d+": date.getDate(), //day
  126. "h+": date.getHours(), //hour
  127. "m+": date.getMinutes(), //minute
  128. "s+": date.getSeconds(), //second
  129. "q+": Math.floor((date.getMonth() + 3) / 3), //quarter
  130. "S": date.getMilliseconds() //millisecond
  131. }
  132. if (/(y+)/.test(format)) format = format.replace(RegExp.$1,
  133. (date.getFullYear() + "").substr(4 - RegExp.$1.length));
  134. for (var k in o)
  135. if (new RegExp("(" + k + ")").test(format))
  136. format = format.replace(RegExp.$1,
  137. RegExp.$1.length == 1 ? o[k] :
  138. ("00" + o[k]).substr(("" + o[k]).length));
  139. return format;
  140. }
  141. return date;
  142. },
  143. /*pageSize改变*/
  144. handleSizeChange(val) {
  145. this.page.pageSize = val
  146. this.page.currentPage = 1
  147. },
  148. /*currentPage改变*/
  149. handleCurrentChange(val) {
  150. this.page.currentPage = val
  151. },
  152. }
  153. }
  154. </script>
  155. <style scoped>
  156. .block {
  157. display: flex;
  158. }
  159. .conOne, .myButton {
  160. margin-left: .5%;
  161. }
  162. .tableBox {
  163. margin-top: 1%;
  164. }
  165. </style>