1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
| // 环信码
| export function getCreditCodeCount(data) {
| const { tag, countList } = data;
| const [first, second, third] = countList;
| const total = first + second + third;
| const p1 = Math.round((first / total) * 1000) / 10;
| const p2 = Math.round((second / total) * 1000) / 10;
| const p3 = Math.round((third / total) * 1000) / 10;
|
| if (total == 0) {
| return {
| period: tag,
| count: [],
| };
| } else {
| return {
| period: tag,
| count: [
| {
| name: '绿码',
| value: first,
| diff: total == 0 ? '0%' : `${p1}%`,
| color: '#13A34C',
| },
| {
| name: '黄码',
| value: second,
| diff: total == 0 ? '0%' : `${p2}%`,
| color: '#FD9532',
| },
| {
| name: '红码',
| value: third,
| diff: total == 0 ? '0%' : `${p3}%`,
| color: '#D10C0C',
| },
| ],
| };
| }
| }
|
|