ModuleCommonBelt.vue 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. <template>
  2. <!-- 常用模块 -->
  3. <Transition
  4. :enter-active-class="`animate__animated animate__fadeIn${capitalizedPosition}`"
  5. :leave-active-class="`animate__animated animate__fadeOut${capitalizedPosition}`"
  6. >
  7. <ventBox1 v-if="visible" :class="getModuleClass(showStyle)" :style="style" :pageType="pageType">
  8. <template v-if="moduleName" #title>
  9. <div :class="{ 'cursor-pointer': !!moduleData.to }" style="font-weight: bold; font-style: italic" @click="redirectTo">{{ moduleName }}</div>
  10. </template>
  11. <template #container>
  12. <slot>
  13. <Header :deviceType="deviceType" :moduleData="moduleData" :data="data" @select="selectedData = $event" />
  14. <Content
  15. :style="{ height: header.show ? 'calc(100% - 30px)' : '100%' }"
  16. :moduleData="moduleData"
  17. :data="selectedData"
  18. :chartData="chartData"
  19. />
  20. </slot>
  21. </template>
  22. </ventBox1>
  23. </Transition>
  24. </template>
  25. <script lang="ts" setup>
  26. import Header from './headerBelt.vue';
  27. import Content from './contentBelt.vue';
  28. // import ModuleLeft from './original/moduleLeft.vue';
  29. // import ModuleBottom from './original/moduleBottom.vue';
  30. import { computed, ref } from 'vue';
  31. import ventBox1 from './ventBoxBelt.vue';
  32. import { openWindow } from '/@/utils';
  33. import { getFormattedText } from '../hooks/helper';
  34. // import { ModuleProps } from '../types';
  35. const props = defineProps<{
  36. pageType: string;
  37. /** 配置的详细模块信息 */
  38. moduleData: any;
  39. /** 配置的详细样式信息 */
  40. showStyle: any;
  41. /** 该模块配置中的设备标识符 */
  42. deviceType: string;
  43. /** api返回的数据 */
  44. data: any;
  45. moduleName: string;
  46. visible: boolean;
  47. chartData?: any;
  48. }>();
  49. defineEmits(['close', 'click']);
  50. const { header } = props.moduleData;
  51. const selectedData = ref();
  52. const style = computed(() => {
  53. const size = props.showStyle.size;
  54. const position = props.showStyle.position;
  55. console.log(props.showStyle, '123123');
  56. return size + position + 'position: absolute; pointer-events: auto; z-index: 1';
  57. });
  58. const pageType = computed(() => {
  59. return props.pageType || '';
  60. });
  61. const capitalizedPosition = computed(() => {
  62. return props.showStyle.position.includes('left') ? 'Left' : 'Right';
  63. });
  64. // 根据配置里的定位判断应该使用哪个class
  65. function getModuleClass({ size, position }) {
  66. const [_, width] = size.match(/width:([0-9]+)px/) || [];
  67. if (position.includes('bottom') || parseInt(width) > 800) {
  68. return 'module-common module-common-longer';
  69. }
  70. return 'module-common';
  71. }
  72. function redirectTo() {
  73. const { to } = props.moduleData;
  74. if (!to) return;
  75. openWindow(getFormattedText(selectedData.value, to));
  76. }
  77. </script>
  78. <style lang="less" scoped>
  79. @import '/@/design/theme.less';
  80. .module-common .box1-center {
  81. height: calc(100% - 48px);
  82. }
  83. :deep(.box1-center) {
  84. height: calc(100% - 48px);
  85. }
  86. :deep(.box1-center > .box-container) {
  87. height: 100%;
  88. padding: 0 !important;
  89. width: 100% !important;
  90. }
  91. .module-common-longer {
  92. :deep(.box1-top) {
  93. --image-box1-top: url('/@/assets/images/beltFire/1-1.png');
  94. background-image: url('/@/assets/images/beltFire/1-1.png');
  95. }
  96. :deep(.box1-bottom) {
  97. --image-box1-bottom: url('/@/assets/images/beltFire/1-2.png');
  98. background-image: url('/@/assets/images/beltFire/1-2.png');
  99. }
  100. }
  101. </style>