ModulePrimary.vue 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222
  1. <template>
  2. <div class="module-primary" :style="style">
  3. <div v-if="moduleName" class="module-title">
  4. <div class="common-navL" :class="{ 'cursor-pointer': !!moduleData.to }" @click="redirectTo">
  5. <div class="navL-title">
  6. {{ moduleName }}
  7. </div>
  8. <div class="navL-slot" v-if="header.show && header.slot.show">
  9. {{ getFormattedText(selectedDevice, header.slot.value) }}
  10. </div>
  11. </div>
  12. <div class="common-navR">
  13. <!-- 下拉框 -->
  14. <div class="common-navR-select" v-if="header.show && header.selector.show">
  15. <a-select
  16. style="width: 140px"
  17. size="small"
  18. placeholder="请选择"
  19. v-model:value="selectedDeviceID"
  20. :options="options"
  21. @change="selectHandler"
  22. />
  23. </div>
  24. </div>
  25. </div>
  26. <div class="module-content">
  27. <slot>
  28. <Content style="height: 100%" :moduleData="moduleData" :data="selectedDevice" />
  29. </slot>
  30. </div>
  31. </div>
  32. </template>
  33. <script setup lang="ts">
  34. import Content from './content.vue';
  35. import { computed, watch } from 'vue';
  36. import { useInitModule } from './hooks/useInit';
  37. import { getFormattedText } from './hooks/helper';
  38. import { openWindow } from '/@/utils';
  39. // import { ModuleProps } from '../types';
  40. const props = defineProps<{
  41. /** 配置的详细模块信息 */
  42. moduleData: any;
  43. /** 配置的详细样式信息 */
  44. showStyle: any;
  45. /** 该模块配置中的设备标识符 */
  46. deviceType: string;
  47. /** api返回的数据 */
  48. data: any;
  49. moduleName: string;
  50. visible: boolean;
  51. }>();
  52. const emit = defineEmits(['close', 'select']);
  53. const { header } = props.moduleData;
  54. const { selectedDeviceID, selectedDevice, options, init } = useInitModule(props.deviceType, props.moduleData);
  55. const style = computed(() => {
  56. const size = props.showStyle.size;
  57. const position = props.showStyle.position;
  58. return size + position;
  59. });
  60. //下拉框选项切换
  61. function selectHandler(id) {
  62. selectedDeviceID.value = id;
  63. emit('select', selectedDevice);
  64. }
  65. function redirectTo() {
  66. const { to } = props.moduleData;
  67. if (!to) return;
  68. openWindow(to);
  69. }
  70. watch(
  71. () => props.data,
  72. (d) => {
  73. init(d);
  74. if (!selectedDeviceID.value) {
  75. selectedDeviceID.value = options.value[0]?.value;
  76. }
  77. },
  78. {
  79. immediate: true,
  80. }
  81. );
  82. </script>
  83. <style scoped lang="less">
  84. @import '/@/design/theme.less';
  85. .module-primary {
  86. --image-module-title: url('/@/assets/images/sealedGoaf/views/home/module-title.png');
  87. position: absolute;
  88. width: 100%;
  89. height: 100%;
  90. background-repeat: no-repeat;
  91. background-position: center top;
  92. background-size: 100% auto;
  93. z-index: @layout-basic-z-index;
  94. // 不允许点击穿透,防止点击穿透到地图
  95. pointer-events: all;
  96. .module-title {
  97. display: flex;
  98. box-sizing: border-box;
  99. align-items: center;
  100. justify-content: space-between;
  101. width: 100%;
  102. height: 25px;
  103. background: var(--image-module-title) no-repeat;
  104. background-size: cover;
  105. padding-left: 10px;
  106. .common-navL {
  107. display: flex;
  108. color: #234e8e;
  109. font-size: 18px;
  110. margin-top: -15px;
  111. .navL-title {
  112. font-weight: 600;
  113. }
  114. .navL-slot {
  115. padding-left: 20px;
  116. }
  117. }
  118. .common-navR {
  119. margin-top: -15px;
  120. }
  121. .common-navR-select {
  122. :deep(.ant-select) {
  123. .ant-select-selector {
  124. background-color: #2b6ff0;
  125. font-size: 16px;
  126. cursor: pointer;
  127. width: auto;
  128. height: 32px;
  129. }
  130. .ant-select-selection-placeholder {
  131. display: flex;
  132. align-items: center;
  133. color: #fff;
  134. }
  135. .ant-select-selection-search-input {
  136. height: 100%;
  137. }
  138. .ant-select-selection-item {
  139. color: #fff;
  140. }
  141. .ant-select-arrow {
  142. color: #fff;
  143. }
  144. }
  145. }
  146. }
  147. .module-content {
  148. height: calc(100% - 38px);
  149. }
  150. }
  151. // :deep(.ant-select-selector) {
  152. // height: 22px !important;
  153. // border: none !important;
  154. // // background-color: rgb(15 64 88) !important;
  155. // background-color: transparent !important;
  156. // color: #8087a1 !important;
  157. // }
  158. // :deep(.ant-select-selection-placeholder) {
  159. // color: #8087a1 !important;
  160. // }
  161. // :deep(.ant-select-arrow) {
  162. // color: #8087a1 !important;
  163. // }
  164. // :deep(.ant-picker) {
  165. // border: none !important;
  166. // background-color: rgb(15 64 88) !important;
  167. // box-shadow: none;
  168. // color: #a1dff8 !important;
  169. // }
  170. // :deep(.ant-picker-input > input) {
  171. // color: #a1dff8 !important;
  172. // text-align: center !important;
  173. // }
  174. // :deep(.ant-picker-separator) {
  175. // color: #a1dff8 !important;
  176. // }
  177. // :deep(.ant-picker-active-bar) {
  178. // display: none !important;
  179. // }
  180. // :deep(.ant-picker-suffix) {
  181. // color: #a1dff8 !important;
  182. // }
  183. // :deep(.ant-switch) {
  184. // min-width: 48px !important;
  185. // }
  186. // :deep(.ant-switch-checked) {
  187. // background-color: rgb(15 64 89) !important;
  188. // }
  189. // :deep(.ant-switch-handle::before) {
  190. // background-color: rgb(33 179 247) !important;
  191. // }
  192. // :deep(.ant-select-selection-item) {
  193. // color: #fff !important;
  194. // }
  195. </style>