mock.vue 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209
  1. <!-- eslint-disable vue/multi-word-component-names -->
  2. <template>
  3. <div class="company-home">
  4. <a-button
  5. preIcon="ant-design:rollback-outlined"
  6. type="text"
  7. size="small"
  8. style="position: absolute; left: 15px; top: 15px; color: #fff"
  9. @click="getBack"
  10. >
  11. 回到首页
  12. </a-button>
  13. <div class="top-bg">
  14. <div class="main-title">{{ mainTitle }}</div>
  15. </div>
  16. <a-row class="company-content" :gutter="10">
  17. <!-- <a-col v-for="(item, i) in shownBillboards" :key="`svvhbi-${i}`" :span="6">
  18. <BaseCard :title="item.orgname || '/'" @open="openHandler(item.ip)">
  19. <component :is="componentMap[billboardType]" :data="item" />
  20. </BaseCard>
  21. </a-col> -->
  22. <a-col v-for="(render, i) in shownBillboards" :key="`svvhbi-${i}`" :span="6">
  23. <component :is="render" />
  24. </a-col>
  25. </a-row>
  26. <!-- <div v-if="showBtn" style="position: absolute; top: 0; left: 0">
  27. <a-button @click="billboardType = 'DustStatus'">切换粉尘看板</a-button>
  28. <a-button @click="billboardType = 'FireStatus'">切换火灾看板</a-button>
  29. <a-button @click="billboardType = 'FileOverview'">切换文件看板</a-button>
  30. <a-button @click="billboardType = 'VentilationStatus'">切换风扇看板</a-button>
  31. <a-button @click="billboardType = 'GasStatus'">切换瓦斯看板</a-button>
  32. </div> -->
  33. <ArrowButton point-to="left" class="company__arrow_left" @click="changeCurrentPage(-1)" />
  34. <ArrowButton point-to="right" class="company__arrow_right" @click="changeCurrentPage(1)" />
  35. </div>
  36. </template>
  37. <script lang="ts" setup>
  38. /**
  39. * 本文件夹下的内容是公司端看板页的内容:
  40. *
  41. * 看板有多种类型,包含了监测、跳转矿端的功能。
  42. *
  43. * 菜单配置相关信息:使用vent/home/billboard/gas及类似组件进行配置(即 ./gas.vue ./fire.vue 等)
  44. *
  45. * 支持的看板类型如下:'DustStatus'、'FireStatus'、'FileOverview'、'VentilationStatus'、'GasStatus'、'Summary'
  46. *
  47. */
  48. import { VNode, computed, h, onMounted, ref } from 'vue';
  49. import BaseCard from './components/BaseCard.vue';
  50. import ArrowButton from './components/ArrowButton.vue';
  51. // import { useRoute } from 'vue-router';
  52. // import { getSummary } from './billboard.api';
  53. import { useAutoLogin } from '../../../../hooks/vent/useAutoLogin';
  54. import DustStatus from './components/DustStatus.vue';
  55. import FileOverview from './components/FileOverview.vue';
  56. import FireStatus from './components/FireStatus.vue';
  57. import VentilationStatus from './components/VentilationStatus.vue';
  58. import GasStatus from './components/GasStatus.vue';
  59. import Summary from './components/Summary.vue';
  60. import Warning from './components/Warning.vue';
  61. import DuskRisk from './components/DustRisk.vue';
  62. import _ from 'lodash-es';
  63. import { useRouter } from 'vue-router';
  64. import { mockSHENDONG } from './billboard.data';
  65. // import mapComponent from './components/3Dmap/index.vue';
  66. const props = defineProps<{
  67. billboardType: string;
  68. title?: string;
  69. }>();
  70. // const route = useRoute();
  71. const { open } = useAutoLogin();
  72. const router = useRouter();
  73. // 组件Map,不同type使用不用组件
  74. const componentMap = {
  75. DustStatus,
  76. FileOverview,
  77. VentilationStatus,
  78. GasStatus,
  79. FireStatus,
  80. Summary,
  81. Warning,
  82. DuskRisk,
  83. };
  84. const mainTitle = props.title || '国能神东一通三防管控平台';
  85. // 看板相关的基础配置
  86. const billboards = ref<(() => VNode)[]>([]);
  87. function fetchBillboards() {
  88. Promise.resolve(mockSHENDONG).then((r) => {
  89. billboards.value = r.map((el) => {
  90. return () =>
  91. h(
  92. BaseCard,
  93. {
  94. title: el.orgname || '/',
  95. onOpen: () => openHandler(el.ip),
  96. },
  97. {
  98. default: () =>
  99. h(componentMap[props.billboardType], {
  100. data: JSON.parse(JSON.stringify(el)),
  101. }),
  102. }
  103. );
  104. });
  105. });
  106. }
  107. // 看板分页相关的配置
  108. const pageSize = 8;
  109. const currentPage = ref(1);
  110. const totalPage = computed(() => {
  111. return Math.ceil(billboards.value.length / pageSize) + 1;
  112. });
  113. // 能真正在页面上展示的看板
  114. const shownBillboards = computed(() => {
  115. return billboards.value.slice((currentPage.value - 1) * pageSize, currentPage.value * pageSize);
  116. });
  117. function changeCurrentPage(pagecount: number) {
  118. currentPage.value = Math.max((currentPage.value + pagecount) % totalPage.value, 1);
  119. }
  120. // const billboardType = ref('DustStatus');
  121. // const showBtn = ref(true);
  122. // 组件Map,不同type需要跳转到不同的矿端页面
  123. const routePathMap = {
  124. DustStatus: '/dust/warn/home',
  125. FileOverview: '/fileManager/fileDetail/home',
  126. VentilationStatus: '/micro-vent-3dModal/dashboard/analysis',
  127. GasStatus: '/gas/warn/home',
  128. FireStatus: '/fire/warn/home',
  129. Summary: '/monitorChannel/monitor-alarm-home',
  130. };
  131. // 页面跳转
  132. function openHandler(ip: string) {
  133. // const url = `http://localhost:3100/login`;
  134. const url = `http://${ip}:8092${routePathMap[props.billboardType]}`;
  135. open(url);
  136. }
  137. // 返回首页
  138. function getBack() {
  139. router.push('/company/home');
  140. }
  141. onMounted(() => {
  142. // if (route.query.type) {
  143. // billboardType.value = route.query.type as string;
  144. // showBtn.value = false;
  145. // }
  146. fetchBillboards();
  147. });
  148. </script>
  149. <style lang="less" scoped>
  150. @font-face {
  151. font-family: 'douyuFont';
  152. src: url('../../../../assets/font/douyuFont.otf');
  153. }
  154. .company-home {
  155. width: 100%;
  156. height: 100%;
  157. color: #fff;
  158. position: relative;
  159. background: url('@/assets/images/company/content-bg.png') no-repeat;
  160. background-size: 100% 100%;
  161. // background: url('../../../../assets/images/company/home-pageBg.png') no-repeat center;
  162. // background-size: 100% 100%;
  163. .top-bg {
  164. width: 100%;
  165. height: 97px;
  166. background: url('@/assets/images/company/top-bg.png') no-repeat center;
  167. .main-title {
  168. height: 96px;
  169. font-family: 'douyuFont';
  170. font-size: 20px;
  171. letter-spacing: 2px;
  172. display: flex;
  173. justify-content: center;
  174. align-items: center;
  175. }
  176. }
  177. .company-content {
  178. width: 100%;
  179. height: calc(100% - 97px);
  180. padding: 30px 100px 0 100px;
  181. }
  182. .company__arrow_left {
  183. position: absolute;
  184. top: calc(50% - 38px);
  185. left: 15px;
  186. }
  187. .company__arrow_right {
  188. position: absolute;
  189. top: calc(50% - 38px);
  190. right: 15px;
  191. }
  192. }
  193. </style>