ModuleOriginal.vue 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. <template>
  2. <!-- 原版模块 -->
  3. <component
  4. :is="getModuleComponent(showStyle.position)"
  5. :style="style"
  6. :title="moduleName"
  7. :visible="visible"
  8. :class="{ 'cursor-pointer': !!moduleData.to }"
  9. @close="$emit('close')"
  10. @click="redirectTo"
  11. >
  12. <slot>
  13. <Header :deviceType="deviceType" :moduleData="moduleData" :data="data" @select="selectedData = $event" />
  14. <Content :style="{ height: header.show ? 'calc(100% - 30px)' : '100%' }" :moduleData="moduleData" :data="selectedData" />
  15. </slot>
  16. </component>
  17. </template>
  18. <script lang="ts" setup>
  19. import Header from './header.vue';
  20. import Content from './content.vue';
  21. import ModuleLeft from './original/moduleLeft.vue';
  22. import ModuleBottom from './original/moduleBottom.vue';
  23. import { computed, ref } from 'vue';
  24. import { openWindow } from '/@/utils';
  25. // import { ModuleProps } from '../types';
  26. const props = defineProps<{
  27. /** 配置的详细模块信息 */
  28. moduleData: any;
  29. /** 配置的详细样式信息 */
  30. showStyle: any;
  31. /** 该模块配置中的设备标识符 */
  32. deviceType: string;
  33. /** api返回的数据 */
  34. data: any;
  35. moduleName: string;
  36. visible: boolean;
  37. }>();
  38. defineEmits(['close', 'click']);
  39. const { header } = props.moduleData;
  40. const selectedData = ref();
  41. const style = computed(() => {
  42. const size = props.showStyle.size;
  43. const position = props.showStyle.position;
  44. return size + position;
  45. });
  46. // 根据配置里的定位判断应该使用哪个module组件
  47. function getModuleComponent(position) {
  48. if (position.includes('bottom')) {
  49. return ModuleBottom;
  50. }
  51. if (position.includes('left')) {
  52. return ModuleLeft;
  53. }
  54. if (position.includes('right')) {
  55. return ModuleLeft;
  56. }
  57. return ModuleBottom;
  58. }
  59. function redirectTo() {
  60. const { to } = props.moduleData;
  61. if (!to) return;
  62. openWindow(to);
  63. }
  64. </script>