ModuleEnhanced.vue 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. <template>
  2. <!-- 新版模块 -->
  3. <component
  4. :is="getModuleComponent(showStyle.position)"
  5. :style="style"
  6. :title="moduleName"
  7. :visible="visible"
  8. @close="$emit('close')"
  9. @click="redirectTo"
  10. >
  11. <slot>
  12. <Header :deviceType="deviceType" :moduleData="moduleData" @select="selectedData = $event" />
  13. <Content :style="{ height: header.show ? 'calc(100% - 30px)' : '100%' }" :moduleData="moduleData" :data="selectedData" />
  14. </slot>
  15. </component>
  16. </template>
  17. <script lang="ts" setup>
  18. import Header from './header.vue';
  19. import Content from './content.vue';
  20. import ModuleLeft from './enhanced/moduleLeft.vue';
  21. import ModuleRight from './enhanced/moduleRight.vue';
  22. import ModuleBottom from './enhanced/moduleBottom.vue';
  23. import { computed, ref } from 'vue';
  24. import { ShowStyle, ModuleData } from '../../../deviceManager/configurationTable/types';
  25. import { openWindow } from '/@/utils';
  26. const props = defineProps<{
  27. moduleData: ModuleData;
  28. showStyle: ShowStyle;
  29. moduleName: string;
  30. deviceType: string;
  31. visible: boolean;
  32. }>();
  33. defineEmits(['close', 'click']);
  34. const { header } = props.moduleData;
  35. const selectedData = ref();
  36. const style = computed(() => {
  37. const size = props.showStyle.size;
  38. const position = props.showStyle.position;
  39. return size + position;
  40. });
  41. // 根据配置里的定位判断应该使用哪个module组件
  42. function getModuleComponent(position) {
  43. if (position.includes('left:0')) {
  44. return ModuleLeft;
  45. }
  46. if (position.includes('right:0')) {
  47. return ModuleRight;
  48. }
  49. return ModuleBottom;
  50. }
  51. function redirectTo() {
  52. const { to } = props.moduleData;
  53. if (!to) return;
  54. openWindow(to);
  55. }
  56. </script>