ventV6.vue 9.1 KB

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