@dayan_hjm лет назад: 2
Родитель
Сommit
26b7d7d4dd
2 измененных файлов с 52 добавлено и 24 удалено
  1. 31 11
      src/pages/tqcDataVHome/component/rightBottomView.jsx
  2. 21 13
      src/utils/util.js

+ 31 - 11
src/pages/tqcDataVHome/component/rightBottomView.jsx

@@ -2,7 +2,7 @@
2 2
  * @Author: dayan_hjm 碳排放
3 3
  * @Date: 2023-10-23 09:32:12 
4 4
  * @Last Modified by: dayan_hjm
5
- * @Last Modified time: 2023-11-01 15:01:37
5
+ * @Last Modified time: 2023-11-02 15:51:27
6 6
  */
7 7
 
8 8
 
@@ -10,9 +10,12 @@ import React, { useState, useEffect, Component } from "react";
10 10
 import styles from "../style.less";
11 11
 import { useHistory, useLocation, withRouter } from "react-router-dom";
12 12
 import mod from '../mod';
13
+
14
+import { getArrMax } from "@utils/util";
13 15
 import {
14 16
   dataengineCenterOneservice,
15 17
 } from "../api";
18
+import { get, } from "lodash";
16 19
 
17 20
 @withRouter
18 21
 
@@ -22,18 +25,36 @@ class RightBottomView extends Component {
22 25
     super(props, context);
23 26
     this.store = mod;
24 27
     this.state = {
28
+      missionsTotal_arr:[],
29
+      year:[],
30
+      missionsIntensity_arr:[],
31
+      max1:0,
32
+      max2:0,
25 33
     };
26 34
   }
27 35
 
28 36
   componentDidMount() {
29 37
     this.getUrl()
30
-    this.setData();
31
-    this.setData2();
32 38
   }
33 39
 
