index.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336
  1. <template>
  2. <div class="chart-container">
  3. <div class="filter">
  4. <div class="startTime">
  5. <span class="timeText">起始时间</span>
  6. <el-date-picker
  7. v-model="startTime"
  8. :clearable="false"
  9. type="datetime"
  10. value-format="timestamp"
  11. placeholder="选择日期">
  12. </el-date-picker>
  13. </div>
  14. <div class="endTime">
  15. <span class="timeText">截止时间</span>
  16. <el-date-picker
  17. v-model="endTime"
  18. :clearable="false"
  19. type="datetime"
  20. value-format="timestamp"
  21. placeholder="选择日期">
  22. </el-date-picker>
  23. </div>
  24. <div class="timeQuery">
  25. <el-button size="small" :loading="loading" @click="dateQuery">查询</el-button>
  26. </div>
  27. <div class="toolbar" v-show="this.showToolBar"> <vxe-toolbar ref="fstToolBar" custom >
  28. <!-- <template v-slot:buttons>-->
  29. <!-- <vxe-button class="downloadButton" style="border:none;" @click="exportDataEvent"><i class="vxe-icon&#45;&#45;download" ></i></vxe-button>-->
  30. <!-- </template>-->
  31. </vxe-toolbar></div>
  32. <div class="toolbar" v-show="this.showToolBar"> <vxe-toolbar ref="nwpToolBar" custom></vxe-toolbar></div>
  33. </div>
  34. <div class="content">
  35. <el-tabs type="card" v-model="activeName" @tab-click="Byresize">
  36. <el-tab-pane label="图表" name="first">
  37. <chart :drawData = this.drawData :resizeKey=this.resizeKey />
  38. </el-tab-pane>
  39. <el-tab-pane label="表格" name="second">
  40. <div class="tableContent">
  41. <vxe-grid
  42. id="nwpTable"
  43. ref="nwpRef"
  44. border
  45. export-config
  46. :loading="loading"
  47. @sort-change="sortChangeEvent"
  48. :custom-config="{storage: true, checkMethod: checkColumnMethod}"
  49. :auto-resize="true"
  50. highlight-hover-row
  51. :header-cell-style="styleStr"
  52. max-height="90%"
  53. :cell-style="styleTableStr"
  54. align="center"
  55. :data="tableData"
  56. :columns="tableColumn"
  57. >
  58. </vxe-grid>
  59. <div class="rtPageturning">
  60. <vxe-pager
  61. background
  62. :loading="loading"
  63. :current-page.sync="currentPage"
  64. :page-size.sync="pageSize"
  65. :total="total"
  66. @page-change="handlePageChange"
  67. :layouts="['PrevJump', 'PrevPage', 'JumpNumber', 'NextPage', 'NextJump', 'Sizes', 'FullJump', 'Total']">
  68. </vxe-pager>
  69. </div>
  70. </div>
  71. </el-tab-pane>
  72. </el-tabs>
  73. </div>
  74. </div>
  75. </template>
  76. <script>
  77. import Chart from './charts'
  78. import resize from '../../../components/Charts/mixins/resize'
  79. export default {
  80. name: 'nwp',
  81. components: { Chart},
  82. mixins: [resize],
  83. data(){
  84. return{
  85. styleStr:{},
  86. styleTableStr:{},
  87. tableToolbar: {
  88. export: true,
  89. custom: true
  90. },
  91. tableColumn:[],
  92. chart: null,
  93. queryStartTime:'',
  94. queryEndTime:'',
  95. startTime:new Date(new Date().toLocaleDateString()).getTime(),
  96. endTime:new Date(new Date().toLocaleDateString()).getTime() + 60 * 60 * 24 * 1000*1-1,
  97. loading:true,
  98. drawLoading:true,
  99. tableLoading:true,
  100. resizeKey:1,
  101. activeName: 'first',
  102. drawData:{datas:[],times:[]},
  103. tableData:[],
  104. total:0,
  105. sortOrder:'asc',
  106. pageSize: 10,
  107. currentPage: 1,
  108. showToolBar:false,
  109. abandonmentRates:[]
  110. }
  111. },
  112. created () {
  113. if(sessionStorage.getItem('styleSwitch') === 'blue'){
  114. this.styleStr = {background:'black',color:'white',border:'white'}
  115. this.styleTableStr = {background:'black',color:'white'}
  116. }
  117. this.$nextTick(() => {
  118. // 手动将表格和工具栏进行关联
  119. this.$refs.nwpRef.connect(this.$refs.nwpToolBar)
  120. })
  121. },
  122. mounted() {
  123. this.init()
  124. },
  125. methods:{
  126. exportDataEvent() {
  127. this.loading = true
  128. this.$axios.get('export/powerStationStatus/'+this.startTime+'/'+this.endTime, {
  129. responseType: 'blob'// 用于解决中文乱码
  130. }).then((response) => {
  131. this.loading = false
  132. }).catch((error) => {
  133. this.loading = false
  134. this.$message.error('导出失败' + error)
  135. })
  136. },
  137. init(){
  138. this.queryStartTime = this.startTime
  139. this.queryEndTime = this.endTime
  140. this.loading = true
  141. this.getDraw(this.queryStartTime,this.queryEndTime)
  142. this.getTable()
  143. },
  144. getDraw(startTime,endTime){
  145. this.drawLoading = true
  146. this.$axios.get('/powerStationStatus/'+startTime+'/'+endTime).then((res) => {
  147. this.drawData = res.data
  148. this.abandonmentRates = res.data.abandonmentRates
  149. this.drawLoading = false
  150. // this.tableColumn = []
  151. this.tableColumn = [
  152. { field: 'time', title: '接入时间',formatter:this.dateFormat,sortable:true,minWidth:"150",width:"180" },
  153. { field: 'realValue', title: '实际功率',minWidth:"60"},
  154. { field: 'ableValue', title: '可用功率',minWidth:"60"},
  155. { field: 'theoryValue', title: '理论功率',minWidth:"60"},
  156. { field: 'referencePowerByMeasuring', title: '参照理论功率(测风、测光法)',minWidth:"60"},
  157. { field: 'referencePowerBySample', title: '参照理论功率(样板机法)',minWidth:"60"},
  158. { field: 'ablePowerByMeasuring', title: '参照可用功率(测风、测光法)',minWidth:"60"},
  159. { field: 'ablePowerBySample', title: '参照可用功率(样板机法)',minWidth:"60"},
  160. { field: 'openCapacity', title: '开机容量',minWidth:"60"},
  161. // { field: 'isRationingByManualControl', title: '人工判断是否限电',formatter:this.isRationingByManualControl,minWidth:"60"},
  162. // { field: 'isRationingByAutoControl', title: '系统判断是否限电',formatter:this.isRationingByAutoControl,minWidth:"60"},
  163. { field: 'capacity', title: '装机容量',minWidth:"60"},
  164. // { field: 'onGridNum', title: '并网设备',minWidth:"60"}
  165. ]
  166. if(this.drawData.abnormalShow == '1'){
  167. this.tableColumn .push({ field: 'abnormalOfMeasuring', title: '测风光法的异常值',minWidth:"60"})
  168. this.tableColumn .push({ field: 'abnormalOfSample', title: '样板机法的异常值',minWidth:"60"})
  169. this.tableColumn .push({ field: 'abnormalOfHubSpeed', title: '机头风速法的异常值',minWidth:"60"})
  170. }
  171. if(this.drawData.displaySz == '1'){
  172. this.tableColumn .push({ field: 'onSiteObstructed', title: '站内受阻功率',minWidth:"60"})
  173. this.tableColumn .push({ field: 'offSiteObstructed', title: '站外受阻功率',minWidth:"60"})
  174. this.tableColumn .push({ field: 'abandonmentRates', title: '弃电率指标%',minWidth:"60"})
  175. }
  176. if(this.drawData.displayJt == '1'){
  177. this.tableColumn .push({ field: 'referencePowerByHubSpeed', title: '参照理论功率(机头风速法)',minWidth:"60"})
  178. this.tableColumn .push({field: 'ablePowerByHubSpeed', title: '参照可用功率(机头风速法)',minWidth:"60"})
  179. this.tableColumn .push({ field: 'abnormalOfHubSpeed', title: '机头风速法的异常值',minWidth:"60"})
  180. }
  181. if(this.drawData.hasTableColumn == 'true'){
  182. for (let i = 0; i < this.drawData.tableColumns.length; i++) {
  183. this.tableColumn.push(this.drawData.tableColumns[i])
  184. }
  185. }
  186. if(!this.drawLoading && !this.tableLoading){
  187. this.loading = false
  188. }
  189. }).catch((error) => {
  190. this.drawLoading = false
  191. if(!this.drawLoading && !this.tableLoading){
  192. this.loading = false
  193. }
  194. this.$message.error('查询实时预测短期echarts出错' + error)
  195. })
  196. },
  197. getTable(){
  198. this.tableLoading = true
  199. this.$axios.get('/powerStationStatus/'+this.queryStartTime+'/'+this.queryEndTime+'/'+this.currentPage+'/'+this.pageSize+'?sortOrder='+this.sortOrder).then((res) => {
  200. this.tableData = res.data.content
  201. // 表分页格数据总条数
  202. this.total = res.data.count
  203. this.tableLoading = false
  204. if(!this.drawLoading && !this.tableLoading){
  205. this.loading = false
  206. }
  207. }).catch((error) => {
  208. this.tableLoading = false
  209. if(!this.drawLoading && !this.tableLoading){
  210. this.loading = false
  211. }
  212. this.$message.error('查询table出错' + error)
  213. })
  214. },
  215. handlePageChange ({ currentPage, pageSize }) {
  216. this.currentPage = currentPage
  217. this.pageSize = pageSize
  218. this.startTime = this.queryStartTime
  219. this.endTime = this.queryEndTime
  220. this.loading = true
  221. this.getTable();
  222. },
  223. dateFormat({ cellValue, row, column }) {
  224. // return this.$XEUtils.toDateString(cellValue, 'yyyy-MM-dd HH:mm:ss')
  225. const date = new Date(cellValue) // 时间戳为10位需*1000,时间戳为13位的话不需乘1000
  226. const Y = date.getFullYear() + '-'
  227. const M = (date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1) + '-'
  228. const D = (date.getDate() < 10 ? '0' + (date.getDate()) : date.getDate()) + ' '
  229. const H = (date.getHours() < 10 ? '0' + (date.getHours()) : date.getHours()) + ':'
  230. const m = (date.getMinutes() < 10 ? '0' + (date.getMinutes()) : date.getMinutes()) + ':'
  231. const s = (date.getSeconds() < 10 ? '0' + (date.getSeconds()) : date.getSeconds())
  232. return Y + M + D + H + m + s
  233. },
  234. isRationingByManualControl({ cellValue, row, column }) {
  235. if (cellValue == 1){
  236. return '限电'
  237. }
  238. if (cellValue == 0){
  239. return '系统判断'
  240. }
  241. return '不限电'
  242. },
  243. isRationingByAutoControl({ cellValue, row, column }) {
  244. if (cellValue){
  245. return '限电'
  246. }
  247. return '不限电'
  248. },
  249. sortChangeEvent ({ column, property, order }) {
  250. if(order == null){
  251. order = 'asc'
  252. }
  253. this.currentPage = 1
  254. this.sortOrder = order
  255. this.loading = true
  256. this.getTable()
  257. },
  258. checkColumnMethod ({ column }) {
  259. if (column.property === 'preTime') {
  260. return false
  261. }
  262. return true
  263. },
  264. dateQuery(){
  265. this.loading = true
  266. if(this.endTime<=this.startTime){
  267. this.$message.error("开始时间不能大于结束时间")
  268. this.startTime = this.queryStartTime
  269. this.endTime = this.queryEndTime
  270. this.loading = false
  271. return
  272. }
  273. if(this.endTime-this.startTime> 60 * 60 * 24 * 1000*31){
  274. this.startTime = this.queryStartTime
  275. this.endTime = this.queryEndTime
  276. this.$message.error("只能最多查询31天的数据哦")
  277. this.loading = false
  278. return
  279. }
  280. this.queryStartTime = this.startTime
  281. this.queryEndTime = this.endTime
  282. this.getDraw(this.queryStartTime,this.queryEndTime)
  283. this.getTable()
  284. },
  285. Byresize(tab){
  286. if(tab.name =='first'){
  287. this.resizeKey++
  288. this.showToolBar = false
  289. }else{
  290. this.showToolBar = true
  291. }
  292. },
  293. }
  294. }
  295. </script>
  296. <style scoped>
  297. /*.chart-container{*/
  298. /*position:relative;*/
  299. /*width:100%;*/
  300. /*height:calc(100vh - 50px);*/
  301. /*}*/
  302. /*.timeText{*/
  303. /*opacity:0.69;*/
  304. /*padding-right:7px;*/
  305. /*font-size:14px;*/
  306. /*}*/
  307. /*.startTime{*/
  308. /*display:inline-block;*/
  309. /*}*/
  310. /*.endTime{*/
  311. /*display:inline-block;*/
  312. /*padding-left:42px;*/
  313. /*}*/
  314. /*.tableContent{*/
  315. /*width: 100%;*/
  316. /*height:calc(80vh - 50px);*/
  317. /*}*/
  318. /*.toolbar{*/
  319. /*position:absolute;right:0px;*/
  320. /*}*/
  321. </style>