ModuleCommonDual.vue 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  1. <template>
  2. <ventBox1 :class="getModuleClass(showStyle)" :style="style">
  3. <template #title>
  4. <div class="dual-title">
  5. <div class="title-left">
  6. <div :class="{ deactived: index === 1, 'cursor-pointer': !!moduleDataA.to }" @click="index = 0">{{ moduleNameA }}</div>
  7. <div :class="{ deactived: index === 0, 'cursor-pointer': !!moduleDataB.to }" @click="index = 1">{{ moduleNameB }}</div>
  8. </div>
  9. <div class="title-center">{{ commonTitle }}</div>
  10. </div>
  11. </template>
  12. <template #container>
  13. <slot>
  14. <Header
  15. v-if="index === 0"
  16. :deviceType="deviceTypeA"
  17. :moduleData="moduleDataA"
  18. :data="data"
  19. @select="selectedDataA = $event"
  20. />
  21. <Header
  22. v-if="index === 1"
  23. :deviceType="deviceTypeB"
  24. :moduleData="moduleDataB"
  25. :data="data"
  26. @select="selectedDataB = $event"
  27. />
  28. <Content
  29. v-if="index === 0"
  30. :style="{ height: moduleDataA.header?.show ? 'calc(100% - 30px)' : '100%' }"
  31. :moduleData="moduleDataA"
  32. :data="selectedDataA"
  33. />
  34. <Content
  35. v-if="index === 1"
  36. :style="{ height: moduleDataB.header?.show ? 'calc(100% - 30px)' : '100%' }"
  37. :moduleData="moduleDataB"
  38. :data="selectedDataB"
  39. />
  40. </slot>
  41. </template>
  42. </ventBox1>
  43. </template>
  44. <script lang="ts" setup>
  45. import Header from './header.vue';
  46. import Content from './content.vue';
  47. import { computed, ref } from 'vue';
  48. import ventBox1 from '/@/components/vent/ventBox1.vue';
  49. import { openWindow } from '/@/utils';
  50. import { getFormattedText } from '../hooks/helper';
  51. const props = defineProps<{
  52. moduleDataA: any;
  53. moduleNameA: string;
  54. deviceTypeA: string;
  55. moduleDataB: any;
  56. moduleNameB: string;
  57. deviceTypeB: string;
  58. showStyle: any;
  59. visible: boolean;
  60. data: any;
  61. commonTitle: string;
  62. }>();
  63. defineEmits(['close', 'click']);
  64. const index = ref(0);
  65. const selectedDataA = ref();
  66. const selectedDataB = ref();
  67. const style = computed(() => {
  68. const size = props.showStyle.size;
  69. const position = props.showStyle.position;
  70. return size + position + ';position: absolute; pointer-events: auto;';
  71. });
  72. // 根据配置里的定位判断应该使用哪个class
  73. function getModuleClass({ size, position }) {
  74. const [_, width] = size.match(/width:([0-9]+)px/) || [];
  75. if (position.includes('bottom') || parseInt(width) > 800) {
  76. return 'module-common-dual module-common-dual-longer';
  77. }
  78. return 'module-common-dual';
  79. }
  80. // 跳转
  81. function redirectToA() {
  82. const { to } = props.moduleDataA;
  83. if (!to) return;
  84. openWindow(getFormattedText(selectedDataA.value, to));
  85. }
  86. function redirectToB() {
  87. const { to } = props.moduleDataB;
  88. if (!to) return;
  89. openWindow(getFormattedText(selectedDataB.value, to));
  90. }
  91. </script>
  92. <style lang="less" scoped>
  93. @import '/@/design/theme.less';
  94. .module-common-dual .box1-center {
  95. height: calc(100% - 48px);
  96. }
  97. :deep(.box1-center) {
  98. height: calc(100% - 48px);
  99. }
  100. :deep(.box1-center > .box-container) {
  101. height: 100%;
  102. padding: 0 !important;
  103. width: 100% !important;
  104. }
  105. .dual-title {
  106. position: relative;
  107. width: 100%;
  108. height: 100%;
  109. align-items: center;
  110. display: flex;
  111. font-size: 14px;
  112. .title-center {
  113. position: absolute;
  114. left: 50%;
  115. transform: translateX(-50%);
  116. }
  117. .title-left {
  118. height: 100%;
  119. margin-left: 30px;
  120. display: flex;
  121. div {
  122. display: flex;
  123. align-items: center;
  124. height: 100%;
  125. cursor: pointer;
  126. padding: 0 12px;
  127. background: linear-gradient(to top, #2bafc6 0%, rgba(44, 255, 221, 0.1) 50%,rgba(44, 255, 221, 0) 90%);
  128. }
  129. }
  130. .deactived {
  131. background: none !important;
  132. color: #8087a1;
  133. }
  134. }
  135. // @{theme-deepblue} {
  136. // .module-common-dual-longer {
  137. // :deep(.box1-top) {
  138. // --image-box1-top: url('/@/assets/images/themify/deepblue/vent/border/box2-top-long.png');
  139. // }
  140. // :deep(.box1-bottom) {
  141. // --image-box1-bottom: none;
  142. // }
  143. // }
  144. // }
  145. .module-common-dual-longer {
  146. :deep(.box1-top) {
  147. --image-box1-top: url('/@/assets/images/vent/box-top-bg.png');
  148. background-image: var(--image-box1-top);
  149. }
  150. :deep(.box1-bottom) {
  151. --image-box1-bottom: url('/@/assets/images/vent/box-bottom-bg.png');
  152. background-image: var(--image-box1-bottom);
  153. }
  154. }
  155. </style>