index.vue
2.71 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
104
105
106
107
108
<template>
<a-spin :loading="loading" :tip="$t('global.loading')">
<a-card :body-style="{height: '100%'}">
<a-tabs ref="iframeRef" justify>
<template #extra>
<a-space>
<a-button type="primary" @click="handleListConfig">配置</a-button>
<a-button type="primary" @click="toggle" style="margin-right: 20px;">进入/退出全屏</a-button>
</a-space>
</template>
<a-tab-pane v-for="item in renderData" :key="item.id"
:title="item.projectName">
<iframe class="ykite-iframe" :src="`${YKITE_DIAGRA}/diagram/preview/${item.id}/${token}`"></iframe>
</a-tab-pane>
</a-tabs>
</a-card>
</a-spin>
</template>
<script setup lang="ts">
import {onMounted, ref} from "vue";
import {useRouter} from 'vue-router';
import {useFullscreen} from '@vueuse/core'
import useLoading from "@/hooks/loading";
import {listWebtopoProject} from "@/api/system/webtopo";
import {StationTypeEnum} from "@/api/system/device";
import {getToken} from "@/utils/auth";
const token = getToken();
//路由
const router = useRouter();
const props = withDefaults(defineProps<{
stationType: number
}>(), {
stationType: StationTypeEnum.power
})
/*************************** 变量区域 begin ***************************/
const iframeRef = ref<HTMLElement | null>(null);
// 全屏 or 非全屏
const {toggle} = useFullscreen(iframeRef);
const YKITE_DIAGRA = import.meta.env.VITE_YKITE_DIAGRA_URL;
const {loading, setLoading} = useLoading(false);
// tabsList
const renderData = ref<any[]>([]);
/*************************** 变量区域 end ***************************/
/*************************** 方法区域 begin ***************************/
/**
* 获取tabs数据
*/
const fetchData = async () => {
try {
setLoading(true);
const params = {
pageSize: 1000,
pageNum: 1,
stationType: props.stationType
}
const res: any = await listWebtopoProject(params);
if (res.code == 200) renderData.value = res.rows;
} finally {
setLoading(false);
}
}
// 跳转配置
const handleListConfig = () => {
const routes = {
1: "/power/energy/search/diagram/list",
2: "/pv/generation/diagram/list"
};
const path = routes[props.stationType as 1 | 2];
console.log(path)
if (path) {
router.push({path});
}
};
/*************************** 方法区域 end ***************************/
onMounted(async () => {
await fetchData();
})
</script>
<style lang="less" scoped>
.arco-spin {
width: 100%;
height: 100%;
.arco-card {
height: 100%;
}
}
:deep(.arco-card-body) {
padding-top: 0;
.arco-tabs-nav-tab{
margin-top: 8px;
}
}
.ykite-iframe {
width: 100%;
height: 100%;
border: none;
}
</style>