vent182.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353
  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. <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="flex pos-absolute bottom-10px left-60px 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 class="switch-button-group">
  67. <div
  68. v-if="sysDataType === 'all'"
  69. :class="{ 'realtime-mode': isDataRealTime }"
  70. alt="切换数据模式"
  71. class="switch-button report-mode"
  72. @click="switchDataMode"
  73. ></div>
  74. <div v-if="hasPermission('show:modalChange')" class="switch-button icon-goto2D" @click="goMicroApp('2.5')"></div>
  75. <div class="switch-button icon-goto3D" @click="goMicroApp('3')"></div>
  76. </div>
  77. </template>
  78. </div>
  79. </template>
  80. <script lang="ts" setup>
  81. // 用来代替该菜单项 vent/monitorManager/deviceMonitor/index /micro-vent-3dModal/dashboard/analysis
  82. // 同时需要更改模型配置,旧配置为 dashboard/Analysis /dashboard/analysis
  83. import { onMounted, onUnmounted, ref, watch } from 'vue';
  84. // import { CaretDownOutlined } from '@ant-design/icons-vue';
  85. import MonitorBar from './components/MonitorBar.vue';
  86. import { useInitConfigs, useInitPage } from './hooks/useInit';
  87. import ModuleEnhanced from './components/ModuleEnhanced.vue';
  88. import ModuleOriginal from './components/ModuleOriginal.vue';
  89. import ModuleCommon from './components/ModuleCommon.vue';
  90. // import { useRoute } from 'vue-router';
  91. import SubApp from '/@/components/vent/micro/createSubApp.vue';
  92. import { list } from './configurable.api';
  93. import { useRoute, useRouter } from 'vue-router';
  94. import { useGlobSetting } from '/@/hooks/setting';
  95. import { testConfigVent182 } from './configurable.data';
  96. import { usePermission } from '/@/hooks/web/usePermission';
  97. console.time('debug setup vent182');
  98. const { sysDataType = 'monitor', title = '智能通风管控系统' } = useGlobSetting();
  99. const { configs, isOriginal, isCommon, fetchConfigs } = useInitConfigs();
  100. const { mainTitle, enhancedConfigs, hiddenList, data, updateData, updateEnhancedConfigs } = useInitPage(title);
  101. const { hasPermission } = usePermission();
  102. const route = useRoute();
  103. const router = useRouter();
  104. const isDataRealTime = ref(sysDataType === 'monitor');
  105. const showBar = ref(true);
  106. let interval: number | undefined;
  107. function switchDataMode() {
  108. isDataRealTime.value = !isDataRealTime.value;
  109. refresh();
  110. }
  111. function refresh() {
  112. fetchConfigs(isDataRealTime.value ? 'vent_182_realtime' : 'vent_182').then(() => {
  113. if (!configs.value.length) {
  114. configs.value = testConfigVent182;
  115. }
  116. updateEnhancedConfigs(configs.value);
  117. list({}).then(updateData);
  118. });
  119. }
  120. function initInterval() {
  121. setInterval(() => {
  122. list({}).then(updateData);
  123. }, 60000);
  124. }
  125. function goMicroApp(flag: string) {
  126. if (flag === '3') {
  127. router.push({
  128. path: route.path.includes('micro-vent-3dModal') ? route.path : route.path.replace('micro-vent-2dModal', 'micro-vent-3dModal'),
  129. query: {
  130. ...route.query,
  131. type: 'model3D',
  132. deviceType: 'model3D',
  133. isNoReverse: '1',
  134. },
  135. });
  136. } else {
  137. router.push({
  138. path: route.path.includes('micro-vent-2dModal') ? route.path : route.path.replace('micro-vent-3dModal', 'micro-vent-2dModal'),
  139. query: {
  140. ...route.query,
  141. type: 'model3D',
  142. deviceType: 'model3D',
  143. isNoReverse: '1',
  144. },
  145. });
  146. }
  147. }
  148. watch(
  149. () => route.query,
  150. () => {
  151. if (route.query.deviceType) {
  152. // 仅需要展示子应用,模拟 unmounted
  153. clearInterval(interval);
  154. } else {
  155. // 模拟 mounted
  156. refresh();
  157. initInterval();
  158. }
  159. }
  160. );
  161. onMounted(() => {
  162. refresh();
  163. initInterval();
  164. console.timeEnd('debug setup vent182');
  165. });
  166. onUnmounted(() => {
  167. clearInterval(interval);
  168. });
  169. </script>
  170. <style lang="less" scoped>
  171. @import '/@/design/theme.less';
  172. @font-face {
  173. font-family: 'douyuFont';
  174. src: url('/@/assets/font/douyuFont.otf');
  175. }
  176. @{theme-deepblue} {
  177. .company-home {
  178. --image-modal-top: url('/@/assets/images/themify/deepblue/vent/home/modal-top.png');
  179. }
  180. }
  181. .company-home {
  182. --image-modal-top: url('/@/assets/images/vent/home/modal-top.png');
  183. --image-monitor-realtime: url('/@/assets/images/company/monitor-realtime.png');
  184. --image-monitor-doc: url('/@/assets/images/company/monitor-doc.png');
  185. --image-monitor-goto2: url('/@/assets/images/vent/home/2.5D.png');
  186. --image-monitor-goto3: url('/@/assets/images/vent/home/3D.png');
  187. width: 100%;
  188. height: 100%;
  189. color: @white;
  190. position: relative;
  191. // background: url('@/assets/images/home-container/configurable/firehome/bg.png') no-repeat center;
  192. .top-bg {
  193. width: 100%;
  194. height: 48px;
  195. background: var(--image-modal-top) no-repeat center;
  196. position: absolute;
  197. z-index: 1;
  198. background-size: 100% 100%;
  199. .main-title {
  200. height: 48px;
  201. font-family: 'douyuFont';
  202. font-size: 20px;
  203. letter-spacing: 2px;
  204. padding-top: 8px;
  205. display: flex;
  206. justify-content: center;
  207. align-items: center;
  208. }
  209. }
  210. // .module-left {
  211. // position: absolute;
  212. // width: 450px;
  213. // height: 280px;
  214. // left: 0;
  215. // }
  216. // .module-right {
  217. // position: absolute;
  218. // width: 450px;
  219. // height: 280px;
  220. // right: 0;
  221. // }
  222. // .module-bottom {
  223. // position: absolute;
  224. // width: 1000px;
  225. // height: 280px;
  226. // }
  227. .module-dropdown {
  228. padding: 5px;
  229. background-image: @vent-configurable-dropdown;
  230. border-bottom: 2px solid @vent-configurable-home-light-border;
  231. color: @vent-font-color;
  232. position: absolute;
  233. top: 60px;
  234. right: 430px;
  235. }
  236. .module-dropdown-original {
  237. padding: 10px;
  238. background-image: @vent-configurable-dropdown;
  239. border-bottom: 2px solid @vent-configurable-home-light-border;
  240. color: @vent-font-color;
  241. position: absolute;
  242. top: 70px;
  243. right: 460px;
  244. }
  245. .module-trigger-button {
  246. color: @vent-font-color;
  247. background-image: @vent-configurable-dropdown;
  248. border: none;
  249. border-bottom: 2px solid @vent-configurable-home-light-border;
  250. }
  251. .switch-button-group {
  252. display: flex;
  253. position: absolute;
  254. right: 430px;
  255. top: 580px;
  256. }
  257. .switch-button {
  258. width: 50px;
  259. height: 50px;
  260. border-radius: 15%;
  261. padding: 8px;
  262. backdrop-filter: blur(10px);
  263. background-color: rgba(30, 58, 117, 0.418);
  264. //position: absolute;
  265. // right: 5px;
  266. bottom: 300px;
  267. z-index: 5;
  268. margin: 0 5px;
  269. }
  270. .report-mode {
  271. &::after {
  272. width: 34px;
  273. height: 34px;
  274. content: '';
  275. position: absolute;
  276. top: 8px;
  277. left: 8px;
  278. background-image: var(--image-monitor-doc);
  279. background-repeat: no-repeat;
  280. background-size: 100% 100%;
  281. }
  282. }
  283. .realtime-mode {
  284. &::after {
  285. width: 34px;
  286. height: 34px;
  287. content: '';
  288. position: absolute;
  289. top: 8px;
  290. left: 8px;
  291. background-image: var(--image-monitor-realtime);
  292. background-repeat: no-repeat;
  293. background-size: 100% 100%;
  294. }
  295. }
  296. .icon-goto2D {
  297. &::after {
  298. width: 34px;
  299. height: 34px;
  300. content: '';
  301. position: absolute;
  302. top: 8px;
  303. left: 8px;
  304. background-image: var(--image-monitor-goto2);
  305. background-repeat: no-repeat;
  306. background-size: 100% 100%;
  307. }
  308. }
  309. .icon-goto3D {
  310. &::after {
  311. width: 34px;
  312. height: 34px;
  313. content: '';
  314. position: absolute;
  315. top: 8px;
  316. left: 8px;
  317. background-image: var(--image-monitor-goto3);
  318. background-repeat: no-repeat;
  319. background-size: 100% 100%;
  320. }
  321. }
  322. .module-monitor-bar {
  323. position: absolute;
  324. top: 90px;
  325. width: 1080px;
  326. height: 74px;
  327. left: calc(50% - 540px);
  328. }
  329. }
  330. :deep(.loading-box) {
  331. position: unset;
  332. }
  333. </style>