ModuleEnhanced.vue 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. <template>
  2. <component :is="getModuleComponent(showStyle.position)" :style="style" :title="moduleName" :visible="visible" @close="$emit('close')">
  3. <slot></slot>
  4. </component>
  5. </template>
  6. <script lang="ts" setup>
  7. import ModuleLeft from './enhanced/moduleLeft.vue';
  8. import ModuleRight from './enhanced/moduleRight.vue';
  9. import ModuleBottom from './enhanced/moduleBottom.vue';
  10. import { computed } from 'vue';
  11. import { ShowStyle } from '../../../deviceManager/configurationTable/types';
  12. const props = defineProps<{
  13. showStyle: ShowStyle;
  14. moduleName: string;
  15. visible: boolean;
  16. }>();
  17. defineEmits(['close']);
  18. const style = computed(() => {
  19. const size = props.showStyle.size;
  20. const position = props.showStyle.position;
  21. return size + position;
  22. });
  23. // 根据配置里的定位判断应该使用哪个module组件
  24. function getModuleComponent(position) {
  25. if (position.includes('左')) {
  26. return ModuleLeft;
  27. }
  28. if (position.includes('右')) {
  29. return ModuleRight;
  30. }
  31. if (position === '中下') {
  32. return ModuleBottom;
  33. }
  34. return ModuleLeft; //
  35. }
  36. </script>