ventSY.vue 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268
  1. <!-- eslint-disable vue/multi-word-component-names -->
  2. <template>
  3. <div class="company-home">
  4. <div style="width: 100%; height: 100%; position: absolute; left: 0; top: 0; z-index: 0">
  5. <SubApp />
  6. </div>
  7. <!-- 如果是有 deviceType、type 等 query,认为是详情页,不需要展示普通模块,只需要模型 -->
  8. <template v-if="!route.query.deviceType">
  9. <div v-if="!route.query.embed" class="top-bg">
  10. <div class="main-title">{{ mainTitle }}</div>
  11. </div>
  12. <!-- 采用定位方式以避免出现各个模块隐藏时其他模块下移的问题 -->
  13. <template v-if="isOriginal">
  14. <ModuleOriginal
  15. v-for="cfg in configs"
  16. :key="cfg.deviceType"
  17. :show-style="cfg.showStyle"
  18. :module-data="cfg.moduleData"
  19. :module-name="cfg.moduleName"
  20. :device-type="cfg.deviceType"
  21. :data="data"
  22. :visible="true"
  23. />
  24. </template>
  25. <template v-else-if="isCommon">
  26. <ModuleCommon
  27. v-for="cfg in configs"
  28. :key="cfg.deviceType"
  29. :show-style="cfg.showStyle"
  30. :module-data="cfg.moduleData"
  31. :module-name="cfg.moduleName"
  32. :device-type="cfg.deviceType"
  33. :data="data"
  34. :visible="true"
  35. />
  36. </template>
  37. <template v-else>
  38. <!-- 下面是正常展示的各新版模块 -->
  39. <ModuleEnhanced
  40. v-for="cfg in enhancedConfigs"
  41. :key="cfg.deviceType"
  42. :visible="cfg.visible"
  43. :show-style="cfg.showStyle"
  44. :module-data="cfg.moduleData"
  45. :module-name="cfg.moduleName"
  46. :device-type="cfg.deviceType"
  47. :data="data"
  48. @close="cfg.visible = false"
  49. />
  50. <!-- 下面是用于呼出已隐藏的模块的按钮 -->
  51. <div class="flex pos-absolute bottom-10px left-60px z-3">
  52. <div v-for="(item, i) in hiddenList" :key="`vvhchg${i}`">
  53. <AButton class="module-trigger-button" @click="item.visible = true">{{ item.moduleName }}</AButton>
  54. </div>
  55. </div>
  56. </template>
  57. <!-- <div
  58. v-if="sysDataType === 'all'"
  59. :class="{ 'realtime-mode': isDataRealTime }"
  60. alt="切换数据模式"
  61. class="switch-button report-mode right-525px"
  62. @click="switchDataMode"
  63. ></div> -->
  64. <div class="switch-button icon-goto right-475px" @click="goMicroApp()"></div>
  65. </template>
  66. </div>
  67. </template>
  68. <script lang="ts" setup>
  69. import { onMounted, onUnmounted, watch } from 'vue';
  70. // import { CaretDownOutlined } from '@ant-design/icons-vue';
  71. import { useInitConfigs, useInitPage } from './hooks/useInit';
  72. import ModuleEnhanced from './components/ModuleEnhanced.vue';
  73. import ModuleOriginal from './components/ModuleOriginal.vue';
  74. import ModuleCommon from './components/ModuleCommon.vue';
  75. // import { useRoute } from 'vue-router';
  76. import SubApp from '/@/components/vent/micro/createSubApp.vue';
  77. import { list } from './configurable.api';
  78. import { useRoute, useRouter } from 'vue-router';
  79. import { useGlobSetting } from '/@/hooks/setting';
  80. // import { testConfigVent, testConfigVentRealtime } from './configurable.data';
  81. const { title = '智能通风管控系统' } = useGlobSetting();
  82. const { configs, isOriginal, isCommon, fetchConfigs } = useInitConfigs();
  83. const { mainTitle, enhancedConfigs, hiddenList, data, updateData, updateEnhancedConfigs } = useInitPage(title);
  84. const route = useRoute();
  85. const router = useRouter();
  86. // const isDataRealTime = ref(sysDataType === 'monitor');
  87. let interval: number | undefined;
  88. // function switchDataMode() {
  89. // isDataRealTime.value = !isDataRealTime.value;
  90. // refresh();
  91. // }
  92. function refresh() {
  93. fetchConfigs('vent').then(() => {
  94. // configs.value = isDataRealTime.value ? testConfigVentRealtime : testConfigVent;
  95. updateEnhancedConfigs(configs.value);
  96. list({}).then(updateData);
  97. });
  98. }
  99. function initInterval() {
  100. // [perf-base-v1] 重复初始化前先清理旧句柄,并将新句柄赋值给 interval,修复定时器泄漏
  101. clearInterval(interval);
  102. interval = setInterval(() => {
  103. list({}).then(updateData);
  104. }, 60000);
  105. }
  106. function goMicroApp() {
  107. router.push({
  108. path: route.path,
  109. query: {
  110. ...route.query,
  111. type: 'model3D',
  112. deviceType: 'model3D',
  113. },
  114. });
  115. }
  116. watch(
  117. () => route.query,
  118. () => {
  119. if (route.query.deviceType) {
  120. // 仅需要展示子应用,模拟 unmounted
  121. clearInterval(interval);
  122. } else {
  123. // 模拟 mounted
  124. refresh();
  125. initInterval();
  126. }
  127. }
  128. );
  129. onMounted(() => {
  130. refresh();
  131. initInterval();
  132. });
  133. onUnmounted(() => {
  134. clearInterval(interval);
  135. });
  136. </script>
  137. <style>
  138. #__qiankun_microapp_wrapper_for_micro_vent_3_d_modal__ #app {
  139. background-color: transparent;
  140. }
  141. </style>
  142. <style lang="less" scoped>
  143. @import '/@/design/theme.less';
  144. @font-face {
  145. font-family: 'douyuFont';
  146. src: url('/@/assets/font/douyuFont.otf');
  147. }
  148. @{theme-deepblue} {
  149. .company-home {
  150. --image-modal-top: url('/@/assets/images/themify/deepblue/vent/home/modal-top.png');
  151. }
  152. }
  153. .company-home {
  154. --image-modal-top: url('/@/assets/images/vent/home/modal-top.png');
  155. --image-monitor-realtime: url('/@/assets/images/company/monitor-realtime.png');
  156. --image-monitor-doc: url('/@/assets/images/company/monitor-doc.png');
  157. --image-monitor-goto: url('/@/assets/images/company/monitor-goto.png');
  158. width: 100%;
  159. height: 100%;
  160. color: @white;
  161. position: relative;
  162. // background: url('@/assets/images/home-container/configurable/firehome/bg.png') no-repeat center;
  163. .top-bg {
  164. width: 100%;
  165. height: 56px;
  166. background: var(--image-modal-top) no-repeat center;
  167. position: absolute;
  168. z-index: 1;
  169. .main-title {
  170. height: 56px;
  171. font-family: 'douyuFont';
  172. font-size: 20px;
  173. letter-spacing: 2px;
  174. display: flex;
  175. justify-content: center;
  176. align-items: center;
  177. }
  178. }
  179. // .module-left {
  180. // position: absolute;
  181. // width: 450px;
  182. // height: 280px;
  183. // left: 0;
  184. // }
  185. // .module-right {
  186. // position: absolute;
  187. // width: 450px;
  188. // height: 280px;
  189. // right: 0;
  190. // }
  191. // .module-bottom {
  192. // position: absolute;
  193. // width: 1000px;
  194. // height: 280px;
  195. // }
  196. .module-dropdown {
  197. padding: 5px;
  198. background-image: @vent-configurable-dropdown;
  199. border-bottom: 2px solid @vent-configurable-home-light-border;
  200. color: @vent-font-color;
  201. position: absolute;
  202. top: 60px;
  203. right: 480px;
  204. }
  205. .module-dropdown-original {
  206. padding: 10px;
  207. background-image: @vent-configurable-dropdown;
  208. border-bottom: 2px solid @vent-configurable-home-light-border;
  209. color: @vent-font-color;
  210. position: absolute;
  211. top: 70px;
  212. right: 460px;
  213. }
  214. .module-trigger-button {
  215. color: @vent-font-color;
  216. background-image: @vent-configurable-dropdown;
  217. border: none;
  218. border-bottom: 2px solid @vent-configurable-home-light-border;
  219. }
  220. .switch-button {
  221. width: 34px;
  222. height: 34px;
  223. position: absolute;
  224. // right: 5px;
  225. bottom: 300px;
  226. z-index: 5;
  227. background-repeat: no-repeat;
  228. background-size: 100% 100%;
  229. }
  230. .report-mode {
  231. background-image: var(--image-monitor-doc);
  232. }
  233. .realtime-mode {
  234. background-image: var(--image-monitor-realtime);
  235. }
  236. .icon-goto {
  237. background-image: var(--image-monitor-goto);
  238. }
  239. .module-monitor-bar {
  240. position: absolute;
  241. top: 100px;
  242. width: 1000px;
  243. height: 200px;
  244. left: calc(50% - 500px);
  245. }
  246. }
  247. :deep(.loading-box) {
  248. position: unset;
  249. }
  250. </style>