monthAndYearBatterDialog.vue 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429
  1. <template>
  2. <el-dialog custom-class="windLifeDialog" :title="title" v-model="dialogVisible" :fullscreen="true"
  3. :close-on-click-modal="false" @close="closeDialog">
  4. <div class="globalDiaMain" v-loading="loading" :class="!theme ? 'themeDa' : 'themeLi'">
  5. <div class="main_top">
  6. <div class="main_top_left">
  7. <div class="exceed">
  8. <span style="margin-top: 3px;">时间:</span>
  9. <el-date-picker v-model="monthVal" v-if="isMonth" type="daterange" value-format="YYYY-MM-DD"
  10. :clearable='false' range-separator="至" start-placeholder="开始日期" end-placeholder="结束日期">
  11. </el-date-picker>
  12. <el-date-picker v-model="yearVal" v-else type="monthrange" value-format="YYYY-MM"
  13. range-separator="至" start-placeholder="开始月份" end-placeholder="结束月份">
  14. </el-date-picker>
  15. </div>
  16. <div class="exceed">
  17. <span style="margin-top: 3px;">超前:</span>
  18. <el-select class="exTime" v-model="chooseExceedTimeFv" placeholder="请选择">
  19. <el-option v-for="item in ExceedTimeList" :key="item.value" :label="item.label"
  20. :disabled="item.disabled" :value="item.value">
  21. </el-option>
  22. </el-select>
  23. </div>
  24. <el-button type="primary" @click="seachData">查 询</el-button>
  25. <el-button @click="exportExcel">导出查询结果</el-button>
  26. </div>
  27. </div>
  28. <div class="main_charts">
  29. <div id="centersCharts" class="chartsStyle"></div>
  30. </div>
  31. <div class="main_table warn-table" style="margin-top: 20px">
  32. <el-table :data="tableData" ref="report-table" border max-height="50vh" style="width: 100%">
  33. <el-table-column prop="dataTime" label="时间" align="center" width="160"></el-table-column>
  34. <el-table-column label="当期数据" align="center">
  35. <el-table-column prop="veryShortTermForecastDq" label="计划发电" align="center"></el-table-column>
  36. <el-table-column prop="actualPowerDq" label="实际发电" align="center"></el-table-column>
  37. <el-table-column prop="shortTermForecastDq" label="预测发电" align="center"></el-table-column>
  38. </el-table-column>
  39. <el-table-column label="同期数据" align="center">
  40. <el-table-column prop="veryShortTermForecastTq" label="计划发电" align="center"></el-table-column>
  41. <el-table-column prop="actualPowerTq" label="实际发电" align="center"></el-table-column>
  42. <el-table-column prop="shortTermForecastTq" label="预测发电" align="center"></el-table-column>
  43. </el-table-column>
  44. <el-table-column label="同期比率" align="center">
  45. <el-table-column prop="tqActualRatio" label="计划发电" align="center"></el-table-column>
  46. <el-table-column prop="tqUltraRatio" label="实际发电" align="center"></el-table-column>
  47. <el-table-column prop="tqShortRatio" label="预测发电" align="center"></el-table-column>
  48. </el-table-column>
  49. <el-table-column label="环比数据" align="center">
  50. <el-table-column prop="veryShortTermForecastSy" label="计划发电" align="center"></el-table-column>
  51. <el-table-column prop="actualPowerSy" label="实际发电" align="center"></el-table-column>
  52. <el-table-column prop="shortTermForecastSy" label="预测发电" align="center"></el-table-column>
  53. </el-table-column>
  54. <el-table-column label="环比比率" align="center">
  55. <el-table-column prop="hbActualRatio" label="计划发电" align="center"></el-table-column>
  56. <el-table-column prop="hbUltraRatio" label="实际发电" align="center"></el-table-column>
  57. <el-table-column prop="hbShortRatio" label="预测发电" align="center"></el-table-column>
  58. </el-table-column>
  59. </el-table>
  60. </div>
  61. </div>
  62. </el-dialog>
  63. </template>
  64. <script>
  65. import * as XLSX from 'xlsx'
  66. import {
  67. saveAs
  68. } from 'file-saver'
  69. import * as XLSXD from 'xlsx-js-style'
  70. import {
  71. apiGetmonthlyDailyPowerComparisonChartData,
  72. apiGetyearlyDailyPowerComparisonChartData,
  73. apiGetmonthlyDailyPowerComparisonTableData,
  74. apiGetyearlyDailyPowerComparisonTableData
  75. } from '../../../api/api'
  76. export default {
  77. props: {
  78. from: {
  79. type: String,
  80. default: () => {
  81. return '';
  82. },
  83. },
  84. ExceedTimeList: {
  85. type: Array,
  86. default: () => {
  87. return [];
  88. },
  89. },
  90. stationData: {
  91. type: Array,
  92. default: () => {
  93. return [];
  94. },
  95. },
  96. echartsTheme: {
  97. type: String,
  98. default: () => {
  99. return '';
  100. },
  101. },
  102. theme: {
  103. type: Boolean,
  104. default: () => {
  105. return false;
  106. },
  107. },
  108. },
  109. data() {
  110. return {
  111. title: '',
  112. dialogVisible: false,
  113. windTurbines: null,
  114. windTurbinesVal: null,
  115. tableData: [],
  116. chooseExceedTimeFv: 0,
  117. pickerTime: [],
  118. monthVal: [],
  119. yearVal: [],
  120. loading: false,
  121. isMonth: false
  122. }
  123. },
  124. created() {},
  125. methods: {
  126. closeDialog() {
  127. this.dialogVisible = false
  128. },
  129. seachData() {
  130. this.loading = true
  131. this.getChartsData()
  132. this.getTableData()
  133. },
  134. chooseVal(val) {
  135. this.stationData.forEach(item => {
  136. if (item.no === val) {
  137. this.windTurbinesVal = item.itemVal
  138. }
  139. })
  140. },
  141. // 全域功率预测echarts
  142. getChartsData() {
  143. let that = this
  144. let params = {
  145. leadTime: that.chooseExceedTimeFv,
  146. stationNumber: that.windTurbines,
  147. itemVal: that.windTurbinesVal
  148. }
  149. if (that.isMonth) {
  150. params.beginDataTime = that.monthVal[0]
  151. params.endDataTime = that.monthVal[1]
  152. apiGetmonthlyDailyPowerComparisonChartData(params).then(datas => {
  153. that.changeChartsData(datas)
  154. })
  155. } else {
  156. params.beginDataTime = that.yearVal[0]
  157. params.endDataTime = that.yearVal[1]
  158. delete params.leadTime
  159. apiGetyearlyDailyPowerComparisonChartData(params).then(datas => {
  160. that.changeChartsData(datas)
  161. })
  162. }
  163. },
  164. //数据处理
  165. changeChartsData(datas) {
  166. if (datas && datas.data) {
  167. let xAxis = []
  168. let series = []
  169. let legend = []
  170. if (datas.data.dateList.length > 0) {
  171. datas.data.dateList.forEach(item => {
  172. if (this.isMonth) {
  173. xAxis.push(item.substring(0, item.indexOf(' ')))
  174. } else {
  175. xAxis.push(item.substring(0, item.indexOf(' ') - 3))
  176. }
  177. })
  178. }
  179. if (datas.data.dataFormatList.length > 0) {
  180. datas.data.dataFormatList.forEach(iten => {
  181. legend.push(iten.name)
  182. let seriesObj = {
  183. name: iten.name,
  184. type: 'line',
  185. data: iten.data.map(it => {
  186. return this.$utils.isHasNum(it)
  187. }),
  188. symbol: 'none'
  189. }
  190. series.push(seriesObj)
  191. })
  192. }
  193. this.getglobalLine('centersCharts', xAxis, legend, series)
  194. }
  195. },
  196. getglobalLine(name, xAxis, legend, series) {
  197. let option = {
  198. title: {
  199. text: '电量'
  200. },
  201. tooltip: {
  202. trigger: 'axis'
  203. },
  204. legend: {
  205. right: '20',
  206. data: legend
  207. },
  208. grid: {
  209. left: '5%',
  210. right: '4%',
  211. bottom: '3%',
  212. containLabel: true
  213. },
  214. xAxis: {
  215. type: 'category',
  216. boundaryGap: false,
  217. data: xAxis
  218. },
  219. yAxis: {
  220. type: 'value',
  221. name: '万千瓦时(Wkw/h)'
  222. },
  223. series: series
  224. };
  225. if (this.from === 'index') {
  226. option.backgroundColor = ''
  227. }
  228. if (!this.theme) {
  229. option.backgroundColor = ''
  230. }
  231. // 基于准备好的dom,初始化echarts实例
  232. let dom = document.getElementById(name);
  233. dom.removeAttribute("_echarts_instance_") ? dom.removeAttribute("_echarts_instance_") : ''
  234. let myChart = this.$echarts.init(dom, this.echartsTheme);
  235. myChart.setOption(option);
  236. window.addEventListener("resize", function () {
  237. myChart.resize()
  238. })
  239. },
  240. // 全域功率预测table
  241. getTableData() {
  242. let that = this
  243. let params = {
  244. leadTime: that.chooseExceedTimeFv,
  245. stationNumber: that.windTurbines,
  246. itemVal: that.windTurbinesVal
  247. }
  248. if (that.isMonth) {
  249. params.beginDataTime = that.monthVal[0]
  250. params.endDataTime = that.monthVal[1]
  251. apiGetmonthlyDailyPowerComparisonTableData(params).then(datas => {
  252. that.changeTableData(datas)
  253. })
  254. } else {
  255. params.beginDataTime = that.yearVal[0]
  256. params.endDataTime = that.yearVal[1]
  257. delete params.leadTime
  258. apiGetyearlyDailyPowerComparisonTableData(params).then(datas => {
  259. that.changeTableData(datas)
  260. })
  261. }
  262. },
  263. changeTableData(datas) {
  264. if (datas && datas.data) {
  265. this.loading = false
  266. if (datas.data.dataFormatList) {
  267. datas.data.dataFormatList.forEach(item => {
  268. for (let i in item) {
  269. if (i !== 'dataTime') {
  270. item[i] = this.$utils.isHasNum(item[i])
  271. } else {
  272. if (!this.isMonth) {
  273. item[i] = item[i].substring(0, item[i].lastIndexOf('-'))
  274. }
  275. }
  276. }
  277. //同期计划发电
  278. item.tqActualRatio = this.$utils.ratioCalculation(item.veryShortTermForecastDq, item
  279. .veryShortTermForecastTq)
  280. //同期实际发电
  281. item.tqUltraRatio = this.$utils.ratioCalculation(item.actualPowerDq, item
  282. .actualPowerTq)
  283. //同期预测发电
  284. item.tqShortRatio = this.$utils.ratioCalculation(item.shortTermForecastDq, item
  285. .shortTermForecastTq)
  286. //环比计划发电
  287. item.hbActualRatio = this.$utils.ratioCalculation(item.veryShortTermForecastDq, item
  288. .veryShortTermForecastSy)
  289. //环比实际发电
  290. item.hbUltraRatio = this.$utils.ratioCalculation(item.actualPowerDq, item
  291. .actualPowerSy)
  292. //环比预测发电
  293. item.hbShortRatio = this.$utils.ratioCalculation(item.shortTermForecastDq, item
  294. .shortTermForecastSy)
  295. })
  296. this.tableData = datas.data.dataFormatList
  297. }
  298. }
  299. },
  300. exportExcel() {
  301. let $e = this.$refs['report-table'].$el
  302. try {
  303. let $table = $e.querySelector('.el-table__fixed')
  304. if (!$table) {
  305. $table = $e
  306. }
  307. const wb = XLSX.utils.table_to_book($table, {
  308. raw: true
  309. })
  310. if (wb && wb.Sheets.Sheet1) {
  311. let as = ['!cols', '!fullref', '!merges', '!ref', '!rows']
  312. let bs = ['时间', '当期数据', '实际发电', '预测发电', '同期数据', '同期比率', '环比数据', '环比比率']
  313. for (let i in wb.Sheets.Sheet1) {
  314. if (as.indexOf(i) < 0) {
  315. if (bs.indexOf(wb.Sheets.Sheet1[i].v) >= 0) {
  316. wb.Sheets.Sheet1[i].s = {
  317. font: {
  318. name: '微软雅黑',
  319. sz: 11,
  320. bold: true,
  321. color: {
  322. rgb: 'ffffff'
  323. }
  324. },
  325. alignment: {
  326. horizontal: 'center',
  327. vertical: 'center'
  328. },
  329. fill: {
  330. fgColor: {
  331. rgb: '4f81bd'
  332. }
  333. }
  334. }
  335. if (i === 'A1') {
  336. wb.Sheets.Sheet1['!cols'].push({
  337. wch: 30
  338. })
  339. } else if (i === 'B1') {
  340. wb.Sheets.Sheet1['!cols'].push({
  341. wch: 20
  342. })
  343. } else {
  344. wb.Sheets.Sheet1['!cols'].push({
  345. wch: 15
  346. })
  347. }
  348. } else {
  349. wb.Sheets.Sheet1[i].s = {
  350. font: {
  351. name: '微软雅黑',
  352. sz: 10,
  353. bold: false,
  354. color: {
  355. rgb: '000000'
  356. }
  357. },
  358. alignment: {
  359. horizontal: 'center',
  360. vertical: 'center'
  361. },
  362. // fill:{fgColor: {rgb: '4f81bd'}}
  363. }
  364. }
  365. }
  366. }
  367. }
  368. const wbout = XLSXD.write(wb, {
  369. bookType: 'xlsx',
  370. bookSST: true,
  371. type: 'array'
  372. })
  373. saveAs(
  374. new Blob([wbout], {
  375. type: 'application/octet-stream'
  376. }),
  377. `${this.title}.xlsx`,
  378. )
  379. } catch (e) {
  380. if (typeof console !== 'undefined') console.error(e)
  381. }
  382. }
  383. }
  384. }
  385. </script>
  386. <style lang="less">
  387. @import '../SecondaryPageStyle/globalblackStyle.less';
  388. @import '../SecondaryPageStyle/globalwhiteStyle.less';
  389. </style>
  390. <style lang="less">
  391. .globalDiaMain {
  392. .main_top {
  393. .main_top_left {
  394. .exceed {
  395. .el-date-editor {
  396. .el-input__prefix {
  397. margin-left: 5px !important;
  398. }
  399. }
  400. }
  401. }
  402. }
  403. }
  404. .themeDa {
  405. .main_top {
  406. .main_top_left {
  407. .exceed {
  408. color: #fff;
  409. }
  410. }
  411. }
  412. }
  413. .themeLi {
  414. .main_top {
  415. .main_top_left {
  416. .exceed {
  417. color: #000;
  418. }
  419. }
  420. }
  421. }
  422. </style>