|
|
@@ -1,10 +1,18 @@
|
|
|
<template>
|
|
|
<div class="bg" style="width: 100%; height: 100%; display: flex; justify-content: center; align-items: center; overflow: hidden">
|
|
|
<a-spin :spinning="loading" />
|
|
|
- <div id="gasPump3D" v-show="activeKey == 'monitor'" style="width: 100%; height: 100%; position: absolute; overflow: hidden"> </div>
|
|
|
+ <!-- 二维 SVG 模型(瓦斯抽采泵站,按泵运行状态点亮管路) -->
|
|
|
+ <component v-if="globalConfig?.is2DModel" ref="modelRef" :is="modelComponent" :device-type="currentDeviceType" style="z-index: 2" />
|
|
|
+ <!-- 三维模型容器(由 index.vue 的 mountedThree 初始化) -->
|
|
|
+ <div v-else id="gasPump3D" v-show="activeKey == 'monitor'" style="width: 100%; height: 100%; position: absolute; overflow: hidden"> </div>
|
|
|
<div
|
|
|
id="gas3DCSS"
|
|
|
- v-show="activeKey == 'monitor' && !loading && (currentDeviceType.startsWith('pump_under') || currentDeviceType == 'pump_n12m2pq')"
|
|
|
+ v-show="
|
|
|
+ !globalConfig?.is2DModel &&
|
|
|
+ activeKey == 'monitor' &&
|
|
|
+ !loading &&
|
|
|
+ (currentDeviceType.startsWith('pump_under') || currentDeviceType == 'pump_n12m2pq')
|
|
|
+ "
|
|
|
style="width: 100%; height: 100%; top: 0; left: 0; position: absolute; overflow: hidden; pointer-events: none"
|
|
|
>
|
|
|
</div>
|
|
|
@@ -59,10 +67,10 @@
|
|
|
|
|
|
<script setup lang="ts">
|
|
|
import customHeader from '/@/components/vent/customHeader.vue';
|
|
|
- import { ref, onMounted, onUnmounted, reactive, toRaw } from 'vue';
|
|
|
+ import { ref, onMounted, onUnmounted, reactive, toRaw, inject, shallowRef, provide } from 'vue';
|
|
|
import { list } from './gasPump.api';
|
|
|
import BottomMenu from '/@/views/vent/comment/components/bottomMenu.vue';
|
|
|
- import { getComponent } from './gasPump.data';
|
|
|
+ import { getComponent, getModelComponent } from './gasPump.data';
|
|
|
import gasPumpHistory from './components/gasPumpHistory.vue';
|
|
|
import gasPumpHandleHistoryVue from './components/gasPumpHandleHistory.vue';
|
|
|
import gasPumpAlarmHistory from './components/gasPumpAlarmHistory.vue';
|
|
|
@@ -75,6 +83,20 @@
|
|
|
const activeKey = ref('monitor');
|
|
|
const loading = ref(false);
|
|
|
|
|
|
+ /** 全局配置(is2DModel 决定二维 / 三维模型) */
|
|
|
+ const globalConfig: any = inject('globalConfig');
|
|
|
+ /** 二维模型容器(三维由 mountedThree 负责,此处仅二维有值) */
|
|
|
+ const modelRef = ref();
|
|
|
+ // 注意:站型 currentDeviceType 在下面才声明,这里先用默认场景,选中站型后由 getSelectRow 刷新
|
|
|
+ const modelComponent = shallowRef(getModelComponent(globalConfig?.is2DModel));
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 二维模型的动画入口,供子组件(gasPumpHome*)在轮询里调用:
|
|
|
+ * 子组件那边就是 animate2D(data) —— 与三维 playAnimate(data) 用同一份监测数据。
|
|
|
+ * 三维模式下 modelRef 为空,这里自然 no-op。
|
|
|
+ */
|
|
|
+ provide('animateGasPump2D', (data: any) => modelRef.value?.animate?.(data));
|
|
|
+
|
|
|
const historyTable = ref();
|
|
|
const alarmHistoryTable = ref();
|
|
|
const handlerHistoryTable = ref();
|
|
|
@@ -98,7 +120,7 @@
|
|
|
});
|
|
|
|
|
|
function changeActive(activeValue) {
|
|
|
- if (activeKey.value == 'monitor') {
|
|
|
+ if (activeKey.value == 'monitor' && !globalConfig?.is2DModel) {
|
|
|
if (currentDeviceType.value == 'pump_over') {
|
|
|
setModelType('gasPump');
|
|
|
} else if (currentDeviceType.value.startsWith('pump_under')) {
|
|
|
@@ -171,18 +193,31 @@
|
|
|
optionValue.value = currentData['deviceID'];
|
|
|
currentDeviceType.value = currentData['deviceType'];
|
|
|
Object.assign(selectData, currentData);
|
|
|
- if (currentDeviceType.value == 'pump_over') {
|
|
|
- setModelType('gasPump');
|
|
|
- } else if (currentDeviceType.value.startsWith('pump_under')) {
|
|
|
- setModelType('gasPumpUnder');
|
|
|
+ if (globalConfig?.is2DModel) {
|
|
|
+ // 二维:换站型时切到对应场景(当前地上/井下共用一套),并立刻刷新一次流动状态
|
|
|
+ // 换站型时切到对应场景(当前地上/井下共用一套),动画由子组件轮询驱动
|
|
|
+ modelComponent.value = getModelComponent(true, currentDeviceType.value);
|
|
|
} else {
|
|
|
- setModelType('gasPumpUnder');
|
|
|
+ if (currentDeviceType.value == 'pump_over') {
|
|
|
+ setModelType('gasPump');
|
|
|
+ } else if (currentDeviceType.value.startsWith('pump_under')) {
|
|
|
+ setModelType('gasPumpUnder');
|
|
|
+ } else {
|
|
|
+ setModelType('gasPumpUnder');
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
onMounted(async () => {
|
|
|
if (currentRoute.value && currentRoute.value['query'] && currentRoute.value['query']['id']) optionValue.value = currentRoute.value['query']['id'];
|
|
|
+ // 二维模式:不初始化三维,只加载数据;动画由子组件(gasPumpHome*)轮询时调 animate2D(data) 驱动
|
|
|
+ if (globalConfig?.is2DModel) {
|
|
|
+ await getSysDataSource();
|
|
|
+ await getDeviceList();
|
|
|
+ getSelectRow(optionValue.value);
|
|
|
+ return;
|
|
|
+ }
|
|
|
mountedThree().then(async () => {
|
|
|
await getSysDataSource();
|
|
|
await getDeviceList();
|
|
|
@@ -191,7 +226,9 @@
|
|
|
});
|
|
|
|
|
|
onUnmounted(() => {
|
|
|
- destroy();
|
|
|
+ if (!globalConfig?.is2DModel) {
|
|
|
+ destroy();
|
|
|
+ }
|
|
|
});
|
|
|
</script>
|
|
|
<style lang="less" scoped>
|