ModuleGasInject.vue 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. <template>
  2. <!-- 红沙泉露天煤矿 -->
  3. <component
  4. :is="getModuleComponent(showStyle)"
  5. :style="style"
  6. :title="moduleName"
  7. :visible="visible"
  8. :visibleDetail="visibleDetail"
  9. :class="{ 'cursor-pointer': !!moduleData.to }"
  10. @close="$emit('close')"
  11. @click="redirectTo"
  12. @handleClickDetail="handleClickDetail"
  13. >
  14. <slot>
  15. <Header :deviceType="deviceType" :moduleData="moduleData" :data="data" @select="selectedData = $event" />
  16. <Content :style="{ height: header.show ? 'calc(100% - 30px)' : '100%' }" :moduleData="moduleData" :data="selectedData" />
  17. <DetailInfo :showDetail="showDetail" :deviceType="deviceType" :data="data" @closeModal="closeModal"></DetailInfo>
  18. </slot>
  19. </component>
  20. </template>
  21. <script lang="ts" setup>
  22. import Header from './header.vue';
  23. import Content from './content.vue';
  24. import ModuleLeft from './gasInject/moduleLeft.vue';
  25. import ModuleRight from './gasInject/moduleRight.vue';
  26. import ModuleBottom from './gasInject/moduleBottom.vue';
  27. import DetailInfo from './gasInject/DetailInfo.vue';
  28. import { computed, ref } from 'vue';
  29. import { openWindow } from '/@/utils';
  30. import { getFormattedText } from '../hooks/helper';
  31. // import { ModuleProps } from '../types';
  32. const props = defineProps<{
  33. /** 配置的详细模块信息 */
  34. moduleData: any;
  35. /** 配置的详细样式信息 */
  36. showStyle: any;
  37. /** 该模块配置中的设备标识符 */
  38. deviceType: string;
  39. /** api返回的数据 */
  40. data: any;
  41. moduleName: string;
  42. visible: boolean;
  43. visibleDetail: boolean;
  44. }>();
  45. defineEmits(['close', 'click']);
  46. const { header } = props.moduleData;
  47. const selectedData = ref();
  48. //是否显示详情信息
  49. const showDetail = ref(false);
  50. const style = computed(() => {
  51. const size = props.showStyle.size;
  52. const position = props.showStyle.position;
  53. return size + position;
  54. });
  55. // 根据配置里的定位判断应该使用哪个module组件
  56. function getModuleComponent({ size, position }) {
  57. const [_, width] = size.match(/width:([0-9]+)px/) || [];
  58. if (position.includes('bottom') || parseInt(width) > 800) {
  59. return ModuleBottom;
  60. }
  61. if (position.includes('left')) {
  62. return ModuleLeft;
  63. }
  64. if (position.includes('right')) {
  65. return ModuleRight;
  66. }
  67. return ModuleBottom;
  68. }
  69. function redirectTo() {
  70. const { to } = props.moduleData;
  71. if (!to) return;
  72. openWindow(getFormattedText(selectedData.value, to));
  73. }
  74. //详情点击
  75. function handleClickDetail() {
  76. showDetail.value = true;
  77. }
  78. //关闭弹窗
  79. function closeModal(param) {
  80. showDetail.value = param;
  81. }
  82. </script>