瀏覽代碼

#669 历史健康趋图未显示缓存数据

zhangchuang 3 月之前
父節點
當前提交
8cf3db72ee
共有 1 個文件被更改,包括 35 次插入0 次删除
  1. 35 0
      src/views/HealthStatusAnalysis/mock.vue

+ 35 - 0
src/views/HealthStatusAnalysis/mock.vue

@@ -628,6 +628,9 @@ const pageInit = async () => {
           data: its,
         };
       });
+      res.data.healths.forEach((item: any) => {
+        newHealthyMessage(item)
+      })
     }
   });
   // 处理接收到的消息
@@ -871,6 +874,9 @@ const mockStart = async (state: boolean = false) => {
           data: its,
         };
       });
+      resultCatch.data.healths.forEach((item: any) => {
+        newHealthyMessage(item)
+      })
     }
   } else {
     lineParamsAllRef.value = [];
@@ -1441,6 +1447,35 @@ const healthyStatusText = ref({
   color: "",
 });
 let flag = false;
+
+const newHealthyMessage = (data: Object) => {
+  console.log('newHealthyMessage ===>', data)
+  if (data.health == 99) {
+    if (flag) {
+      data.health = 92;
+      flag = false;
+    } else {
+      data.health = 98;
+      flag = true;
+    }
+  }
+
+  // 获取健康数据
+  // let obj=determineHealthStatus(data.avg_num)
+  let obj = determineHealthStatus(`${data.sha}(${data.health}%)`);
+  healthyStatusText.value = obj;
+  sessionStorage.setItem("healthyStatusText", JSON.stringify(data));
+  xAxisData.value.push(moment(data._ts).format("HH:mm:ss"));
+  seriesData.value[0].data.push(data.health);
+  let arr = seriesData.value[0].data;
+  seriesData.value = [
+    {
+      name: "趋势",
+      data: arr,
+    },
+  ];
+};
+
 const healthyMessage = (data: Object) => {
   if (data.avg_num == 99) {
     if (flag) {