|
@@ -1,29 +1,68 @@
|
|
|
<script setup lang="ts">
|
|
|
-import { ref } from 'vue';
|
|
|
+import { computed, onMounted, ref, watch } from 'vue';
|
|
|
import { useRoute, useRouter } from 'vue-router';
|
|
|
|
|
|
-import { aiSmartCtrlRoutes } from '@/router';
|
|
|
+import DeviceWorkStatus from '@/views/device-work-status/DeviceWorkStatus.vue';
|
|
|
+import RealTimeMonitor from '@/views/real-time-monitor/RealTimeMonitor.vue';
|
|
|
+import { useRefreshView } from '@/hooks/refresh-view';
|
|
|
import { translateNavigation } from '@/utils';
|
|
|
|
|
|
+import type { Component } from 'vue';
|
|
|
+
|
|
|
+interface TabComponent {
|
|
|
+ name: string;
|
|
|
+ component: Component;
|
|
|
+}
|
|
|
+
|
|
|
const router = useRouter();
|
|
|
const route = useRoute();
|
|
|
-const activeKey = ref(route.name as string);
|
|
|
+const { renderView, refreshView } = useRefreshView();
|
|
|
+const activeKey = ref('');
|
|
|
+
|
|
|
+const deviceGroupId = computed(() => {
|
|
|
+ return route.params.id as string;
|
|
|
+});
|
|
|
+
|
|
|
+const aiSmartCtrlTabs: TabComponent[] = [
|
|
|
+ {
|
|
|
+ name: 'realTimeMonitor',
|
|
|
+ component: RealTimeMonitor,
|
|
|
+ },
|
|
|
+ {
|
|
|
+ name: 'deviceWorkStatus',
|
|
|
+ component: DeviceWorkStatus,
|
|
|
+ },
|
|
|
+];
|
|
|
+
|
|
|
+watch(deviceGroupId, () => {
|
|
|
+ refreshView();
|
|
|
+});
|
|
|
+
|
|
|
+onMounted(() => {
|
|
|
+ activeKey.value = (route.query.tab as string) ?? aiSmartCtrlTabs[0].name;
|
|
|
+ refreshView();
|
|
|
+});
|
|
|
|
|
|
const handleTabClick = (activeKey: string | number) => {
|
|
|
- router.push({
|
|
|
- name: activeKey as string,
|
|
|
+ router.replace({
|
|
|
+ path: route.path,
|
|
|
+ query: {
|
|
|
+ ...route.query,
|
|
|
+ tab: activeKey,
|
|
|
+ },
|
|
|
});
|
|
|
+
|
|
|
+ refreshView();
|
|
|
};
|
|
|
</script>
|
|
|
|
|
|
<template>
|
|
|
<div>
|
|
|
- <div>
|
|
|
- <ATabs class="device-group-tab" v-model:active-key="activeKey" @tab-click="handleTabClick">
|
|
|
- <ATabPane v-for="item in aiSmartCtrlRoutes" :key="item.name" :tab="translateNavigation(item.meta?.title)" />
|
|
|
- </ATabs>
|
|
|
- </div>
|
|
|
- <RouterView />
|
|
|
+ <ATabs class="device-group-tab" v-model:active-key="activeKey" @tab-click="handleTabClick">
|
|
|
+ <ATabPane v-for="item in aiSmartCtrlTabs" :key="item.name" :tab="translateNavigation(item.name)">
|
|
|
+ <component v-if="renderView" :is="item.component" :device-group-id="Number(deviceGroupId)" />
|
|
|
+ </ATabPane>
|
|
|
+ </ATabs>
|
|
|
</div>
|
|
|
</template>
|
|
|
|