index.vue
2.75 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
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
<!--
* 功能:历史数据
* 作者:曹晓桐
* 日期:2023-11-18
-->
<template>
<div>
<a-row :gutter="10">
<!-- 左侧树 start -->
<a-col :span="4">
<!-- :listStyle="1" -->
<search-tree :title="$t('global.device')" :time="true" @onChange="searchTreeChange" :stationType="StationTypeEnum.pv" />
</a-col>
<!-- 左侧树 end -->
<!-- 右侧内容 start -->
<a-col :span="20">
<a-card class="general-card" :title="$t('power.energy.search.queryData')">
<!-- tab切换 -->
<a-tabs type="rounded" v-model:active-key="tabsActiveKey" @change="handleTabsChange">
<a-tab-pane key="0" :title="$t('pv.preview.generation.analysis')"></a-tab-pane>
<a-tab-pane key="1" :title="$t('pv.preview.generation.analysisDc')"></a-tab-pane>
<a-tab-pane key="2" :title="$t('pv.preview.generation.analysisDcVoltage')"></a-tab-pane>
<!-- <a-tab-pane v-for="(item, index) in pageValues" :key="index" :title="item.title">-->
<!-- </a-tab-pane>-->
</a-tabs>
<a-spin :loading="loading" style="width: 100%;height: auto;" :tip="$t('global.loading')">
<CutomChart :options="chartData" autoresize height="460px"></CutomChart>
</a-spin>
</a-card>
</a-col>
<!-- 右侧内容 end -->
</a-row>
</div>
</template>
<script setup lang="ts">
import { ref } from "vue";
import useLoading from "@/hooks/loading";
import { getChartBySingleDate } from "@/api/system/home-power";
import { handleChartData } from "@/utils/charts";
import { StationTypeEnum } from "@/api/system/device";
//加载中
const { loading, setLoading } = useLoading(false);
//图表数据
const chartData = ref<any>([]);
//tab切换选中值
const tabsActiveKey = ref<number>(0);
//模块
const pageValues = ref<any>([{
title: "交流分析",
value: "photovoltaic-exchange"
}, {
title: "直流电流分析",
value: "photovoltaic-direct-current"
}, {
title: "直流电压分析",
value: "photovoltaic-direct-voltage"
}]);
const searchParams = ref<any>({});
/**
* 搜索树Change
*/
const searchTreeChange = async (val: any) => {
searchParams.value = val;
await fetchChartData();
}
/**
* tab切换
*/
const handleTabsChange = async () => {
await fetchChartData();
}
/**
* 获取图表数据
*/
const fetchChartData = async () => {
setLoading(true);
try {
let param = {
pageValue: pageValues.value[tabsActiveKey.value].value,
...searchParams.value
}
let chartsRes = await getChartBySingleDate(param);
if (chartsRes.code == 200) {
chartData.value = handleChartData(chartsRes.data);
} else {
chartData.value = [];
}
} catch (error) {
} finally {
setLoading(false)
}
}
</script>