index.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346
  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. if(this.drawData.displayKyLl == '1'){
  152. this.tableColumn = [
  153. { field: 'time', title: '接入时间',formatter:this.dateFormat,sortable:true,minWidth:"150",width:"180" },
  154. { field: 'realValue', title: '实际功率',minWidth:"60"},
  155. { field: 'ableValue', title: '可用功率',minWidth:"60"},
  156. { field: 'theoryValue', title: '理论功率',minWidth:"60"},
  157. { field: 'referencePowerByMeasuring', title: '参照理论功率(测风、测光法)',minWidth:"60"},
  158. { field: 'referencePowerBySample', title: '参照理论功率(样板机法)',minWidth:"60"},
  159. { field: 'ablePowerByMeasuring', title: '参照可用功率(测风、测光法)',minWidth:"60"},
  160. { field: 'ablePowerBySample', title: '参照可用功率(样板机法)',minWidth:"60"},
  161. // { field: 'openCapacity', title: '开机容量',minWidth:"60"},
  162. // { field: 'isRationingByManualControl', title: '人工判断是否限电',formatter:this.isRationingByManualControl,minWidth:"60"},
  163. // { field: 'isRationingByAutoControl', title: '系统判断是否限电',formatter:this.isRationingByAutoControl,minWidth:"60"},
  164. // { field: 'capacity', title: '装机容量',minWidth:"60"},
  165. // { field: 'onGridNum', title: '并网设备',minWidth:"60"}
  166. ]
  167. }else {
  168. this.tableColumn = [
  169. { field: 'time', title: '接入时间',formatter:this.dateFormat,sortable:true,minWidth:"150",width:"180" },
  170. { field: 'realValue', title: '实际功率',minWidth:"60"},
  171. // { field: 'openCapacity', title: '开机容量',minWidth:"60"},
  172. // { field: 'isRationingByManualControl', title: '人工判断是否限电',formatter:this.isRationingByManualControl,minWidth:"60"},
  173. // { field: 'isRationingByAutoControl', title: '系统判断是否限电',formatter:this.isRationingByAutoControl,minWidth:"60"},
  174. // { field: 'capacity', title: '装机容量',minWidth:"60"},
  175. // { field: 'onGridNum', title: '并网设备',minWidth:"60"}
  176. ]
  177. }
  178. if(this.drawData.abnormalShow == '1'){
  179. this.tableColumn .push({ field: 'abnormalOfMeasuring', title: '测风光法的异常值',minWidth:"60"})
  180. this.tableColumn .push({ field: 'abnormalOfSample', title: '样板机法的异常值',minWidth:"60"})
  181. this.tableColumn .push({ field: 'abnormalOfHubSpeed', title: '机头风速法的异常值',minWidth:"60"})
  182. }
  183. if(this.drawData.displaySz == '1'){
  184. this.tableColumn .push({ field: 'onSiteObstructed', title: '站内受阻功率',minWidth:"60"})
  185. this.tableColumn .push({ field: 'offSiteObstructed', title: '站外受阻功率',minWidth:"60"})
  186. this.tableColumn .push({ field: 'abandonmentRates', title: '弃电率指标%',minWidth:"60"})
  187. }
  188. if(this.drawData.displayJt == '1'){
  189. this.tableColumn .push({ field: 'referencePowerByHubSpeed', title: '参照理论功率(机头风速法)',minWidth:"60"})
  190. this.tableColumn .push({field: 'ablePowerByHubSpeed', title: '参照可用功率(机头风速法)',minWidth:"60"})
  191. this.tableColumn .push({ field: 'abnormalOfHubSpeed', title: '机头风速法的异常值',minWidth:"60"})
  192. }
  193. if(this.drawData.hasTableColumn == 'true'){
  194. for (let i = 0; i < this.drawData.tableColumns.length; i++) {
  195. this.tableColumn.push(this.drawData.tableColumns[i])
  196. }
  197. }
  198. if(!this.drawLoading && !this.tableLoading){
  199. this.loading = false
  200. }
  201. }).catch((error) => {
  202. this.drawLoading = false
  203. if(!this.drawLoading && !this.tableLoading){
  204. this.loading = false
  205. }
  206. this.$message.error('查询实时预测短期echarts出错' + error)
  207. })
  208. },
  209. getTable(){
  210. this.tableLoading = true
  211. this.$axios.get('/powerStationStatus/'+this.queryStartTime+'/'+this.queryEndTime+'/'+this.currentPage+'/'+this.pageSize+'?sortOrder='+this.sortOrder).then((res) => {
  212. this.tableData = res.data.content
  213. // 表分页格数据总条数
  214. this.total = res.data.count
  215. this.tableLoading = false
  216. if(!this.drawLoading && !this.tableLoading){
  217. this.loading = false
  218. }
  219. }).catch((error) => {
  220. this.tableLoading = false
  221. if(!this.drawLoading && !this.tableLoading){
  222. this.loading = false
  223. }
  224. this.$message.error('查询table出错' + error)
  225. })
  226. },
  227. handlePageChange ({ currentPage, pageSize }) {
  228. this.currentPage = currentPage
  229. this.pageSize = pageSize
  230. this.startTime = this.queryStartTime
  231. this.endTime = this.queryEndTime
  232. this.loading = true
  233. this.getTable();
  234. },
  235. dateFormat({ cellValue, row, column }) {
  236. // return this.$XEUtils.toDateString(cellValue, 'yyyy-MM-dd HH:mm:ss')
  237. const date = new Date(cellValue) // 时间戳为10位需*1000,时间戳为13位的话不需乘1000
  238. const Y = date.getFullYear() + '-'
  239. const M = (date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1) + '-'
  240. const D = (date.getDate() < 10 ? '0' + (date.getDate()) : date.getDate()) + ' '
  241. const H = (date.getHours() < 10 ? '0' + (date.getHours()) : date.getHours()) + ':'
  242. const m = (date.getMinutes() < 10 ? '0' + (date.getMinutes()) : date.getMinutes()) + ':'
  243. const s = (date.getSeconds() < 10 ? '0' + (date.getSeconds()) : date.getSeconds())
  244. return Y + M + D + H + m + s
  245. },
  246. isRationingByManualControl({ cellValue, row, column }) {
  247. if (cellValue == 1){
  248. return '限电'
  249. }
  250. if (cellValue == 0){
  251. return '系统判断'
  252. }
  253. return '不限电'
  254. },
  255. isRationingByAutoControl({ cellValue, row, column }) {
  256. if (cellValue){
  257. return '限电'
  258. }
  259. return '不限电'
  260. },
  261. sortChangeEvent ({ column, property, order }) {
  262. if(order == null){
  263. order = 'asc'
  264. }
  265. this.currentPage = 1
  266. this.sortOrder = order
  267. this.loading = true
  268. this.getTable()
  269. },
  270. checkColumnMethod ({ column }) {
  271. if (column.property === 'preTime') {
  272. return false
  273. }
  274. return true
  275. },
  276. dateQuery(){
  277. this.loading = true
  278. if(this.endTime<=this.startTime){
  279. this.$message.error("开始时间不能大于结束时间")
  280. this.startTime = this.queryStartTime
  281. this.endTime = this.queryEndTime
  282. this.loading = false
  283. return
  284. }
  285. if(this.endTime-this.startTime> 60 * 60 * 24 * 1000*31){
  286. this.startTime = this.queryStartTime
  287. this.endTime = this.queryEndTime
  288. this.$message.error("只能最多查询31天的数据哦")
  289. this.loading = false
  290. return
  291. }
  292. this.queryStartTime = this.startTime
  293. this.queryEndTime = this.endTime
  294. this.getDraw(this.queryStartTime,this.queryEndTime)
  295. this.getTable()
  296. },
  297. Byresize(tab){
  298. if(tab.name =='first'){
  299. this.resizeKey++
  300. this.showToolBar = false
  301. }else{
  302. this.showToolBar = true
  303. }
  304. },
  305. }
  306. }
  307. </script>
  308. <style scoped>
  309. /*.chart-container{*/
  310. /*position:relative;*/
  311. /*width:100%;*/
  312. /*height:calc(100vh - 50px);*/
  313. /*}*/
  314. /*.timeText{*/
  315. /*opacity:0.69;*/
  316. /*padding-right:7px;*/
  317. /*font-size:14px;*/
  318. /*}*/
  319. /*.startTime{*/
  320. /*display:inline-block;*/
  321. /*}*/
  322. /*.endTime{*/
  323. /*display:inline-block;*/
  324. /*padding-left:42px;*/
  325. /*}*/
  326. /*.tableContent{*/
  327. /*width: 100%;*/
  328. /*height:calc(80vh - 50px);*/
  329. /*}*/
  330. /*.toolbar{*/
  331. /*position:absolute;right:0px;*/
  332. /*}*/
  333. </style>