index.vue 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292
  1. <template>
  2. <div class="chart-container">
  3. <br/>
  4. <div class="filter">
  5. <div class="startTime" style="display: inline-block">
  6. <span class="timeText" style="font-weight: bold;font-size: 14px">&#12288;起始时间:</span>
  7. <el-date-picker
  8. v-model="startTime"
  9. :clearable="false"
  10. type="datetime"
  11. value-format="timestamp"
  12. placeholder="选择日期">
  13. </el-date-picker>
  14. </div>
  15. <div class="endTime" style="display: inline-block">
  16. <span class="timeText" style="font-weight: bold;font-size: 14px">&#12288;截止时间:</span>
  17. <el-date-picker
  18. v-model="endTime"
  19. :clearable="false"
  20. type="datetime"
  21. value-format="timestamp"
  22. placeholder="选择日期">
  23. </el-date-picker>
  24. </div>
  25. </div>
  26. <br/>
  27. <div>
  28. <div style="display: inline-block">
  29. <span style="font-weight: bold;font-size: 14px">&#12288;场站名称:</span>
  30. <el-select style="width:250px" clearable v-model="stationCode" size="small">
  31. <el-option
  32. v-for="item in stationList"
  33. :key="item.stationCode"
  34. :label="item.name"
  35. :value="item.stationCode">
  36. <span style="float: left">{{ item.name }}</span>
  37. <span style="float: right; color: #8492a6;font-size: 13px">{{ item.stationCode }}</span>
  38. </el-option>
  39. </el-select>
  40. </div>
  41. <div class="timeQuery" style="display: inline-block">
  42. <el-button size="small" :loading="loading" @click="dateQuery">&#12288;查询</el-button>
  43. </div>
  44. </div>
  45. <br/>
  46. <div class="content">
  47. <el-tabs type="card" v-model="activeName" @tab-click="Byresize">
  48. <el-tab-pane label="图表" name="first">
  49. <chart :drawData=this.drawData :resizeKey=this.resizeKey
  50. />
  51. </el-tab-pane>
  52. <el-tab-pane label="表格" name="second">
  53. <div class="tableContent">
  54. <vxe-table
  55. id="fstTable"
  56. ref="fstRef"
  57. border
  58. export-config
  59. beforeExportMethod=""
  60. :loading="loading"
  61. @sort-change="sortChangeEvent"
  62. :custom-config="{storage: true, checkMethod: checkColumnMethod}"
  63. :auto-resize="true"
  64. highlight-hover-row
  65. max-height="90%"
  66. align="center"
  67. :data="tableData">
  68. <vxe-table-column field="forecastTime" title="预测时间" :formatter="dateFormat" width="180" sortable
  69. min-width="150"></vxe-table-column>
  70. <vxe-table-column field="genDate" title="生成时间" min-width="60" :formatter="dateMoment"></vxe-table-column>
  71. <vxe-table-column field="fpValue" title="预测功率" min-width="60"></vxe-table-column>
  72. <vxe-table-column field="predictionModelEnum" title="预测模型" min-width="60"
  73. :formatter="enumToWord"></vxe-table-column>
  74. </vxe-table>
  75. <div class="rtPageturning">
  76. <vxe-pager
  77. background
  78. :loading="loading"
  79. :current-page="currentPage"
  80. :page-size="pageSize"
  81. :total="total"
  82. @page-change="handlePageChange"
  83. :layouts="['PrevJump', 'PrevPage', 'JumpNumber', 'NextPage', 'NextJump', 'Sizes', 'FullJump', 'Total']">
  84. </vxe-pager>
  85. </div>
  86. </div>
  87. <!-- <Table height="100%" width="100%" :queryTime=this.queryTime @sendLoading="getLoadingFormTable"></Table>-->
  88. </el-tab-pane>
  89. </el-tabs>
  90. </div>
  91. </div>
  92. </template>
  93. <script>
  94. import Chart from './charts'
  95. import resize from '../../../components/Charts/mixins/resize'
  96. import moment from "moment";
  97. export default {
  98. name: 'dq',
  99. components: {Chart},
  100. mixins: [resize],
  101. data() {
  102. return {
  103. stationCode: '',
  104. chart: null,
  105. queryStartTime: '',
  106. queryEndTime: '',
  107. startTime: new Date(new Date().toLocaleDateString()).getTime() + 60 * 60 * 24 * 1000,
  108. endTime: new Date(new Date().toLocaleDateString()).getTime() + 60 * 60 * 24 * 1000 * 4 - 1,
  109. loading: true,
  110. drawLoading: true,
  111. tableLoading: true,
  112. resizeKey: 1,
  113. activeName: 'first',
  114. drawData: {datas: [], times: []},
  115. tableData: [],
  116. stationList: [],
  117. total: 0,
  118. sortOrder: 'asc',
  119. pageSize: 10,
  120. currentPage: 1,
  121. showToolBar: false,
  122. }
  123. },
  124. created() {
  125. this.$nextTick(() => {
  126. // 手动将表格和工具栏进行关联
  127. this.$refs.fstRef.connect(this.$refs.fstToolBar)
  128. })
  129. },
  130. mounted() {
  131. this.getStationList()
  132. this.init()
  133. },
  134. methods: {
  135. getStationList() {
  136. this.$axios.get('/electricField/getElectricField').then((res) => {
  137. this.stationList = res.data
  138. }).catch((error) => {
  139. this.$message.error('获取场站下拉框出错' + error)
  140. })
  141. this.loading = false
  142. },
  143. init() {
  144. this.pageSize = 10
  145. this.queryStartTime = this.startTime
  146. this.queryEndTime = this.endTime
  147. this.loading = false
  148. },
  149. getDraw(startTime, endTime, stationCode) {
  150. if (this.stationCode == '') {
  151. this.$message.error("场站编码不能为空")
  152. this.loading = false
  153. return
  154. }
  155. this.drawLoading = true
  156. this.$axios.get('/forecastPowerShortTerm/' + startTime + '/' + endTime + '/' + stationCode).then((res) => {
  157. this.drawData = res.data
  158. this.drawLoading = false
  159. if (!this.drawLoading && !this.tableLoading) {
  160. this.loading = false
  161. }
  162. }).catch((error) => {
  163. this.drawLoading = false
  164. if (!this.drawLoading && !this.tableLoading) {
  165. this.loading = false
  166. }
  167. this.$message.error('查询实时预测短期echarts出错' + error)
  168. })
  169. },
  170. getTable() {
  171. if (this.stationCode == '') {
  172. this.$message.error("场站编码不能为空")
  173. this.loading = false
  174. return
  175. }
  176. this.tableLoading = true
  177. this.$axios.get('/forecastPowerShortTerm/' + this.queryStartTime + '/' + this.queryEndTime + '/' + this.stationCode + '/' + this.currentPage + '/' + this.pageSize + '?sortOrder=' + this.sortOrder).then((res) => {
  178. this.tableData = res.data.content
  179. // 表分页格数据总条数
  180. this.total = res.data.count
  181. this.tableLoading = false
  182. if (!this.drawLoading && !this.tableLoading) {
  183. this.loading = false
  184. }
  185. }).catch((error) => {
  186. this.tableLoading = false
  187. if (!this.drawLoading && !this.tableLoading) {
  188. this.loading = false
  189. }
  190. this.$message.error('查询table出错' + error)
  191. })
  192. },
  193. handlePageChange({currentPage, pageSize}) {
  194. this.currentPage = currentPage
  195. if (this.pageSize != pageSize) {
  196. this.changePageSize(pageSize)
  197. }
  198. this.pageSize = pageSize
  199. this.startTime = this.queryStartTime
  200. this.endTime = this.queryEndTime
  201. this.getTable()
  202. },
  203. changePageSize(pageSize) {
  204. this.currentPage = 1
  205. this.displayConfigPageSize.showCode = pageSize
  206. this.$axios.post('displayConfig/', this.displayConfigPageSize).then((res) => {
  207. this.displayConfigPageSize = res.data
  208. // this.$message.success('PageSize设置成功' )
  209. this.dialogVisible = false
  210. }).catch((error) => {
  211. this.$message.error('PageSize设置出错' + error)
  212. })
  213. },
  214. dateFormat({cellValue, row, column}) {
  215. return this.$XEUtils.toDateString(cellValue, 'yyyy-MM-dd HH:mm:ss')
  216. },
  217. enumToWord({cellValue, row, column}) {
  218. if (cellValue == "E1") {
  219. return "云端模型"
  220. }
  221. if (cellValue == 'E2') {
  222. return "物理模型"
  223. }
  224. if (cellValue == 'E3') {
  225. return "统计模型"
  226. }
  227. if (cellValue == 'E4') {
  228. return "补录数据"
  229. }
  230. if (cellValue == 'E5') {
  231. return "差值模型"
  232. }
  233. },
  234. dateMoment({cellValue, row, column}) {
  235. return moment(cellValue).format('YYYY-MM-DD HH:mm:ss')
  236. },
  237. sortChangeEvent({column, property, order}) {
  238. if (order == null) {
  239. order = 'asc'
  240. }
  241. this.currentPage = 1
  242. this.sortOrder = order
  243. this.loading = true
  244. this.getTable()
  245. },
  246. checkColumnMethod({column}) {
  247. if (column.property === 'preTime') {
  248. return false
  249. }
  250. return true
  251. },
  252. dateQuery() {
  253. this.loading = true
  254. if (this.endTime <= this.startTime) {
  255. this.$message.error("开始时间不能小于结束时间")
  256. this.startTime = this.queryStartTime
  257. this.endTime = this.queryEndTime
  258. this.loading = false
  259. return
  260. }
  261. if (this.endTime - this.startTime > 60 * 60 * 24 * 1000 * 31) {
  262. this.startTime = this.queryStartTime
  263. this.endTime = this.queryEndTime
  264. this.$message.error("只能最多查询31天的数据哦")
  265. this.loading = false
  266. return
  267. }
  268. this.queryStartTime = this.startTime
  269. this.queryEndTime = this.endTime
  270. this.getDraw(this.queryStartTime, this.queryEndTime, this.stationCode)
  271. this.getTable()
  272. },
  273. Byresize(tab) {
  274. if (tab.name == 'first') {
  275. this.resizeKey++
  276. this.showToolBar = false
  277. } else {
  278. this.showToolBar = true
  279. }
  280. }
  281. }
  282. }
  283. </script>