ModuleCommonDual.vue 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  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 === 0, 'cursor-pointer': !!moduleDataA.to }" @click="index = 0">{{ moduleNameA }}</div>
  7. <div :class="{ deactived: index === 1, 'cursor-pointer': !!moduleDataB.to }" @click="index = 1">{{ moduleNameB }}</div>
  8. <div :class="{ deactived: index === 2, 'cursor-pointer': !!moduleDataC.to }" @click="index = 2">{{ moduleNameC }}</div>
  9. </div>
  10. <div class="title-center">{{ commonTitle }}</div>
  11. </div>
  12. </template>
  13. <template #container>
  14. <slot>
  15. <Header v-if="index === 0" :deviceType="deviceTypeA" :moduleData="moduleDataA" :data="data" @select="selectedDataA = $event" />
  16. <Header v-if="index === 1" :deviceType="deviceTypeB" :moduleData="moduleDataB" :data="data" @select="selectedDataB = $event" />
  17. <Header v-if="index === 2" :deviceType="deviceTypeC" :moduleData="moduleDataC" :data="data" @select="selectedDataC = $event" />
  18. <Content
  19. v-if="index === 0"
  20. :style="{ height: moduleDataA.header?.show ? 'calc(100% - 30px)' : '100%' }"
  21. :moduleData="moduleDataA"
  22. :data="selectedDataA"
  23. />
  24. <Content
  25. v-if="index === 1"
  26. :style="{ height: moduleDataB.header?.show ? 'calc(100% - 30px)' : '100%' }"
  27. :moduleData="moduleDataB"
  28. :data="selectedDataB"
  29. />
  30. <Content
  31. v-if="index === 2"
  32. :style="{ height: moduleDataC.header?.show ? 'calc(100% - 30px)' : '100%' }"
  33. :moduleData="moduleDataC"
  34. :data="selectedDataC"
  35. />
  36. </slot>
  37. </template>
  38. </ventBox1>
  39. </template>
  40. <script lang="ts" setup>
  41. import Header from './header.vue';
  42. import Content from './content.vue';
  43. import { computed, ref } from 'vue';
  44. import ventBox1 from '/@/components/vent/ventBox1.vue';
  45. import { openWindow } from '/@/utils';
  46. import { getFormattedText } from '../hooks/helper';
  47. const props = defineProps<{
  48. moduleDataA: any;
  49. moduleNameA: string;
  50. deviceTypeA: string;
  51. moduleDataB: any;
  52. moduleNameB: string;
  53. deviceTypeB: string;
  54. moduleDataC: any;
  55. moduleNameC: string;
  56. deviceTypeC: string;
  57. showStyle: any;
  58. visible: boolean;
  59. data: any;
  60. commonTitle: string;
  61. }>();
  62. defineEmits(['close', 'click']);
  63. const index = ref(0);
  64. const selectedDataA = ref();
  65. const selectedDataB = ref();
  66. const selectedDataC = 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; z-index: 1';
  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. function redirectToC() {
  92. const { to } = props.moduleDataC;
  93. if (!to) return;
  94. openWindow(getFormattedText(selectedDataC.value, to));
  95. }
  96. </script>
  97. <style lang="less" scoped>
  98. @import '/@/design/theme.less';
  99. .module-common-dual .box1-center {
  100. height: calc(100% - 48px);
  101. }
  102. :deep(.box1-center) {
  103. height: calc(100% - 48px);
  104. }
  105. :deep(.box1-center > .box-container) {
  106. height: 100%;
  107. padding: 0 !important;
  108. width: 100% !important;
  109. }
  110. .dual-title {
  111. position: relative;
  112. width: 100%;
  113. height: 100%;
  114. align-items: center;
  115. display: flex;
  116. font-size: 14px;
  117. .title-center {
  118. position: absolute;
  119. left: 50%;
  120. transform: translateX(-50%);
  121. }
  122. .title-left {
  123. height: 100%;
  124. margin-left: 30px;
  125. display: flex;
  126. div {
  127. display: flex;
  128. align-items: center;
  129. height: 100%;
  130. cursor: pointer;
  131. padding: 0 12px;
  132. color: #8087a1;
  133. }
  134. }
  135. .deactived {
  136. color: #fff !important;
  137. background: linear-gradient(to top, #2bafc6 0%, rgba(44, 255, 221, 0.1) 50%, rgba(44, 255, 221, 0) 90%);
  138. }
  139. }
  140. // @{theme-deepblue} {
  141. // .module-common-dual-longer {
  142. // :deep(.box1-top) {
  143. // --image-box1-top: url('/@/assets/images/themify/deepblue/vent/border/box2-top-long.png');
  144. // }
  145. // :deep(.box1-bottom) {
  146. // --image-box1-bottom: none;
  147. // }
  148. // }
  149. // }
  150. .module-common-dual-longer {
  151. :deep(.box1-top) {
  152. --image-box1-top: url('/@/assets/images/vent/box-top-bg.png');
  153. background-image: var(--image-box1-top);
  154. }
  155. :deep(.box1-bottom) {
  156. --image-box1-bottom: url('/@/assets/images/vent/box-bottom-bg.png');
  157. background-image: var(--image-box1-bottom);
  158. }
  159. }
  160. </style>