Browse Source

修改首次进入加入cache

chenbaoxin 3 months ago
parent
commit
d6fc9bf2f6
1 changed files with 19 additions and 4 deletions
  1. 19 4
      src/views/HealthStatusAnalysis/mock.vue

+ 19 - 4
src/views/HealthStatusAnalysis/mock.vue

@@ -599,7 +599,7 @@ const getQueryDataRangeSpeed = async () => {
     count:Number(valueObj.batch_size),
     time:Number(valueObj.interval)
    }
-   mockStart()
+   mockStart(true)
 };
 onMounted(async () => {
   getcateData();
@@ -715,7 +715,7 @@ const setParamsHl = (start: string, end: string) => {
   ];
   setConditionTime({"min_time":hlQueryParams.value.eDate[0],"max_time":hlQueryParams.value.eDate[1]})
 };
-const mockStart = () => {
+const mockStart = async (state:boolean=false) => {
   if (queryParamsMock.value.time > 60) {
     ElMessage({
       message: `最大不超过60s`,
@@ -730,7 +730,19 @@ const mockStart = () => {
     });
     return false;
   }
-  lineParamsAllRef.value = [];
+  // mounted进来使用缓存接口数据
+  if (state) {
+    let resultCatch= await mockCacheData({})
+    lineParamsAllRef.value = resultCatch.data.map((its:any) => {
+      return {
+        data: its,
+      };
+    });
+    // debugger
+  }else{
+
+    lineParamsAllRef.value = [];
+  }
   seriesData.value = [
     {
       name: "趋势",
@@ -746,7 +758,8 @@ const mockStart = () => {
     start: queryParamsMock.value.sDate,
     end: queryParamsMock.value.eDate,
   });
-  updateDataRangeSpeed({
+  if (!state) {
+    updateDataRangeSpeed({
     start_time: moment(queryParamsMock.value.sDate).format(
       "YYYY-MM-DD HH:mm:ss"
     ),
@@ -759,6 +772,8 @@ const mockStart = () => {
       type: "success",
     });
   });
+  }
+  
 };
 let cateBigRef = ref([]);
 let cateSmallRef = ref([]);