index.vue 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304
  1. <template>
  2. <div class="app-container">
  3. <el-tabs v-model="activeName" type="card" @tab-click="handleClick">
  4. <el-tab-pane label="短期" name="dq"></el-tab-pane>
  5. <el-tab-pane label="超短期" name="cdq"></el-tab-pane>
  6. </el-tabs>
  7. <div class="dark-el-input dark-el-button">
  8. <el-form ref="queryForm" size="small" :inline="true" popper-class="cpp-popper">
  9. <el-form-item label="时间范围">
  10. <el-date-picker
  11. :clearable="false"
  12. v-model="dateTime"
  13. type="monthrange"
  14. range-separator="至"
  15. :picker-options="expireDateOption"
  16. :unlink-panels="true"
  17. @change="onchange"
  18. format="yyyy-MM"
  19. placeholder="选择生成日期"
  20. popper-class="cpp-popper">
  21. </el-date-picker>
  22. </el-form-item>
  23. <el-form-item label="场站名称">
  24. <el-select v-model="stationCode" placeholder="请选择" popper-class="cpp-popper" @change="onchange">
  25. <el-option
  26. v-for="item in stationList"
  27. :key="item.value"
  28. :label="item.label"
  29. :value="item.value">
  30. </el-option>
  31. </el-select>
  32. </el-form-item>
  33. <el-form-item>
  34. <el-button type="primary" size="small" style="margin-left: 5px" icon="el-icon-search" @click="dataQuery">
  35. 查询
  36. </el-button>
  37. <el-button type="primary" size="small" style="margin-left: 5px" icon="el-icon-download" @click="exportFile">
  38. 导出
  39. </el-button>
  40. </el-form-item>
  41. </el-form>
  42. </div>
  43. <div id="masChart" style="width: 100%;height: 450px"></div>
  44. <div v-if="activeName == 'dq'">
  45. <vxe-table ref="shortTermTable" border v-loading="loading" :data="tableData" class="custom-table" max-height="300px"
  46. element-loading-background="rgba(8, 61, 92,1)">
  47. <vxe-table-column title="场站" align="center" field="station"/>
  48. <vxe-table-column title="月份" align="center" field="month" :formatter="monthFormatter"/>
  49. <vxe-table-column title="预测模型" align="center" field="preModels"/>
  50. <vxe-table-column title="短期准确率(%)" align="center" field="shortAccuracy"/>
  51. <vxe-table-column title="上报文件短期准确率(%)" align="center" field="uploadShortAccuracy"></vxe-table-column>
  52. <vxe-table-column title="准确率排名" align="center" field="accuracyRanking"/>
  53. </vxe-table>
  54. </div>
  55. <div v-else>
  56. <vxe-table ref="ultraShortTermTable" border v-loading="loading" :data="tableData" class="custom-table" max-height="300px"
  57. element-loading-background="rgba(8, 61, 92,1)">
  58. <vxe-table-column title="场站" align="center" field="station"/>
  59. <vxe-table-column title="月份" align="center" field="month" :formatter="monthFormatter"/>
  60. <vxe-table-column title="预测模型" align="center" field="preModels"/>
  61. <vxe-table-column title="超短期准确率(%)" align="center" field="shortAccuracy"/>
  62. <vxe-table-column title="上报文件超短期准确率(%)" align="center" field="uploadShortAccuracy"></vxe-table-column>
  63. <vxe-table-column title="准确率排名" align="center" field="accuracyRanking"/>
  64. </vxe-table>
  65. </div>
  66. </div>
  67. </template>
  68. <script>
  69. import * as echarts from "echarts";
  70. export default {
  71. name: 'inverterinfo',
  72. data() {
  73. return {
  74. activeName:'dq',
  75. stationName:'',
  76. showDeleteButton:true,
  77. expireDateOption: {
  78. disabledDate(time) {
  79. const today = new Date();
  80. const threeYearDate = new Date(today)
  81. threeYearDate.setFullYear(today.getFullYear() - 3)
  82. return time.getTime()<threeYearDate.getTime() || time.getTime()>today.getTime()
  83. }
  84. },
  85. loading: false,
  86. xData:[],
  87. yData:[],
  88. tableData: [],
  89. dataS:'E2',
  90. dataS4:'E4',
  91. form: [],
  92. dateTime: [ new Date(new Date().getFullYear(), new Date().getMonth(), 1).getTime(), new Date(new Date().getFullYear(), new Date().getMonth() + 1, 0, 23, 59, 59, 999).getTime()],
  93. stationList: [],
  94. stationCode: '',
  95. forecastType: "dq",
  96. }
  97. },
  98. created() {
  99. this.getStationCode()
  100. },
  101. mounted() {},
  102. beforeDestroy() {
  103. if (!this.chart) {
  104. return
  105. }
  106. this.chart.dispose()
  107. this.chart = null
  108. },
  109. computed: {},
  110. methods: {
  111. monthFormatter({cellValue, row, column}){
  112. return cellValue;
  113. },
  114. onchange(){
  115. this.dataQuery()
  116. },
  117. handleClick(tab, event){
  118. this.forecastType = tab.name
  119. this.dataQuery()
  120. },
  121. exportFile(){
  122. const modifyData = this.tableData.map(item=>({
  123. ...item,
  124. month:item.month.substring(0,4)+"年"+item.month.substring(5,item.month.length)+"月"
  125. }))
  126. let startMonth = new Date(this.dateTime[0]).getFullYear() + '-' +(new Date(this.dateTime[0]).getMonth()+1)+'月'
  127. let endMonth = new Date(this.dateTime[1]).getFullYear() + '-' +(new Date(this.dateTime[1]).getMonth()+1)+'月'
  128. if (this.activeName == 'dq'){
  129. this.$refs.shortTermTable.exportData({
  130. filename: startMonth==endMonth?startMonth+'短期模型准确率统计':startMonth+'至'+endMonth+'短期模型准确率统计',
  131. type: 'csv',
  132. isHeader: true,
  133. isFooter: true,
  134. data:modifyData
  135. })
  136. }else if (this.activeName == 'cdq'){
  137. this.$refs.ultraShortTermTable.exportData({
  138. filename: startMonth==endMonth?startMonth+'超短期模型准确率统计':startMonth+'至'+endMonth+'超短期模型准确率统计',
  139. type: 'csv',
  140. isHeader: true,
  141. isFooter: true,
  142. data:modifyData
  143. })
  144. }
  145. },
  146. dataQuery(){
  147. var find = this.stationList.find(s=>s.value == this.stationCode);
  148. this.stationName = find.label
  149. this.xData = []
  150. this.yData = []
  151. let startTime = Math.round(this.dateTime[0])
  152. let endTime = Math.round(this.dateTime[1])
  153. let queryParams = {
  154. "stationCode": this.stationCode,
  155. "startTime": startTime,
  156. "endTime": endTime,
  157. "forecastType": this.forecastType,
  158. "dataSources": 'E2',
  159. "uploadDataSources": 'E4',
  160. "stationName":this.stationName
  161. }
  162. this.$axios.get('/accuracyPassRate/getByMonthBetweenAndForecastTypeAndStationCode', {params: queryParams}).then(response => {
  163. if (response.data){
  164. for (const [key,value] of Object.entries(response.data)){
  165. this.xData.push(key)
  166. this.yData.push(value.toFixed(2))
  167. }
  168. }
  169. }).catch(() => {}).finally(()=>{
  170. this.initChart()
  171. })
  172. this.$axios.get('/accuracyPassRate/getBySingleMonthBetweenAndForecastTypeAndStationCode', {params: queryParams}).then(response => {
  173. if (response.data){
  174. this.tableData = response.data || []
  175. }
  176. })
  177. },
  178. getStationCode() {
  179. this.$axios({url: '/electricfield/all', method: 'get'}).then(response => {
  180. this.stationList = response.data
  181. if (this.stationList.length > 0) {
  182. this.stationCode = this.stationList[0].value
  183. }
  184. this.dataQuery()
  185. })
  186. },
  187. initChart() {
  188. var chartDom = document.getElementById('masChart');
  189. this.chart = echarts.init(chartDom);
  190. this.chart.setOption({
  191. title: {
  192. top: 20,
  193. text: '综合准确率',
  194. textStyle: {
  195. color:'#fff',
  196. fontWeight: 'normal',
  197. fontSize: 16,
  198. },
  199. left: 'center'
  200. },
  201. tooltip: {
  202. trigger: 'axis',
  203. axisPointer: {
  204. type: 'shadow'
  205. }
  206. },
  207. grid: {
  208. left: '3%',
  209. right: '4%',
  210. bottom: '3%',
  211. containLabel: true
  212. },
  213. xAxis: [
  214. {
  215. type: 'category',
  216. data: this.xData,
  217. axisTick: {
  218. alignWithLabel: true
  219. },
  220. axisLabel: {
  221. textStyle: {
  222. color: '#ffffff',
  223. fontWeight: 500,
  224. fontSize: '14'
  225. },
  226. },
  227. }
  228. ],
  229. yAxis: [
  230. {
  231. name: '%',
  232. nameTextStyle: {
  233. color: '#ffffff',
  234. fontSize: 12,
  235. padding: 10
  236. },
  237. type: 'value',
  238. axisLabel: {
  239. textStyle: {
  240. color: '#ffffff',
  241. fontWeight: 500,
  242. fontSize: '14'
  243. },
  244. },
  245. }
  246. ],
  247. series: [
  248. {
  249. // name: 'Direct',
  250. type: 'bar',
  251. barWidth: '60%',
  252. data: this.yData,
  253. markLine:{
  254. data:[
  255. {
  256. silent:true,
  257. yAxis:65,
  258. label:{
  259. position:'end',
  260. formatter:'65',
  261. color:'#4d69da',
  262. },
  263. lineStyle:{
  264. type:'dashed',
  265. color:'#3c73ea',
  266. width:1
  267. }
  268. },
  269. ]
  270. },
  271. }
  272. ]
  273. })
  274. },
  275. }
  276. }
  277. </script>
  278. <style scoped>
  279. ::v-deep .el-tabs__nav-scroll{
  280. display: flex;
  281. justify-content: center;
  282. width: 50% !important;
  283. margin: 0 auto !important;
  284. }
  285. /deep/ .reg-config-btu .el-button:first-child {
  286. margin-top: 5px;
  287. }
  288. /deep/ .reg-config-btu .el-button {
  289. margin-top: 10px;
  290. }
  291. /deep/ .reg-config-btu .el-button:last-child {
  292. margin-bottom: 10px;
  293. }
  294. /deep/ .reg-config-btu .el-button + .el-button {
  295. margin-left: 0px;
  296. }
  297. </style>