@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
  * @Author: dayan_hjm 碳排放
2
  * @Author: dayan_hjm 碳排放
3
  * @Date: 2023-10-23 09:32:12 
3
  * @Date: 2023-10-23 09:32:12 
4
  * @Last Modified by: dayan_hjm
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
 import styles from "../style.less";
10
 import styles from "../style.less";
11
 import { useHistory, useLocation, withRouter } from "react-router-dom";
11
 import { useHistory, useLocation, withRouter } from "react-router-dom";
12
 import mod from '../mod';
12
 import mod from '../mod';
13
+
14
+import { getArrMax } from "@utils/util";
13
 import {
15
 import {
14
   dataengineCenterOneservice,
16
   dataengineCenterOneservice,
15
 } from "../api";
17
 } from "../api";
18
+import { get, } from "lodash";
16
 
19
 
17
 @withRouter
20
 @withRouter
18
 
21
 
@@ -22,18 +25,36 @@ class RightBottomView extends Component {
22
     super(props, context);
25
     super(props, context);
23
     this.store = mod;
26
     this.store = mod;
24
     this.state = {
27
     this.state = {
28
+      missionsTotal_arr:[],
29
+      year:[],
30
+      missionsIntensity_arr:[],
31
+      max1:0,
32
+      max2:0,
25
     };
33
     };
26
   }
34
   }
27
 
35
 
28
   componentDidMount() {
36
   componentDidMount() {
29
     this.getUrl()
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
       if (+resultCode === 0) {
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
               fontFamily: 'DingTalkJinBuTi',
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
           name: '条',
121
           name: '条',
101
           type: 'bar',
122
           type: 'bar',
102
           yAxisIndex: 0,
123
           yAxisIndex: 0,
103
-          data: [88, 73, 34],
124
+          data: this.state.missionsTotal_arr,
104
           label: {
125
           label: {
105
             normal: {
126
             normal: {
106
               show: true,
127
               show: true,
@@ -135,7 +156,7 @@ class RightBottomView extends Component {
135
           type: 'bar',
156
           type: 'bar',
136
           yAxisIndex: 1,
157
           yAxisIndex: 1,
137
           barGap: '-100%',
158
           barGap: '-100%',
138
-          data: [99.5, 99.5, 99.5],
159
+          data: this.state.max2,
139
           barWidth: 23,
160
           barWidth: 23,
140
           itemStyle: {
161
           itemStyle: {
141
             normal: {
162
             normal: {
@@ -163,7 +184,6 @@ class RightBottomView extends Component {
163
       var myChart = echarts.init(document.getElementById('echarts9'));
184
       var myChart = echarts.init(document.getElementById('echarts9'));
164
       var myColor = ['#eb2100', '#eb3600', '#d0570e', '#d0a00e', '#34da62', '#00e9db', '#00c0e9', '#0096f3'];
185
       var myColor = ['#eb2100', '#eb3600', '#d0570e', '#d0a00e', '#34da62', '#00e9db', '#00c0e9', '#0096f3'];
165
       var option = {
186
       var option = {
166
-
167
         grid: {
187
         grid: {
168
           left: '0%',
188
           left: '0%',
169
           top: '15%',
189
           top: '15%',
@@ -209,7 +229,7 @@ class RightBottomView extends Component {
209
           name: '条',
229
           name: '条',
210
           type: 'bar',
230
           type: 'bar',
211
           yAxisIndex: 0,
231
           yAxisIndex: 0,
212
-          data: [25, 55, 88],
232
+          data: this.state.missionsIntensity_arr,
213
           animation:true,
233
           animation:true,
214
           animationDuration:3000,
234
           animationDuration:3000,
215
           smooth: true,
235
           smooth: true,
@@ -246,7 +266,7 @@ class RightBottomView extends Component {
246
           type: 'bar',
266
           type: 'bar',
247
           yAxisIndex: 1,
267
           yAxisIndex: 1,
248
           barGap: '-100%',
268
           barGap: '-100%',
249
-          data: [99.5, 99.5, 99.5],
269
+          data: this.state.max1,
250
           animation:true,
270
           animation:true,
251
           animationDuration:3000,
271
           animationDuration:3000,
252
           smooth: true,
272
           smooth: true,

+ 21 - 13
src/utils/util.js

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