123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869 |
- <template>
- <!-- 原版模块 -->
- <component
- :is="getModuleComponent(showStyle)"
- :style="style"
- :title="moduleName"
- :visible="visible"
- :class="{ 'cursor-pointer': !!moduleData.to }"
- @close="$emit('close')"
- @click="redirectTo"
- >
- <slot>
- <Header :deviceType="deviceType" :moduleData="moduleData" :data="data" @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 './original/moduleLeft.vue';
- import ModuleBottom from './original/moduleBottom.vue';
- import { computed, ref } from 'vue';
- import { openWindow } from '/@/utils';
- // import { ModuleProps } from '../types';
- const props = defineProps<{
- /** 配置的详细模块信息 */
- moduleData: any;
- /** 配置的详细样式信息 */
- showStyle: any;
- /** 该模块配置中的设备标识符 */
- deviceType: string;
- /** api返回的数据 */
- data: any;
- moduleName: 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({ size, position }) {
- const [_, width] = size.match(/width:([0-9]+)px/) || [];
- if (position.includes('bottom') || parseInt(width) > 800) {
- return ModuleBottom;
- }
- if (position.includes('left')) {
- return ModuleLeft;
- }
- if (position.includes('right')) {
- return ModuleLeft;
- }
- return ModuleBottom;
- }
- function redirectTo() {
- const { to } = props.moduleData;
- if (!to) return;
- openWindow(to);
- }
- </script>
|