| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061 |
- <template>
- <!-- 新版模块 -->
- <component
- :is="getModuleComponent(showStyle.position)"
- :style="style"
- :title="moduleName"
- :visible="visible"
- @close="$emit('close')"
- @click="redirectTo"
- >
- <slot>
- <Header :deviceType="deviceType" :moduleData="moduleData" @select="selectedData = $event" />
- <Content :style="{ height: header.show ? 'calc(100% - 30px)' : '100%' }" :moduleData="moduleData" :data="selectedData" />
- </slot>
- </component>
- </template>
- <script lang="ts" setup>
- import Header from './header.vue';
- import Content from './content.vue';
- import ModuleLeft from './enhanced/moduleLeft.vue';
- import ModuleRight from './enhanced/moduleRight.vue';
- import ModuleBottom from './enhanced/moduleBottom.vue';
- import { computed, ref } from 'vue';
- import { ShowStyle, ModuleData } from '../../../deviceManager/configurationTable/types';
- import { openWindow } from '/@/utils';
- const props = defineProps<{
- moduleData: ModuleData;
- showStyle: ShowStyle;
- moduleName: string;
- deviceType: string;
- visible: boolean;
- }>();
- defineEmits(['close', 'click']);
- const { header } = props.moduleData;
- const selectedData = ref();
- const style = computed(() => {
- const size = props.showStyle.size;
- const position = props.showStyle.position;
- return size + position;
- });
- // 根据配置里的定位判断应该使用哪个module组件
- function getModuleComponent(position) {
- if (position.includes('left:0')) {
- return ModuleLeft;
- }
- if (position.includes('right:0')) {
- return ModuleRight;
- }
- return ModuleBottom;
- }
- function redirectTo() {
- const { to } = props.moduleData;
- if (!to) return;
- openWindow(to);
- }
- </script>
|