index.vue 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258
  1. <template>
  2. <div class="app-container">
  3. <el-form :inline="true" size="small" class="dark-el-input dark-el-button">
  4. <el-form-item label="生成日期" prop="startTime">
  5. <el-date-picker
  6. popper-class="cpp-popper"
  7. v-model="dateTime"
  8. :clearable="false"
  9. type="date"
  10. value-format="timestamp"
  11. placeholder="选择开始日期"
  12. style="width: 255px"
  13. :picker-options="pickerOptions"
  14. >
  15. </el-date-picker>
  16. </el-form-item>
  17. <el-form-item label="场站名称">
  18. <el-select v-model="stationCode" placeholder="请选择" style="width: 255px" popper-class="cpp-popper" filterable>
  19. <el-option
  20. v-for="item in stationList"
  21. :key="item.value"
  22. :label="item.label"
  23. :value="item.value">
  24. </el-option>
  25. </el-select>
  26. </el-form-item>
  27. <el-form-item>
  28. <el-button type="primary" size="mini" style="margin-left: 5px" icon="el-icon-search"
  29. @click="queryByStationCode">查询
  30. </el-button>
  31. </el-form-item>
  32. </el-form>
  33. <div style="padding-top: 20px">
  34. <el-row :gutter="24">
  35. <el-col :span="6">
  36. <vxe-table
  37. ref="xTable"
  38. align="center"
  39. class="mytable-style"
  40. auto-resize
  41. border
  42. resizable
  43. export-config
  44. highlight-current-row
  45. show-overflow
  46. max-height="700"
  47. :loading="loading"
  48. :data="tableData">
  49. <vxe-table-column field="time" title="预测日期"></vxe-table-column>
  50. <vxe-table-column field="forecastPowerGenerationZd" title="站端上传"></vxe-table-column>
  51. <vxe-table-column field="forecastPowerGenerationYd" title="中心预测"></vxe-table-column>
  52. </vxe-table>
  53. </el-col>
  54. <el-col :span="18">
  55. <div style="width: 100%;height:600px" id="contrastCharts"></div>
  56. </el-col>
  57. </el-row>
  58. </div>
  59. </div>
  60. </template>
  61. <script>
  62. import * as echarts from "echarts";
  63. export default {
  64. name: 'predictedPowerGeneration',
  65. data() {
  66. return {
  67. dateTime: new Date(new Date().toLocaleDateString()).getTime(),
  68. stationList: [],
  69. stationCode: '',
  70. stationName: undefined,
  71. tableData: [],
  72. loading: false,
  73. predictionDataSource: '',
  74. total: 0,
  75. pageSize: 10,
  76. currentPage: 1,
  77. contrastChart: null,
  78. pickerOptions: {
  79. disabledDate: (time) => {
  80. return time.getTime() > new Date()
  81. }
  82. },
  83. }
  84. },
  85. created() {
  86. this.getStationCode()
  87. },
  88. mounted() {
  89. },
  90. beforeDestroy() {
  91. if (this.contrastChart) {
  92. this.contrastChart.dispose()
  93. this.contrastChart = null
  94. }
  95. },
  96. computed: {},
  97. methods: {
  98. handlePageChange({currentPage, pageSize}) {
  99. this.currentPage = currentPage
  100. if (this.pageSize != pageSize) {
  101. this.changePageSize(pageSize)
  102. }
  103. this.pageSize = pageSize
  104. },
  105. getStationCode() {
  106. this.$axios({url: '/electricfield/all', method: 'get'}).then(response => {
  107. this.stationList = response.data
  108. if (this.stationList.length > 0) {
  109. this.stationCode = this.stationList[0].value
  110. this.queryByStationCode()
  111. }
  112. })
  113. },
  114. queryByStationCode() {
  115. let genDate = this.dateTime
  116. const param = {
  117. "stationCode": this.stationCode,
  118. "genDate": genDate,
  119. "predictionDataSource": this.predictionDataSource
  120. }
  121. this.$axios.get('/dayPowerGeneration/getList', {params: param}).then(response => {
  122. this.loading = true
  123. this.tableData = response.data
  124. this.total = this.tableData.length
  125. this.loading = false
  126. var times = []
  127. var yd = []
  128. var zd = []
  129. for (let i = 0; i < this.tableData.length; i++) {
  130. times.push(this.tableData[i].time);
  131. yd.push(this.tableData[i].forecastPowerGenerationYd);
  132. zd.push(this.tableData[i].forecastPowerGenerationZd);
  133. }
  134. this.contrastDraw(times, zd, yd)
  135. })
  136. },
  137. contrastDraw(times, zd, yd) {
  138. this.loading = true
  139. this.contrastChart = echarts.init(document.getElementById('contrastCharts'), "dark", {renderer: 'svg'})
  140. var option = {
  141. backgroundColor: 'transparent',
  142. title: {
  143. text: '发电量变化',
  144. textStyle: {
  145. fontWeight: 'normal',
  146. fontSize: 16,
  147. },
  148. left: '1%'
  149. },
  150. tooltip: {
  151. trigger: 'axis',
  152. axisPointer: {
  153. lineStyle: {
  154. color: '#57617B'
  155. }
  156. }
  157. },
  158. legend: [{
  159. top: 20,
  160. icon: 'rect',
  161. itemWidth: 14,
  162. itemHeight: 5,
  163. itemGap: 13,
  164. data: ['站端上传', '中心预测'],
  165. right: '4%',
  166. textStyle: {
  167. fontSize: 12,
  168. }
  169. }],
  170. grid: {
  171. top: '10%',
  172. left: '3%',
  173. right: '3%',
  174. bottom: '8%',
  175. containLabel: true
  176. },
  177. xAxis: {
  178. type: 'category',
  179. // boundaryGap: false,
  180. data: times,
  181. // axisLabel: {
  182. // formatter: '{value}',
  183. // hideOverlap: true
  184. // },
  185. },
  186. yAxis: [{
  187. type: 'value',
  188. name: '万(kWh)',
  189. axisLabel: {
  190. margin: 10,
  191. textStyle: {
  192. fontSize: 14
  193. }
  194. },
  195. splitLine: {
  196. lineStyle: {
  197. color: '#57617B'
  198. }
  199. }
  200. }],
  201. series: [
  202. {
  203. name: '站端上传',
  204. type: 'bar',
  205. data: zd,
  206. lineStyle: {
  207. normal: {
  208. width: 2
  209. }
  210. },
  211. itemStyle: {
  212. normal: {
  213. color: '#ff8200',
  214. // borderColor: 'rgba(50,194,219,0.2)',
  215. borderWidth: 12
  216. }
  217. }
  218. },
  219. {
  220. name: '中心预测',
  221. type: 'bar',
  222. data: yd,
  223. lineStyle: {
  224. normal: {
  225. width: 1
  226. }
  227. },
  228. itemStyle: {
  229. normal: {
  230. color: '#EE82EE',
  231. // borderColor: 'rgba(87,219,50,0.2)',
  232. borderWidth: 12
  233. }
  234. }
  235. }
  236. ]
  237. }
  238. this.contrastChart.setOption(option, true)
  239. this.loading = false
  240. var _this = this
  241. window.addEventListener("resize", function () {
  242. _this.contrastChart.resize();
  243. });
  244. },
  245. }
  246. }
  247. </script>
  248. <style scoped>
  249. </style>