index.vue 5.9 KB

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