PvDetailPages.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413
  1. <template>
  2. <el-dialog width="80%" @opened="opened()" @closed="closed()" :show-close="false" custom-class="my-info-dialog">
  3. <template #title>
  4. <div style="margin-top: -10px; color: #ffffff">光伏详情</div>
  5. </template>
  6. <div class="pvDetail" v-loading="loading">
  7. <div class="pvLeftDetail">
  8. <div class="commonSty titleFont">
  9. <span>光伏板号:</span>
  10. <span style="width: 38%;color: #c3c3c3">{{windturbine.id}}</span>
  11. </div>
  12. <div class="commonSty titleFont">
  13. <span>逆变器状态</span>
  14. </div>
  15. <div v-for="(item, index) in nbqData" :key="index" class="commonSty arrSty">
  16. <div class="arrName">
  17. <span>{{item.name}}</span>
  18. </div>
  19. <div class="arrMsg">
  20. <span style="padding-right: 20px">{{item.value}}</span>
  21. <span style="width: 20%;color: #c3c3c3">{{item.unit}}</span>
  22. </div>
  23. </div>
  24. </div>
  25. <div class="pvRightDetail">
  26. <div class="pvRightDetail_top">
  27. <div class="pvRightTopTitle">
  28. <span>光伏板</span>
  29. <span>汇流箱</span>
  30. <span>逆变器</span>
  31. <span>电网</span>
  32. </div>
  33. <div class="pvRightBotImg">
  34. <div class="img1">
  35. <img src="../assets/img/PV/pv_pic.png" alt="">
  36. </div>
  37. <div class="imgCom">
  38. <img src="../assets/img/PV/pv_arrow_pic.png" alt="">
  39. </div>
  40. <div class="img2">
  41. <img src="../assets/img/PV/pv_box_pic.png" alt="">
  42. </div>
  43. <div class="imgCom">
  44. <img src="../assets/img/PV/pv_arrow_pic.png" alt="">
  45. </div>
  46. <div class="img3">
  47. <img src="../assets/img/PV/pv_nb_pic.png" alt="">
  48. </div>
  49. <div class="imgCom">
  50. <img src="../assets/img/PV/pv_arrow_pic.png" alt="">
  51. </div>
  52. <div>
  53. <img src="../assets/img/PV/pv_elec_pic.png" alt="">
  54. </div>
  55. </div>
  56. </div>
  57. <div class="pvRightDetail_bot">
  58. <div class="pvRightBotTitle">
  59. <span>功率曲线</span>
  60. </div>
  61. <div class="pvRightBotEchart" id="pvEchart"></div>
  62. </div>
  63. </div>
  64. </div>
  65. </el-dialog>
  66. </template>
  67. <script>
  68. import api from "api/index";
  69. import * as echarts from "echarts";
  70. export default {
  71. props: {
  72. windturbine: {
  73. type: Object,
  74. default: () => {
  75. return {}
  76. },
  77. },
  78. },
  79. watch: {
  80. windturbine: {
  81. handler: function (json) {
  82. if (json) {
  83. // this.initData();
  84. }
  85. },
  86. },
  87. },
  88. data() {
  89. return {
  90. nbqData: [],
  91. echartsData: [],
  92. pvTitle: [],
  93. startTimer: null,
  94. echartTimer: null,
  95. loading: false
  96. };
  97. },
  98. computed: {
  99. echartHeight() {
  100. return {
  101. 'height': document.documentElement.clientHeight-30 + 'px'
  102. }
  103. }
  104. },
  105. created() {
  106. },
  107. methods: {
  108. opened() {
  109. this.getPvStationInfoData()
  110. this.loading = true
  111. },
  112. // 获取光伏详情配置
  113. getPvStationInfoData() {
  114. let that = this
  115. that.echartsData = []
  116. api.getStationInfoData().then(datas =>{
  117. if (datas && datas.data) {
  118. console.log(datas)
  119. for(let i in datas.data) {
  120. if (that.windturbine.station === i) {
  121. this.startTimer = setInterval(() =>{
  122. that.getPvStationData(datas.data[i].codeInfos)
  123. }, 3000)
  124. this.echartTimer = setInterval(() =>{
  125. that.getEcharts(datas.data[i].codeInfos)
  126. }, 10000)
  127. }
  128. }
  129. }
  130. })
  131. },
  132. // 获取光伏详情配置数据
  133. getPvStationData(list) {
  134. console.log('list', list)
  135. console.log('windturbine', this.windturbine)
  136. let code = []
  137. list.forEach(it =>{
  138. code.push(it.code)
  139. })
  140. let params = {
  141. id: this.windturbine.id,
  142. codes: code.join(',')
  143. }
  144. api.getAllPvStationData(params).then(datas =>{
  145. if (datas && datas.data) {
  146. list.forEach(it =>{
  147. if (it.code) {
  148. let codeFv = it.code.split(',')
  149. if (codeFv.length === 1) {
  150. for(let i in datas.data) {
  151. if (it.code === i) {
  152. it.value = datas.data[i].value.toFixed(2)
  153. }
  154. }
  155. } else if (codeFv.length > 1) {
  156. for(let j =0; j<codeFv.length; j++) {
  157. let codeVal = 0
  158. for(let i in datas.data) {
  159. if (codeFv[j] === i) {
  160. codeVal += datas.data[i].value
  161. }
  162. }
  163. it.value = codeVal.toFixed(2)
  164. }
  165. }
  166. } else {
  167. it.value = 0.00
  168. }
  169. })
  170. this.nbqData = list
  171. }
  172. })
  173. },
  174. // 获取曲线数据
  175. getEcharts(data) {
  176. let end = new Date().getTime()
  177. for(let i =0; i<data.length; i++) {
  178. let it = data[i]
  179. if (it.type) {
  180. let params = {
  181. id: this.windturbine.id,
  182. code: it.code,
  183. startTime: end - 8*60*60*1000,
  184. endTime: end,
  185. interval: 60
  186. }
  187. api.getAllPvHistoryData(params).then(datas =>{
  188. let obj = {
  189. name: it.name,
  190. type: it.type,
  191. series: datas.data
  192. }
  193. this.echartsData.push(obj)
  194. if (this.echartsData.length === 3) {
  195. this.changeDataFormat(this.echartsData)
  196. }
  197. })
  198. }
  199. }
  200. },
  201. changeDataFormat(datas) {
  202. let series = []
  203. let xAxis = []
  204. let legend = []
  205. console.log('datas', datas)
  206. datas.forEach((it, index) =>{
  207. legend.push(it.name)
  208. if (index === 0) {
  209. it.series.forEach(ic =>{
  210. let time = this.getTime(new Date(ic.ts))
  211. xAxis.push(time)
  212. })
  213. }
  214. let oneSeries = []
  215. it.series.forEach(iv =>{
  216. oneSeries.push(iv.value)
  217. })
  218. let seriesObj = {
  219. name: it.name,
  220. type: 'line',
  221. data: oneSeries.map(ib => {
  222. return ib.toFixed(2)
  223. }),
  224. symbol: 'none'
  225. }
  226. series.push(seriesObj)
  227. })
  228. console.log('series', series)
  229. console.log('xAxis', xAxis)
  230. console.log('legend', legend)
  231. this.getglobalLine('pvEchart', xAxis, legend, series)
  232. },
  233. getTime(date){
  234. var h = date.getHours();
  235. h=h < 10 ? ('0' + h) : h;
  236. var minute = date.getMinutes();
  237. minute = minute < 10 ? ('0' + minute) : minute;
  238. var second=date.getSeconds();
  239. second=second < 10 ? ('0' + second) : second;
  240. return h + ':' + minute + ':' + second;
  241. },
  242. closed(){
  243. clearInterval(this.startTimer);
  244. clearInterval(this.echartTimer);
  245. this.startTimer = null
  246. this.echartTimer = null
  247. },
  248. getglobalLine(name, xAxis, legend, series) {
  249. let option = {
  250. backgroundColor: '#232d38',
  251. tooltip: {
  252. trigger: 'axis'
  253. },
  254. legend: {
  255. data: legend
  256. },
  257. grid: {
  258. left: '5%',
  259. right: '4%',
  260. bottom: '3%',
  261. containLabel: true
  262. },
  263. xAxis: {
  264. type: 'category',
  265. boundaryGap: false,
  266. data: xAxis
  267. },
  268. yAxis: {
  269. type: 'value'
  270. },
  271. series: series
  272. };
  273. // 基于准备好的dom,初始化echarts实例
  274. let dom = document.getElementById(name);
  275. dom.removeAttribute("_echarts_instance_")
  276. let myChart = echarts.init(dom, 'dark');
  277. myChart.setOption(option);
  278. this.loading = false
  279. window.addEventListener("resize", function () {
  280. myChart.resize()
  281. })
  282. },
  283. }
  284. };
  285. </script>
  286. <style lang="less" scoped>
  287. .pvDetail {
  288. background-color: black;
  289. margin-top: -30px;
  290. margin-left: -10px;
  291. margin-right: -10px;
  292. margin-bottom: -30px;
  293. border-bottom: 20px solid rgb(36, 36, 36);
  294. display: flex;
  295. padding: 5px 10px;
  296. .pvLeftDetail{
  297. width: 20%;
  298. .commonSty{
  299. height: 40px;
  300. background:#232d38;
  301. border-radius: 10px;
  302. margin-top: 10px;
  303. span{
  304. color: #fff;
  305. position: relative;
  306. top: 8px;
  307. left: 16px;
  308. }
  309. }
  310. .titleFont{
  311. width: calc(100% - 20px);
  312. font-size: 16px;
  313. display: flex;
  314. padding-right: 20px;
  315. justify-content: space-between;
  316. }
  317. .arrSty{
  318. display: flex;
  319. justify-content: space-between;
  320. span{
  321. font-size: 14px;
  322. }
  323. .arrName{
  324. width: 40%;
  325. span{
  326. color: #c3c3c3;
  327. }
  328. }
  329. .arrMsg{
  330. width: 60%;
  331. display: flex;
  332. justify-content: end;
  333. padding-right: 20px;
  334. span{
  335. display: inline-block;
  336. }
  337. }
  338. }
  339. }
  340. .pvRightDetail{
  341. width: calc(80% - 10px);
  342. padding-left: 10px;
  343. .pvRightDetail_top{
  344. background:#232d38;
  345. border-radius: 10px;
  346. margin-top: 10px;
  347. .pvRightTopTitle{
  348. display: flex;
  349. justify-content: space-around;
  350. height: 30px;
  351. color: #253443;
  352. border-bottom: 1px solid #5c5b5b;
  353. padding: 5px 0;
  354. margin-bottom: 10px;
  355. span{
  356. color: #fff;
  357. margin-top: 3px;
  358. }
  359. }
  360. .pvRightBotImg{
  361. display: flex;
  362. justify-content: space-around;
  363. padding: 50px 0;
  364. .img1{
  365. margin-top: 40px;
  366. }
  367. .img2{
  368. margin-top: 35px;
  369. }
  370. .img3{
  371. margin-top: 20px;
  372. }
  373. .imgCom{
  374. margin-top: 50px;
  375. }
  376. }
  377. }
  378. .pvRightDetail_bot{
  379. background:#232d38;
  380. border-radius: 10px;
  381. margin-top: 10px;
  382. height: 60%;
  383. .pvRightBotTitle{
  384. text-align: center;
  385. height: 20px;
  386. color: #253443;
  387. border-bottom: 1px solid #5c5b5b;
  388. padding: 10px 0;
  389. margin-bottom: 10px;
  390. span{
  391. color: #fff;
  392. }
  393. }
  394. .pvRightBotEchart{
  395. width: 100%;
  396. // height: calc(100% - 70px);
  397. height: 380px;
  398. }
  399. }
  400. }
  401. }
  402. </style>
  403. <style lang="less">
  404. .my-info-dialog{
  405. margin-top: 10vh !important;
  406. }
  407. </style>