| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081 |
- <template>
- <!-- 注气驱替 -->
- <component :is="getModuleComponent(showStyle)" :style="style" :title="moduleName" :visible="visible"
- :visibleDetail="visibleDetail" :class="{ 'cursor-pointer': !!moduleData.to }" @close="$emit('close')"
- @click="redirectTo" @handleClickDetail="handleClickDetail">
- <slot>
- <Header :deviceType="deviceType" :moduleData="moduleData" :data="data" @select="selectedData = $event" />
- <Content :style="{ height: header.show ? 'calc(100% - 30px)' : '100%' }" :moduleData="moduleData"
- :data="selectedData" />
- <DetailInfo v-if="showDetail" :deviceType="deviceType" @closeModal="closeModal"></DetailInfo>
- </slot>
- </component>
- </template>
- <script lang="ts" setup>
- import Header from './header.vue';
- import Content from './content.vue';
- import ModuleLeft from './gasInject/moduleLeft.vue';
- import ModuleRight from './gasInject/moduleRight.vue';
- import ModuleBottom from './gasInject/moduleBottom.vue';
- import DetailInfo from './gasInject/DetailInfo.vue'
- import { computed, ref } from 'vue';
- import { openWindow } from '/@/utils';
- import { getFormattedText } from '../hooks/helper';
- // import { ModuleProps } from '../types';
- const props = defineProps<{
- /** 配置的详细模块信息 */
- moduleData: any;
- /** 配置的详细样式信息 */
- showStyle: any;
- /** 该模块配置中的设备标识符 */
- deviceType: string;
- /** api返回的数据 */
- data: any;
- moduleName: string;
- visible: boolean;
- visibleDetail: boolean
- }>();
- defineEmits(['close', 'click']);
- const { header } = props.moduleData;
- const selectedData = ref();
- //是否显示详情信息
- const showDetail = ref(false)
- 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 ModuleRight;
- }
- return ModuleBottom;
- }
- function redirectTo() {
- const { to } = props.moduleData;
- if (!to) return;
- openWindow(getFormattedText(selectedData.value, to));
- }
- //详情点击
- function handleClickDetail() {
- showDetail.value = true
- }
- //关闭弹窗
- function closeModal(param) {
- showDetail.value = param
- }
- </script>
|