index.vue 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. <!-- eslint-disable vue/multi-word-component-names -->
  2. <template>
  3. <div class="company-home">
  4. <!-- 渲染所有模块 -->
  5. <ModulePrimary v-for="cfg in cfgs" :key="cfg.deviceType + cfg.moduleName" :show-style="cfg.showStyle"
  6. :module-data="cfg.moduleData" :module-name="cfg.moduleName" :device-type="cfg.deviceType" :data="data"
  7. :visible="true" />
  8. </div>
  9. </template>
  10. <script lang="ts" setup>
  11. import { computed, onMounted, onUnmounted, ref } from 'vue';
  12. import { useInitConfigs, useInitPage } from '@/components/Configurable/hooks/useInit';
  13. import { testConfigSealedGoaf } from './configurable.data.sealedGoaf';
  14. import { getCoalSeamFireNum, getMineProductionStatusNum, getOverLimitNum, getGoafAlarmNum, getGoafAlarmLevel } from './sealedGoaf.api'
  15. import ModulePrimary from '/@/components/Configurable/ModulePrimary.vue';
  16. import { useGlobSetting } from '/@/hooks/setting';
  17. const { title = '采空区密闭监测与分析系统' } = useGlobSetting();
  18. const { data, updateData } = useInitPage(title);
  19. const cfgs = computed(() => configs.value);
  20. const { configs, fetchConfigs } = useInitConfigs();
  21. const mineData = ref({}); // 所有数据汇总
  22. onMounted(async () => {
  23. try {
  24. // 1. 先获取基础配置(若有接口获取配置则保留,否则直接用本地testConfigSealedGoaf)
  25. await fetchConfigs('sealed_goaf');
  26. // 2. 异步获取所有接口数据(并行请求提升性能)
  27. const [coalSeamFireData, productionStatusData, overLimitData, goafAlarmData, goafAlarmLevel] = await Promise.all([
  28. getCoalSeamFireNum(), // 煤层自燃倾向数据
  29. getMineProductionStatusNum(), // 当日生产状态数据
  30. getOverLimitNum(), // 超限数据(可按需处理)
  31. getGoafAlarmNum({ mineCode: '100008' }), // 执法处风险统计
  32. getGoafAlarmLevel({ mineCode: '100008' }),
  33. ]);
  34. // 3. 把接口数据赋值给响应式变量(备用)
  35. mineData.value = { coalSeamFireData, productionStatusData, overLimitData, goafAlarmData, goafAlarmLevel };
  36. // 4. 赋值更新后的配置到configs(触发组件重新渲染)
  37. configs.value = [...testConfigSealedGoaf]; // 解构触发响应式更新
  38. // 5. 更新页面数据
  39. updateData(mineData.value);
  40. } catch (error) {
  41. console.error('数据获取/配置更新失败:', error);
  42. }
  43. });
  44. // 数据处理函数
  45. onUnmounted(() => { });
  46. </script>
  47. <style lang="less" scoped>
  48. @import '/@/design/theme.less';
  49. @font-face {
  50. font-family: 'douyuFont';
  51. src: url('/@/assets/font/douyuFont.otf');
  52. }
  53. .company-home {
  54. position: absolute;
  55. width: 100%;
  56. height: 100%;
  57. color: @white;
  58. background-image: linear-gradient(90deg, @map-bg 0%, @map-bg 14%, transparent 50%, @map-bg 86%, @map-bg 100%);
  59. background-repeat: no-repeat;
  60. background-size: 100% 100%;
  61. z-index: @layout-basic-z-index;
  62. // 允许点击穿透以支持下面的地图进行交互
  63. pointer-events: none;
  64. }
  65. :deep(.ant-select-selection-item) {
  66. display: flex;
  67. align-items: center;
  68. }
  69. </style>