vent_v5.vue 8.1 KB

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