| 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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
 | | <template> |  |   <a-spin :loading="loading" style="width: 100%"> |  |     <a-card |  |       class="general-card" |  |       :title="title" |  |       :header-style="{ paddingBottom: '12px' }" |  |     > |  |       <div class="content"> |  |         <a-statistic |  |           :value="count" |  |           :show-group-separator="true" |  |           :value-from="0" |  |           animation |  |         /> |  |         <a-typography-text |  |           class="percent-text" |  |           :type="isUp ? 'danger' : 'success'" |  |         > |  |           {{ growth }}% |  |           <icon-arrow-rise v-if="isUp" /> |  |           <icon-arrow-fall v-else /> |  |         </a-typography-text> |  |       </div> |  |       <div class="chart"> |  |         <Chart :option="chartOption" /> |  |       </div> |  |     </a-card> |  |   </a-spin> |  | </template> |  |   |  | <script lang="ts" setup> |  |   import { computed, ref } from 'vue'; |  |   import useLoading from '@/hooks/loading'; |  |   import { queryDataChainGrowth, DataChainGrowth } from '@/api/visualization'; |  |   import useChartOption from '@/hooks/chart-option'; |  |   |  |   const props = defineProps({ |  |     title: { |  |       type: String, |  |       default: '', |  |     }, |  |     quota: { |  |       type: String, |  |       default: '', |  |     }, |  |     chartType: { |  |       type: String, |  |       default: '', |  |     }, |  |   }); |  |   const { loading, setLoading } = useLoading(true); |  |   const count = ref(0); |  |   const growth = ref(100); |  |   const isUp = computed(() => growth.value > 50); |  |   const chartData = ref<any>([]); |  |   const { chartOption } = useChartOption(() => { |  |     return { |  |       grid: { |  |         left: 0, |  |         right: 0, |  |         top: 0, |  |         bottom: 0, |  |       }, |  |       xAxis: { |  |         type: 'category', |  |         show: false, |  |       }, |  |       yAxis: { |  |         show: false, |  |       }, |  |       tooltip: { |  |         show: true, |  |         trigger: 'axis', |  |         formatter: '{c}', |  |       }, |  |       series: [ |  |         { |  |           data: chartData.value, |  |           ...(props.chartType === 'bar' |  |             ? { |  |                 type: 'bar', |  |                 barWidth: 7, |  |                 barGap: '0', |  |               } |  |             : { |  |                 type: 'line', |  |                 showSymbol: false, |  |                 smooth: true, |  |                 lineStyle: { |  |                   color: '#4080FF', |  |                 }, |  |               }), |  |         }, |  |       ], |  |     }; |  |   }); |  |   const fetchData = async (params: DataChainGrowth) => { |  |     try { |  |       const { data } = await queryDataChainGrowth(params); |  |       const { chartData: resChartData } = data; |  |       count.value = data.count; |  |       growth.value = data.growth; |  |       resChartData.data.value.forEach((el, idx) => { |  |         if (props.chartType === 'bar') { |  |           chartData.value.push({ |  |             value: el, |  |             itemStyle: { |  |               color: idx % 2 ? '#468DFF' : '#86DF6C', |  |             }, |  |           }); |  |         } else { |  |           chartData.value.push(el); |  |         } |  |       }); |  |     } catch (err) { |  |       // you can report use errorHandler or other |  |     } finally { |  |       setLoading(false); |  |     } |  |   }; |  |   fetchData({ quota: props.quota }); |  | </script> |  |   |  | <style scoped lang="less"> |  |   .general-card { |  |     min-height: 204px; |  |   } |  |   .content { |  |     display: flex; |  |     align-items: center; |  |     width: 100%; |  |     margin-bottom: 12px; |  |   } |  |   .percent-text { |  |     margin-left: 16px; |  |   } |  |   .chart { |  |     width: 100%; |  |     height: 80px; |  |     vertical-align: bottom; |  |   } |  |   |  |   .unit { |  |     padding-left: 8px; |  |     font-size: 12px; |  |   } |  |   |  |   .label { |  |     padding-right: 8px; |  |     font-size: 12px; |  |   } |  | </style> | 
 |