index.vue 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343
  1. <!--
  2. - Copyright (c) 2018-2025, lengleng All rights reserved.
  3. -
  4. - Redistribution and use in source and binary forms, with or without
  5. - modification, are permitted provided that the following conditions are met:
  6. -
  7. - Redistributions of source code must retain the above copyright notice,
  8. - this list of conditions and the following disclaimer.
  9. - Redistributions in binary form must reproduce the above copyright
  10. - notice, this list of conditions and the following disclaimer in the
  11. - documentation and/or other materials provided with the distribution.
  12. - Neither the name of the pig4cloud.com developer nor the names of its
  13. - contributors may be used to endorse or promote products derived from
  14. - this software without specific prior written permission.
  15. - Author: lengleng (wangiegie@gmail.com)
  16. -->
  17. <template>
  18. <div class="execution">
  19. <div class="filter">
  20. <div class="startTime" style="display: inline-block">
  21. <span class="timeText" style="font-weight: bold;font-size: 14px">&#12288;起始时间:</span>
  22. <el-date-picker
  23. v-model="startTime"
  24. :clearable="false"
  25. type="datetime"
  26. value-format="timestamp"
  27. placeholder="选择日期">
  28. </el-date-picker>
  29. </div>
  30. <div class="endTime" style="display: inline-block">
  31. <span class="timeText" style="font-weight: bold;font-size: 14px">&#12288;截止时间:</span>
  32. <el-date-picker
  33. v-model="endTime"
  34. :clearable="false"
  35. type="datetime"
  36. value-format="timestamp"
  37. placeholder="选择日期">
  38. </el-date-picker>
  39. </div>
  40. <div class="timeQuery" style="display: inline-block">
  41. &#12288;<el-button size="small" :loading="loading" @click="queryDataForCharts">查询</el-button>
  42. <el-button size="small" :loading="loading" @click="exportDataEvent">导出</el-button>
  43. </div>
  44. </div>
  45. <el-tabs type="card" v-model="activeName" @tab-click="handleClick">
  46. <el-tab-pane label="预测对比图" name="first">
  47. <div style="width: 100%; height: calc(80vh - 50px)" id="echarts"></div>
  48. </el-tab-pane>
  49. <el-tab-pane label="预测表格" name="second">
  50. <vxe-table
  51. align="center"
  52. :loading="loading"
  53. ref="xTable"
  54. auto-resize
  55. border
  56. resizable
  57. highlight-current-row
  58. show-overflow
  59. :data="tableData.slice((currentPage-1)*pageSize,currentPage*pageSize)"
  60. >
  61. <vxe-table-column
  62. v-for="(item, index) in fromHead"
  63. :key="index"
  64. align="center"
  65. :title="item.label"
  66. :field="item.field"
  67. ></vxe-table-column>
  68. </vxe-table>
  69. <vxe-pager
  70. perfect
  71. :current-page.sync="currentPage"
  72. :page-size.sync="pageSize"
  73. :total="total"
  74. :page-sizes=[10,50,100]
  75. :layouts="['PrevJump', 'PrevPage','JumpNumber', 'NextPage', 'NextJump', 'Sizes', 'FullJump', 'Total']"
  76. @page-change="handlePageChange"
  77. >
  78. </vxe-pager>
  79. </el-tab-pane>
  80. </el-tabs>
  81. </div>
  82. </template>
  83. <script>
  84. import {mapGetters} from 'vuex'
  85. import * as echarts from 'echarts';
  86. import {
  87. queryCharts
  88. } from '@/api/windtotalpowercontrast'
  89. import {queryTableData} from "@/api/windtowerstatusdata";
  90. export default {
  91. name: 'windtotalpowercontrast',
  92. data() {
  93. return {
  94. searchForm: {},
  95. tableData: [],
  96. page: {
  97. total: 0, // 总页数
  98. currentPage: 1, // 当前页数
  99. pageSize: 20 // 每页显示多少条
  100. },
  101. total: 0, // 总页数
  102. currentPage: 1, // 当前页数
  103. pageSize: 10, // 每页显示多少条
  104. wsChart:null,
  105. tableLoading: false,
  106. startTime: new Date(new Date().toLocaleDateString()).getTime(),
  107. endTime: new Date(new Date().toLocaleDateString()).getTime() + 60 * 60 * 24 * 1000 - 1,
  108. stationCode: '',
  109. stationType:'',
  110. stationList: [],
  111. forecastManufactor: '',
  112. forecastManufactorList: [],
  113. drawData: {datas: [], times: []},
  114. resizeKey: 1,
  115. activeName: 'first',
  116. loading: false,
  117. ultraShortData: [],
  118. shortData: [],
  119. powerStationStatusData: [],
  120. timeStamp: [],
  121. arrays: [],
  122. fromHead: []
  123. }
  124. },
  125. computed: {
  126. ...mapGetters(['permissions']),
  127. },
  128. mounted() {
  129. },
  130. methods: {
  131. queryDataForCharts() {
  132. if (this.startTime==null){
  133. this.$message.warning('请选择开始时间')
  134. return
  135. }
  136. if (this.endTime==null){
  137. this.$message.warning('请选择结束时间')
  138. return
  139. }
  140. const param = new URLSearchParams()
  141. param.append('startTime', this.startTime)
  142. param.append('endTime', this.endTime)
  143. queryCharts(param).then((res) => {
  144. this.drawData = res.data.data
  145. this.fromHead = res.data.data.headList
  146. this.tableData = res.data.data.tableList
  147. this.total = res.data.data.tableList.length
  148. this.dqDraw(this.drawData)
  149. }).catch((error) => {
  150. if (!this.tableLoading) {
  151. this.loading = false
  152. }
  153. console.log(error)
  154. this.$message.error('查询总功率charts出错' + error)
  155. })
  156. },
  157. handleClick() {
  158. if (this.activeName === "first") {
  159. this.chart = null
  160. this.$nextTick(() => {
  161. this.dqDraw(this.drawData)
  162. this.chart.resize()
  163. })
  164. } else if (this.activeName === "second") {
  165. this.wsChart = null
  166. }
  167. },
  168. dqDraw(dqData) {
  169. this.wsChart = echarts.init(document.getElementById('echarts'))
  170. var option = {
  171. backgroundColor: 'transparent',
  172. animation: false,
  173. title: {
  174. top: 20,
  175. text: '总功率对比',
  176. textStyle: {
  177. fontWeight: 'normal',
  178. fontSize: 16,
  179. // color: this.lineColor
  180. },
  181. left: '1%'
  182. },
  183. tooltip: {
  184. trigger: 'axis',
  185. axisPointer: {
  186. lineStyle: {
  187. color: '#57617B'
  188. },
  189. },
  190. },
  191. legend: {
  192. top: 20,
  193. width: '70%',
  194. icon: 'rect',
  195. itemWidth: 14,
  196. itemHeight: 5,
  197. itemGap: 13,
  198. data: [],
  199. right: '4%',
  200. textStyle: {
  201. fontSize: 12,
  202. // color: this.lineColor
  203. },
  204. selected: {}
  205. },
  206. dataZoom: [{
  207. show: true,
  208. realtime: false,
  209. start: 0,
  210. end: 100,
  211. left: "15%",
  212. right: "15%",
  213. textStyle: {
  214. // color: this.lineColor
  215. }
  216. }, {
  217. type: 'inside',
  218. }],
  219. grid: {
  220. top: 100,
  221. left: '2%',
  222. right: '2%',
  223. bottom: '10%',
  224. containLabel: true
  225. },
  226. xAxis: [{
  227. type: 'category',
  228. boundaryGap: false,
  229. axisLine: {
  230. lineStyle: {
  231. // color: this.lineColor
  232. }
  233. },
  234. data: []
  235. }],
  236. yAxis: [{
  237. type: 'value',
  238. name: 'MW',
  239. axisTick: {
  240. show: false
  241. },
  242. axisLine: {
  243. lineStyle: {
  244. // color: this.lineColor
  245. }
  246. },
  247. axisLabel: {
  248. margin: 10,
  249. textStyle: {
  250. fontSize: 14,
  251. // color: this.lineColor
  252. },
  253. formatter: '{value}',
  254. },
  255. splitLine: {
  256. lineStyle: {
  257. color: '#57617B'
  258. }
  259. }
  260. }],
  261. series: []
  262. }
  263. option.xAxis[0].data = dqData.time
  264. var index = 0;
  265. for (var key in dqData.chart) {
  266. option.legend.data.push(key)
  267. var sValue = {
  268. name: '',
  269. type: 'line',
  270. smooth: false,
  271. symbol: 'circle',
  272. symbolSize: 5,
  273. showSymbol: false,
  274. lineStyle: {
  275. normal: {
  276. width: 2
  277. }
  278. },
  279. itemStyle: {},
  280. data: []
  281. }
  282. sValue.name = key
  283. sValue.data = dqData.chart[key]
  284. // sValue.itemStyle = this.lineStyle[index].itemStyle
  285. sValue.connectNulls = true
  286. option.series.push(sValue)
  287. index++;
  288. }
  289. this.wsChart.setOption(option, true)
  290. var _this = this
  291. window.addEventListener("resize", function () {
  292. _this.wsChart.resize();
  293. });
  294. },
  295. exportDataEvent() {
  296. if (this.startTime==null){
  297. this.$message.warning('请选择开始时间')
  298. return
  299. }
  300. if (this.endTime==null){
  301. this.$message.warning('请选择结束时间')
  302. return
  303. }
  304. this.$axios.get("/windtotalpowercontrast/exportDataEvent/" + this.startTime + "/" + this.endTime, {
  305. responseType: 'blob'// 用于解决中文乱码
  306. }).then((response) => {
  307. this.loading = false
  308. }).catch((error) => {
  309. this.loading = false
  310. this.$message.error('导出失败' + error)
  311. })
  312. },
  313. getCapacity(param) {
  314. return new Promise(function (resolve, reject) {
  315. getCapacity(param).then(response => {
  316. resolve(response.data.data)
  317. })
  318. })
  319. },
  320. handlePageChange({currentPage, pageSize}) {
  321. this.currentPage = currentPage;//当前页
  322. this.pageSize = pageSize//每页显示的条数
  323. },
  324. refreshChange() {
  325. // this.getCompositeData()
  326. this.getStationCode()
  327. }
  328. }
  329. }
  330. </script>