34
-  getUrl(){
35
-    dataengineCenterOneservice().then(({ data, resultCode }) => {
40
+  async getUrl(){
41
+    await dataengineCenterOneservice().then(({ data=[], resultCode }) => {
36 42
       if (+resultCode === 0) {
43
+        let year = [],missionsIntensity_arr = [],missionsTotal_arr = [],max1=[],max2=[];
44
+        data.map((x,i)=>{
45
+          year.unshift(x.byear)
46
+          missionsIntensity_arr.unshift(x.missionsIntensity)
47
+          missionsTotal_arr.unshift(x.missionsTotal)
48
+        });
49
+        const max_1 = getArrMax(missionsIntensity_arr);
50
+        const max_2 = getArrMax(missionsTotal_arr);
51
+        for (let index = 0; index < data.length; index++) {
52
+          max1.unshift(max_1/0.8)
53
+          max2.unshift(max_2/0.8)
54
+        }
55
+        this.setState({year,missionsIntensity_arr,missionsTotal_arr,max1,max2});
56
+          this.setData();
57
+          this.setData2();    
37 58
       }
38 59
     });
39 60
 
@@ -68,7 +89,7 @@ class RightBottomView extends Component {
68 89
               fontFamily: 'DingTalkJinBuTi',
69 90
             }
70 91
           },
71
-          data: ['2020', '2021', '2022']
92
+          data: this.state.year
72 93
 
73 94
         },
74 95
         {
@@ -100,7 +121,7 @@ class RightBottomView extends Component {
100 121
           name: '条',
101 122
           type: 'bar',
102 123
           yAxisIndex: 0,
103
-          data: [88, 73, 34],
124
+          data: this.state.missionsTotal_arr,
104 125
           label: {
105 126
             normal: {
106 127
               show: true,
@@ -135,7 +156,7 @@ class RightBottomView extends Component {
135 156
           type: 'bar',
136 157
           yAxisIndex: 1,
137 158
           barGap: '-100%',
138
-          data: [99.5, 99.5, 99.5],
159
+          data: this.state.max2,
139 160
           barWidth: 23,
140 161
           itemStyle: {
141 162
             normal: {
@@ -163,7 +184,6 @@ class RightBottomView extends Component {
163 184
       var myChart = echarts.init(document.getElementById('echarts9'));
164 185
       var myColor = ['#eb2100', '#eb3600', '#d0570e', '#d0a00e', '#34da62', '#00e9db', '#00c0e9', '#0096f3'];
165 186
       var option = {
166
-
167 187
         grid: {
168 188
           left: '0%',
169 189
           top: '15%',
@@ -209,7 +229,7 @@ class RightBottomView extends Component {
209 229
           name: '条',
210 230
           type: 'bar',
211 231
           yAxisIndex: 0,
212
-          data: [25, 55, 88],
232
+          data: this.state.missionsIntensity_arr,
213 233
           animation:true,
214 234
           animationDuration:3000,
215 235
           smooth: true,
@@ -246,7 +266,7 @@ class RightBottomView extends Component {
246 266
           type: 'bar',
247 267
           yAxisIndex: 1,
248 268
           barGap: '-100%',
249
-          data: [99.5, 99.5, 99.5],
269
+          data: this.state.max1,
250 270
           animation:true,
251 271
           animationDuration:3000,
252 272
           smooth: true,

+ 21 - 13
src/utils/util.js

@@ -1,6 +1,6 @@
1 1
 import moment from "moment";
2 2
 import React, { useRef, useState } from "react";
3
-import { message,notification,Button } from "antd";
3
+import { message, notification, Button } from "antd";
4 4
 import { getFineBiToken, getPreFineBiUrl } from "@apis/outer";
5 5
 import { getDmpAccessUrl, getValueByDictCode } from "@apis/dict";
6 6
 import { getSheetToken } from "@apis/common";
@@ -295,7 +295,7 @@ export function formatNum(num = 0, n = 0) {
295 295
 
296 296
 /**判断一个时间是否在某个时间端内*/
297 297
 export function isTimes(newdate, startdate, enddate) {
298
-  var newdate = newdate ? new Date(newdate) :new Date();
298
+  var newdate = newdate ? new Date(newdate) : new Date();
299 299
   var startdate = new Date(startdate);
300 300
   console.log(newdate);
301 301
   console.log(startdate);
@@ -305,19 +305,19 @@ export function isTimes(newdate, startdate, enddate) {
305 305
   console.log(a);
306 306
   console.log(b);
307 307
   if (a < 0 || b > 0) {
308
-      return false;
308
+    return false;
309 309
   } else {
310
-      return true;
310
+    return true;
311 311
   }
312 312
 }
313 313
 
314
-export function recursion(tree=[],oldParam_={'200000':'移动端首页'}) {
314
+export function recursion(tree = [], oldParam_ = { '200000': '移动端首页' }) {
315 315
   // let  param_ = {};
316 316
   for (let index = 0; index < tree.length; index++) {
317 317
     const item = tree[index];
318 318
     oldParam_[item.resourceId] = item.resourceName; // 保存每次遍历的结果
319 319
     if ((item.resourceList).length > 0) {
320
-      recursion(item.resourceList,oldParam_);
320
+      recursion(item.resourceList, oldParam_);
321 321
     }
322 322
   }
323 323
   return oldParam_
@@ -335,25 +335,25 @@ export function calcEnc(str) {
335 335
 export function tipsLockStatus(callback) {
336 336
   const key = `open${Date.now()}`;
337 337
   const btn = <Button type="primary" onClick={() => {
338
-      notification.close(key)
339
-      callback && callback()
340
-    }}>
341
-      确定
342
-    </Button>
338
+    notification.close(key)
339
+    callback && callback()
340
+  }}>
341
+    确定
342
+  </Button>
343 343
     ;
344 344
   notification.open({
345 345
     message: '消息提示',
346 346
     description:
347 347
       `您的密码将于${sessionStorage.getItem("accountLockTime")}过期,过期后将无法使用数据门户,请点击“确认”立即修改密码,或在3天内前往【首页-右上角-点击头像】修改密码!`,
348 348
     btn,
349
-    duration:null,
349
+    duration: null,
350 350
     placement: 'topLeft',
351 351
     key,
352 352
     style: {
353 353
       width: "600px",
354 354
       bottom: "auto",
355 355
       minHeight: "200px",
356
-    borderRadius: "10px",
356
+      borderRadius: "10px",
357 357
     },
358 358
     onClose: () => { },
359 359
   });
@@ -393,6 +393,14 @@ export function timestampToTime() {
393 393
   return datetime
394 394
 }
395 395
 
396
+export function getArrMax(arr) {
397
+  arr.sort(function (a, b) {
398
+    return a - b
399
+  })
400
+  return arr[arr.length - 1]
401
+}
402
+
403
+
396 404
 
397 405
 export async function dealDiffSheetType(item) {
398 406
   return new Promise((resolve, reject) => {