index.vue 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283
  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 class="filter">
  28. <div style="display: inline-block">
  29. <span style="font-weight: bold;font-size: 14px">场站名称:</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. <div class="content">
  46. <el-tabs type="card" v-model="activeName" @tab-click="Byresize">
  47. <el-tab-pane label="图表" name="first">
  48. <chart :drawData=this.drawData :resizeKey=this.resizeKey
  49. />
  50. </el-tab-pane>
  51. <el-tab-pane label="表格" name="second">
  52. <div class="tableContent">
  53. <vxe-grid
  54. id="nwpTable"
  55. ref="nwpRef"
  56. border
  57. export-config
  58. :loading="loading"
  59. @sort-change="sortChangeEvent"
  60. :custom-config="{storage: true, checkMethod: checkColumnMethod}"
  61. :auto-resize="true"
  62. highlight-hover-row
  63. max-height="90%"
  64. :cell-style="{background:'white',color:'black',border:'black'}"
  65. align="center"
  66. :columns="tableColumn"
  67. :data="tableData">
  68. </vxe-grid>
  69. <div class="rtPageturning">
  70. <vxe-pager
  71. background
  72. :loading="loading"
  73. :current-page.sync="currentPage"
  74. :page-size="pageSize"
  75. :total="total"
  76. @page-change="handlePageChange"
  77. :layouts="['PrevJump', 'PrevPage', 'JumpNumber', 'NextPage', 'NextJump', 'Sizes', 'FullJump', 'Total']">
  78. </vxe-pager>
  79. </div>
  80. </div>
  81. <!-- <Table height="100%" width="100%" :queryTime=this.queryTime @sendLoading="getLoadingFormTable"></Table>-->
  82. </el-tab-pane>
  83. </el-tabs>
  84. </div>
  85. </div>
  86. </template>
  87. <script>
  88. import Chart from './charts'
  89. import resize from '../../../components/Charts/mixins/resize'
  90. export default {
  91. name: 'nwp',
  92. components: {Chart},
  93. mixins: [resize],
  94. data() {
  95. return {
  96. stationCode: '',
  97. stationList: [],
  98. tableColumn: [],
  99. chart: null,
  100. queryStartTime: new Date(new Date().toLocaleDateString()).getTime() - 60 * 60 * 24 * 1000 * 10,
  101. queryEndTime: new Date(new Date().toLocaleDateString()).getTime() + 60 * 60 * 24 * 1000 * 10,
  102. startTime: new Date(new Date().toLocaleDateString()).getTime() - 60 * 60 * 24 * 1000 * 10,
  103. endTime: new Date(new Date().toLocaleDateString()).getTime() + 60 * 60 * 24 * 1000 * 10,
  104. loading: true,
  105. drawLoading: true,
  106. tableLoading: true,
  107. resizeKey: 1,
  108. activeName: 'first',
  109. drawData: {datas: [], times: []},
  110. tableData: [],
  111. statisticsData: [],
  112. total: 0,
  113. sortOrder: 'asc',
  114. pageSize: 10,
  115. currentPage: 1,
  116. showToolBar: false
  117. }
  118. },
  119. created() {
  120. this.$nextTick(() => {
  121. // 手动将表格和工具栏进行关联
  122. this.$refs.nwpRef.connect(this.$refs.nwpToolBar)
  123. })
  124. },
  125. mounted() {
  126. this.getStationList()
  127. },
  128. methods: {
  129. getStationList() {
  130. this.$axios.get('/electricField/getElectricField').then((res) => {
  131. this.stationList = res.data
  132. }).catch((error) => {
  133. this.$message.error('获取场站下拉框出错' + error)
  134. })
  135. this.loading = false
  136. },
  137. getDraw(startTime, endTime, stationCode) {
  138. this.drawLoading = true
  139. this.$axios.get('/nwp/' + startTime + '/' + endTime + '/' + stationCode).then((res) => {
  140. this.drawData = res.data
  141. this.drawLoading = false
  142. if (!this.drawLoading && !this.tableLoading) {
  143. this.loading = false
  144. }
  145. }).catch((error) => {
  146. this.drawLoading = false
  147. if (!this.drawLoading && !this.tableLoading) {
  148. this.loading = false
  149. }
  150. this.$message.error('查询实时预测短期echarts出错' + error)
  151. })
  152. },
  153. getTable() {
  154. this.tableLoading = true
  155. this.$axios.get('/nwp/' + this.queryStartTime + '/' + this.queryEndTime + '/' + this.stationCode + '/' + this.currentPage + '/' + this.pageSize + '?sortOrder=' + this.sortOrder).then((res) => {
  156. this.tableData = res.data.content
  157. // 表分页格数据总条数
  158. this.total = res.data.count
  159. this.statisticsData = res.data.statistics
  160. const cName = res.data.cName
  161. this.tableColumn = [
  162. {field: 'preTime', title: cName.preTime, formatter: this.dateFormat, minWidth: "150", width: "180"},
  163. {field: 'scTime', title: cName.scTime, minWidth: "150"},
  164. {field: 't', title: cName.t, minWidth: "90"},
  165. {field: 'rh', title: cName.rh, minWidth: "90"},
  166. {field: 'pressure', title: cName.pressure, minWidth: "90"},
  167. {field: 'swr', title: cName.swr, minWidth: "90"},
  168. {field: 'directRadiation', title: cName.directRadiation, minWidth: "90"},
  169. {field: 'diffuseRadiation', title: cName.diffuseRadiation, minWidth: "90"},
  170. {field: 'ws10', title: cName.ws10, minWidth: "90"},
  171. {field: 'ws30', title: cName.ws30, minWidth: "90"},
  172. {field: 'ws50', title: cName.ws50, minWidth: "90"},
  173. {field: 'ws70', title: cName.ws70, minWidth: "90"},
  174. {field: 'ws80', title: cName.ws80, minWidth: "90"},
  175. {field: 'ws90', title: cName.ws90, minWidth: "90"},
  176. {field: 'ws100', title: cName.ws100, minWidth: "90"},
  177. {field: 'ws170', title: cName.ws170, minWidth: "90"},
  178. {field: 'wd10', title: cName.wd10, minWidth: "90"},
  179. {field: 'wd30', title: cName.wd30, minWidth: "90"},
  180. {field: 'wd50', title: cName.wd50, minWidth: "90"},
  181. {field: 'wd70', title: cName.wd70, minWidth: "90"},
  182. {field: 'wd80', title: cName.wd80, minWidth: "90"},
  183. {field: 'wd90', title: cName.wd90, minWidth: "90"},
  184. {field: 'wd100', title: cName.wd100, minWidth: "90"},
  185. {field: 'wd170', title: cName.wd170, minWidth: "90"},
  186. ]
  187. this.tableLoading = false
  188. if (!this.drawLoading && !this.tableLoading) {
  189. this.loading = false
  190. }
  191. }).catch((error) => {
  192. this.tableLoading = false
  193. if (!this.drawLoading && !this.tableLoading) {
  194. this.loading = false
  195. }
  196. this.$message.error('查询table出错' + error)
  197. })
  198. this.tableLoading = false
  199. this.loading = false
  200. },
  201. handlePageChange({currentPage, pageSize}) {
  202. this.currentPage = currentPage
  203. if (this.pageSize != pageSize) {
  204. this.currentPage =1
  205. }
  206. this.pageSize = pageSize
  207. this.startTime = this.queryStartTime
  208. this.endTime = this.queryEndTime
  209. this.loading = true
  210. this.getTable();
  211. },
  212. dateFormat({cellValue, row, column}) {
  213. return this.$XEUtils.toDateString(cellValue, 'yyyy-MM-dd HH:mm:ss')
  214. },
  215. sortChangeEvent({column, property, order}) {
  216. if (order == null) {
  217. order = 'asc'
  218. }
  219. this.currentPage = 1
  220. this.sortOrder = order
  221. this.loading = true
  222. this.getTable()
  223. },
  224. checkColumnMethod({column}) {
  225. if (column.property === 'preTime') {
  226. return false
  227. }
  228. return true
  229. },
  230. dateQuery() {
  231. this.loading = true
  232. if (this.endTime <= this.startTime) {
  233. this.$message.error("开始时间不能小于结束时间")
  234. this.startTime = this.queryStartTime
  235. this.endTime = this.queryEndTime
  236. this.loading = false
  237. return
  238. }
  239. if (this.endTime - this.startTime > 60 * 60 * 24 * 1000 * 31) {
  240. this.startTime = this.queryStartTime
  241. this.endTime = this.queryEndTime
  242. this.$message.error("只能最多查询31天的数据哦")
  243. this.loading = false
  244. return
  245. }
  246. this.queryStartTime = this.startTime
  247. this.queryEndTime = this.endTime
  248. if (this.stationCode == '') {
  249. this.$message.error("场站编码不能为空")
  250. this.loading = false
  251. return
  252. }
  253. this.getDraw(this.queryStartTime, this.queryEndTime, this.stationCode)
  254. this.getTable()
  255. },
  256. Byresize(tab) {
  257. if (tab.name == 'first') {
  258. this.resizeKey++
  259. this.showToolBar = false
  260. } else {
  261. this.showToolBar = true
  262. }
  263. },
  264. }
  265. }
  266. </script>
  267. <style scoped>
  268. </style>