power-generation.vue
1.53 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
<template>
<a-spin :loading="loading" style="width: 100%">
<a-card :bordered="false" :style="cardStyle">
<a-statistic style="margin-left: 10px;" :title="pageTitle" :value="renderData" :value-from="0" animation :precision="2">
<template #suffix>{{ suffix }}</template></a-statistic>
</a-card>
</a-spin>
</template>
<script lang="ts" setup>
import { ref, PropType, CSSProperties } from 'vue';
import useLoading from '@/hooks/loading';
import { onMounted } from 'vue';
import { getChart } from '@/api/system/home-power';
const renderData = ref<any>(0);
const { loading, setLoading } = useLoading(false);
const props = defineProps({
pageTitle: {
type: String,
default: '',
},
pageValue: {
type: String,
default: '',
},
suffix: {
type: String,
default: '',
},
cardStyle: {
type: Object as PropType<CSSProperties>,
default: () => {
return {};
},
},
});
/**
* 获取日期数据
* @param param 时间参数
*/
const fetchData = async () => {
if (!props.pageValue) {
return
}
setLoading(true);
try {
let res = await getChart({ pageValue: props.pageValue });
if (res.code == 200 && res.data.yAxis && res.data.yAxis.length == 1 && res.data.yAxis[0].dataList && res.data.yAxis[0].dataList.length) {
renderData.value = res.data.yAxis[0].dataList[0];
}
} catch (ex) {
console.error("有功功率监控出错", ex)
} finally {
setLoading(false);
}
}
onMounted(async () => {
await fetchData();
})
</script>
<style scoped lang="less">
</style>