card-six.vue
1.89 KB
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
<template>
<a-card :title="$t('pv.preview.inverter')" class="home-statistics-box">
<template #extra>
<time-bar @change="timeChange" />
</template>
<a-spin :loading="loading" style="width: 100%" :tip="$t('global.loading')">
<div class="chart-box">
<CutomChart :options="chartData" />
</div>
</a-spin>
</a-card>
</template>
<script setup lang="ts">
import { PowerModuleEunm, getChart } from "@/api/system/home-power";
import useLoading from "@/hooks/loading";
import { handleChartData } from "@/utils/charts";
import { onMounted, ref } from "vue";
//加载中
const { loading, setLoading } = useLoading(false);
//图表数据
const chartData = ref<any>({});
/**
* 时间改变
*/
const timeChange = async (options: any) => {
console.log("options", options)
if (options.timeUnit == 0) {
await fetchData({ pageValue: PowerModuleEunm.pv_power_inverter_day, "dayTime": options.timer });
} else if (options.timeUnit == 1) {
await fetchData({ pageValue: PowerModuleEunm.pv_power_inverter_month, "monthTime": options.timer });
} else {
await fetchData({ pageValue: PowerModuleEunm.pv_power_inverter_year, "yearTime": options.timer });
}
}
/**
* 获取逆变器数据
* @param param 时间参数
*/
const fetchData = async (param: any) => {
setLoading(true);
try {
let res = await getChart(param);
if (res.code == 200) {
chartData.value = handleChartData(res.data);
console.log("逆变器统计", param.pageValue, chartData.value)
}
} catch (ex) {
console.error("逆变器统计出错", ex)
} finally {
setLoading(false);
}
}
</script>
<style scoped lang="less">
:deep(.arco-statistic) {
.arco-statistic-title {
margin-bottom: 0px;
font-size: 14px;
font-weight: bold;
white-space: nowrap;
}
.arco-statistic-content {
margin-top: 0px;
}
}
.chart-box {
margin-top: 15px;
height: 400px;
}
</style>