ModuleOriginal.vue 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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 './original/moduleLeft.vue';
  21. import ModuleBottom from './original/moduleBottom.vue';
  22. import { computed, ref } from 'vue';
  23. import { ShowStyle, ModuleData } from '../../../deviceManager/configurationTable/types';
  24. import { openWindow } from '/@/utils';
  25. const props = defineProps<{
  26. moduleData: ModuleData;
  27. showStyle: ShowStyle;
  28. moduleName: string;
  29. deviceType: string;
  30. visible: boolean;
  31. }>();
  32. defineEmits(['close', 'click']);
  33. const { header } = props.moduleData;
  34. const selectedData = ref();
  35. const style = computed(() => {
  36. const size = props.showStyle.size;
  37. const position = props.showStyle.position;
  38. return size + position;
  39. });
  40. // 根据配置里的定位判断应该使用哪个module组件
  41. function getModuleComponent(position) {
  42. if (position.includes('left:0')) {
  43. return ModuleLeft;
  44. }
  45. if (position.includes('right:0')) {
  46. return ModuleLeft;
  47. }
  48. return ModuleBottom;
  49. }
  50. function redirectTo() {
  51. const { to } = props.moduleData;
  52. if (!to) return;
  53. openWindow(to);
  54. }
  55. </script>