ventV5.vue 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276
  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="barData" />
  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 { computed, 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. const barData = computed(() => ({
  99. ...data.value,
  100. totallength: 223196,
  101. }));
  102. let interval: number | undefined;
  103. function switchDataMode() {
  104. isDataRealTime.value = !isDataRealTime.value;
  105. refresh();
  106. }
  107. function refresh() {
  108. fetchConfigs(isDataRealTime.value ? 'vent_realtime' : 'vent').then(() => {
  109. // configs.value = isDataRealTime.value ? testConfigVentRealtime : testConfigVent;
  110. updateEnhancedConfigs(configs.value);
  111. list({}).then(updateData);
  112. });
  113. }
  114. function initInterval() {
  115. setInterval(() => {
  116. list({}).then(updateData);
  117. }, 60000);
  118. }
  119. function goMicroApp() {
  120. router.push({
  121. path: route.path,
  122. query: {
  123. ...route.query,
  124. type: 'model3D',
  125. deviceType: 'model3D',
  126. },
  127. });
  128. }
  129. watch(
  130. () => route.query,
  131. () => {
  132. if (route.query.deviceType) {
  133. // 仅需要展示子应用,模拟 unmounted
  134. clearInterval(interval);
  135. } else {
  136. // 模拟 mounted
  137. refresh();
  138. initInterval();
  139. }
  140. }
  141. );
  142. onMounted(() => {
  143. refresh();
  144. initInterval();
  145. });
  146. onUnmounted(() => {
  147. clearInterval(interval);
  148. });
  149. </script>
  150. <style lang="less" scoped>
  151. @import '/@/design/theme.less';
  152. @font-face {
  153. font-family: 'douyuFont';
  154. src: url('/@/assets/font/douyuFont.otf');
  155. }
  156. @{theme-deepblue} {
  157. .company-home {
  158. --image-modal-top: url('/@/assets/images/themify/deepblue/vent/home/modal-top.png');
  159. }
  160. }
  161. .company-home {
  162. --image-modal-top: url('/@/assets/images/vent/home/modal-top.png');
  163. --image-monitor-realtime: url('/@/assets/images/company/monitor-realtime.png');
  164. --image-monitor-doc: url('/@/assets/images/company/monitor-doc.png');
  165. --image-monitor-goto: url('/@/assets/images/company/monitor-goto.png');
  166. width: 100%;
  167. height: 100%;
  168. color: @white;
  169. position: relative;
  170. // background: url('@/assets/images/home-container/configurable/firehome/bg.png') no-repeat center;
  171. .top-bg {
  172. width: 100%;
  173. height: 56px;
  174. background: var(--image-modal-top) no-repeat center;
  175. position: absolute;
  176. z-index: 1;
  177. .main-title {
  178. height: 56px;
  179. font-family: 'douyuFont';
  180. font-size: 20px;
  181. letter-spacing: 2px;
  182. display: flex;
  183. justify-content: center;
  184. align-items: center;
  185. }
  186. }
  187. // .module-left {
  188. // position: absolute;
  189. // width: 450px;
  190. // height: 280px;
  191. // left: 0;
  192. // }
  193. // .module-right {
  194. // position: absolute;
  195. // width: 450px;
  196. // height: 280px;
  197. // right: 0;
  198. // }
  199. // .module-bottom {
  200. // position: absolute;
  201. // width: 1000px;
  202. // height: 280px;
  203. // }
  204. .module-dropdown {
  205. padding: 5px;
  206. background-image: @vent-configurable-dropdown;
  207. border-bottom: 2px solid @vent-configurable-home-light-border;
  208. color: @vent-font-color;
  209. position: absolute;
  210. top: 60px;
  211. right: 480px;
  212. }
  213. .module-dropdown-original {
  214. padding: 10px;
  215. background-image: @vent-configurable-dropdown;
  216. border-bottom: 2px solid @vent-configurable-home-light-border;
  217. color: @vent-font-color;
  218. position: absolute;
  219. top: 70px;
  220. right: 460px;
  221. }
  222. .module-trigger-button {
  223. color: @vent-font-color;
  224. background-image: @vent-configurable-dropdown;
  225. border: none;
  226. border-bottom: 2px solid @vent-configurable-home-light-border;
  227. }
  228. .switch-button {
  229. width: 34px;
  230. height: 34px;
  231. position: absolute;
  232. // right: 5px;
  233. bottom: 300px;
  234. z-index: 5;
  235. background-repeat: no-repeat;
  236. background-size: 100% 100%;
  237. }
  238. .report-mode {
  239. background-image: var(--image-monitor-doc);
  240. }
  241. .realtime-mode {
  242. background-image: var(--image-monitor-realtime);
  243. }
  244. .icon-goto {
  245. background-image: var(--image-monitor-goto);
  246. }
  247. .module-monitor-bar {
  248. position: absolute;
  249. top: 100px;
  250. width: 1000px;
  251. height: 200px;
  252. left: calc(50% - 500px);
  253. }
  254. }
  255. :deep(.loading-box) {
  256. position: unset;
  257. }
  258. </style>