<template>
  <component :is="getModuleComponent(showStyle.position)" :style="style" :title="moduleName" :visible="visible" @close="$emit('close')">
    <slot></slot>
  </component>
</template>
<script lang="ts" setup>
  import ModuleLeft from './enhanced/moduleLeft.vue';
  import ModuleRight from './enhanced/moduleRight.vue';
  import ModuleBottom from './enhanced/moduleBottom.vue';
  import { computed } from 'vue';
  import { ShowStyle } from '../../../deviceManager/configurationTable/types';

  const props = defineProps<{
    showStyle: ShowStyle;
    moduleName: string;
    visible: boolean;
  }>();
  defineEmits(['close']);

  const style = computed(() => {
    const size = props.showStyle.size;
    const position = props.showStyle.position;
    return size + position;
  });

  // 根据配置里的定位判断应该使用哪个module组件
  function getModuleComponent(position) {
    if (position.includes('左')) {
      return ModuleLeft;
    }
    if (position.includes('右')) {
      return ModuleRight;
    }
    if (position === '中下') {
      return ModuleBottom;
    }
    return ModuleLeft; //
  }
</script>
