index.vue 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208
  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 mapComponent from './components/3Dmap/index.vue';
  65. const props = defineProps<{
  66. billboardType: string;
  67. title?: string;
  68. }>();
  69. // const route = useRoute();
  70. const { open } = useAutoLogin();
  71. const router = useRouter();
  72. // 组件Map,不同type使用不用组件
  73. const componentMap = {
  74. DustStatus,
  75. FileOverview,
  76. VentilationStatus,
  77. GasStatus,
  78. FireStatus,
  79. Summary,
  80. Warning,
  81. DuskRisk,
  82. };
  83. const mainTitle = props.title || '国能神东一通三防管控平台';
  84. // 看板相关的基础配置
  85. const billboards = ref<(() => VNode)[]>([]);
  86. function fetchBillboards() {
  87. getSummary().then((r) => {
  88. billboards.value = r.map((el) => {
  89. return () =>
  90. h(
  91. BaseCard,
  92. {
  93. title: el.orgname || '/',
  94. onOpen: () => openHandler(el.ip),
  95. },
  96. {
  97. default: () =>
  98. h(componentMap[props.billboardType], {
  99. data: JSON.parse(JSON.stringify(el)),
  100. }),
  101. }
  102. );
  103. });
  104. });
  105. }
  106. // 看板分页相关的配置
  107. const pageSize = 8;
  108. const currentPage = ref(1);
  109. const totalPage = computed(() => {
  110. return Math.ceil(billboards.value.length / pageSize) + 1;
  111. });
  112. // 能真正在页面上展示的看板
  113. const shownBillboards = computed(() => {
  114. return billboards.value.slice((currentPage.value - 1) * pageSize, currentPage.value * pageSize);
  115. });
  116. function changeCurrentPage(pagecount: number) {
  117. currentPage.value = Math.max((currentPage.value + pagecount) % totalPage.value, 1);
  118. }
  119. // const billboardType = ref('DustStatus');
  120. // const showBtn = ref(true);
  121. // 组件Map,不同type需要跳转到不同的矿端页面
  122. const routePathMap = {
  123. DustStatus: '/dust/warn/home',
  124. FileOverview: '/fileManager/fileDetail/home',
  125. VentilationStatus: '/micro-vent-3dModal/dashboard/analysis',
  126. GasStatus: '/gas/warn/home',
  127. FireStatus: '/fire/warn/home',
  128. Summary: '/monitorChannel/monitor-alarm-home',
  129. };
  130. // 页面跳转
  131. function openHandler(ip: string) {
  132. // const url = `http://localhost:3100/login`;
  133. const url = `http://${ip}:8092${routePathMap[props.billboardType]}`;
  134. open(url);
  135. }
  136. // 返回首页
  137. function getBack() {
  138. router.push('/company/home');
  139. }
  140. onMounted(() => {
  141. // if (route.query.type) {
  142. // billboardType.value = route.query.type as string;
  143. // showBtn.value = false;
  144. // }
  145. fetchBillboards();
  146. });
  147. </script>
  148. <style lang="less" scoped>
  149. @font-face {
  150. font-family: 'douyuFont';
  151. src: url('../../../../assets/font/douyuFont.otf');
  152. }
  153. .company-home {
  154. width: 100%;
  155. height: 100%;
  156. color: #fff;
  157. position: relative;
  158. background: url('@/assets/images/company/content-bg.png') no-repeat;
  159. background-size: 100% 100%;
  160. // background: url('../../../../assets/images/company/home-pageBg.png') no-repeat center;
  161. // background-size: 100% 100%;
  162. .top-bg {
  163. width: 100%;
  164. height: 97px;
  165. background: url('@/assets/images/company/top-bg.png') no-repeat center;
  166. .main-title {
  167. height: 96px;
  168. font-family: 'douyuFont';
  169. font-size: 20px;
  170. letter-spacing: 2px;
  171. display: flex;
  172. justify-content: center;
  173. align-items: center;
  174. }
  175. }
  176. .company-content {
  177. width: 100%;
  178. height: calc(100% - 97px);
  179. padding: 30px 100px 0 100px;
  180. }
  181. .company__arrow_left {
  182. position: absolute;
  183. top: calc(50% - 38px);
  184. left: 15px;
  185. }
  186. .company__arrow_right {
  187. position: absolute;
  188. top: calc(50% - 38px);
  189. right: 15px;
  190. }
  191. }
  192. </style>