warnMonitor.vue 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  1. <template>
  2. <!-- 告警监控主容器 -->
  3. <div class="warn-monitor">
  4. <!-- 顶部区域:三个面板横向排列 -->
  5. <div class="warn-top-box">
  6. <!-- 左侧面板:告警列表 -->
  7. <div class="baisc-box">
  8. <WarnLeftTop :tableData="tableData" @detail="handlerDetail"></WarnLeftTop>
  9. </div>
  10. <!-- 中间面板:告警详情展示 -->
  11. <div class="baisc-box">
  12. <WarnCenTop :warnData="warnData"></WarnCenTop>
  13. </div>
  14. <!-- 右侧面板:告警统计 -->
  15. <div class="baisc-box">
  16. <WarnRightTop></WarnRightTop>
  17. </div>
  18. </div>
  19. <!-- 底部区域:告警趋势/历史记录 -->
  20. <div class="warn-bot-box">
  21. <WarnBottom></WarnBottom>
  22. </div>
  23. </div>
  24. </template>
  25. <script lang="ts" setup>
  26. import { onMounted, onUnmounted, ref, computed, nextTick, onBeforeMount, watch } from 'vue';
  27. import WarnLeftTop from './components/WarnLeftTop.vue';
  28. import WarnCenTop from './components/WarnCenTop.vue'
  29. import WarnRightTop from './components/WarnRightTop.vue'
  30. import WarnBottom from './components/WarnBottom.vue'
  31. import { autoLogList, managesysList } from './hsqHome.api'
  32. // 告警列表数据
  33. let tableData = ref<any[]>([])
  34. // 当前选中的告警详情数据
  35. let warnData = ref({})
  36. // 系统ID,用于筛选数据
  37. let systemId = ref('')
  38. // 定时器引用,用于页面卸载时清理
  39. let timer: null | NodeJS.Timeout = null;
  40. /**
  41. * 定时获取监测数据
  42. *
  43. * @param flag 是否立即执行(默认false,延迟30秒执行)
  44. */
  45. function getMonitor(flag?: boolean) {
  46. timer = setTimeout(async () => {
  47. // 获取告警列表数据
  48. await getWarnList();
  49. if (timer) {
  50. timer = null;
  51. }
  52. // 递归调用实现持续轮询
  53. getMonitor();
  54. }, flag ? 0 : 30000);
  55. }
  56. /**
  57. * 获取告警列表数据
  58. * 根据systemId筛选告警记录,最多返回100条
  59. */
  60. async function getWarnList() {
  61. let res = await autoLogList({ pageNum: 1, pageSize: 100, sysId: systemId.value });
  62. tableData.value = res.records || []
  63. }
  64. /**
  65. * 处理告警详情点击事件
  66. * 将选中的告警项数据传递给中间面板显示
  67. *
  68. * @param item 选中的告警记录
  69. */
  70. function handlerDetail(item: any) {
  71. warnData.value = item
  72. }
  73. /**
  74. * 获取系统列表并设置默认系统ID
  75. * 用于初始化时获取systemId,供后续接口调用使用
  76. */
  77. async function getManagesysList() {
  78. const res = await managesysList({ strtype: 'sys_openair_fire', pagetype: 'normal' });
  79. if (res && res.records) {
  80. systemId.value = res.records[0].id
  81. }
  82. }
  83. // 页面加载时初始化数据并启动定时轮询
  84. onMounted(async() => {
  85. await getManagesysList();
  86. getMonitor(true);
  87. });
  88. // 页面卸载时清理定时器,防止内存泄漏
  89. onUnmounted(() => {
  90. timer = null
  91. clearTimeout(timer);
  92. });
  93. </script>
  94. <style lang="less" scoped>
  95. @import '/@/design/theme.less';
  96. @{theme-deepblue} {
  97. .warn-monitor {}
  98. }
  99. .warn-monitor {
  100. --image-box1-bg: url('@/assets/images/home-container/configurable/hsq/2-4.png');
  101. --image-box1-bg1: url('@/assets/images/home-container/configurable/hsq/2-10.png');
  102. --image-box1-bg2: url('@/assets/images/home-container/configurable/hsq/3-3.png');
  103. width: 100%;
  104. height: calc(100% - 10px);
  105. color: @white;
  106. position: relative;
  107. background-color: #09172c;
  108. margin-bottom: 10px;
  109. }
  110. .warn-top-box {
  111. position: relative;
  112. display: flex;
  113. justify-content: space-between;
  114. height: calc(100% - 200px);
  115. margin-bottom: 10px;
  116. }
  117. .warn-bot-box {
  118. width: 100%;
  119. height: 190px;
  120. background: var(--image-box1-bg2) no-repeat;
  121. background-size: 100% 100%;
  122. }
  123. .baisc-box {
  124. &:nth-child(1) {
  125. width: 430px;
  126. height: 100%;
  127. background: var(--image-box1-bg) no-repeat;
  128. background-size: 100% 100%;
  129. margin-right: 10px;
  130. }
  131. &:nth-child(2) {
  132. position: absolute;
  133. top: 63px;
  134. left: 50%;
  135. transform: translate(-50%, 0);
  136. width: calc(100% - 880px);
  137. height: calc(100% - 63px);
  138. background: var(--image-box1-bg1) no-repeat;
  139. background-size: 100% 100%;
  140. }
  141. &:nth-child(3) {
  142. width: 430px;
  143. height: 100%;
  144. background: var(--image-box1-bg) no-repeat;
  145. background-size: 100% 100%;
  146. margin-left: 10px;
  147. }
  148. }
  149. :deep(.loading-box) {
  150. position: unset;
  151. }
  152. </style>