index.vue 7.4 KB

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