From c35074e0e33054bb6c5ada22f8104422ae953b17 Mon Sep 17 00:00:00 2001
From: riku <risaku@163.com>
Date: 星期五, 21 二月 2025 17:19:04 +0800
Subject: [PATCH] 1. 新增默认加载时先判断各选项是否获取完成逻辑

---
 src/views/realtimemode/RealtimeMode.vue |   26 ++++++++++++++++----------
 1 files changed, 16 insertions(+), 10 deletions(-)

diff --git a/src/views/realtimemode/RealtimeMode.vue b/src/views/realtimemode/RealtimeMode.vue
index f6ff253..da8a10b 100644
--- a/src/views/realtimemode/RealtimeMode.vue
+++ b/src/views/realtimemode/RealtimeMode.vue
@@ -28,7 +28,7 @@
 import moment from 'moment';
 import { useFetchData } from '@/composables/fetchData';
 import { TYPE0 } from '@/constant/device-type';
-import { radioOptions } from '@/constant/radio-options';
+import { defaultOptions } from '@/constant/radio-options';
 import { FactorDatas } from '@/model/FactorDatas';
 import DashBoard from './component/DashBoard.vue';
 import RealTimeTrend from './component/RealTimeTrend.vue';
@@ -39,6 +39,7 @@
   startLoopFetchRealTimeData,
   clearFetchingTask
 } from '@/utils/factor/data';
+import thirdPartyDataApi from '@/api/thirdPartyDataApi';
 
 // const mapAnimation = new MapAnimation();
 
@@ -54,7 +55,7 @@
       deviceType: TYPE0,
       deviceCode: '',
       // 鐩戞祴鍥犲瓙鐨勭被鍨嬬紪鍙�
-      factorType: radioOptions(TYPE0)[0].value,
+      factorType: defaultOptions(TYPE0),
       // 鏂拌幏鍙栫殑鐩戞祴鏁版嵁
       factorDatas: new FactorDatas(),
       // 鍏ㄩ儴鐩戞祴鏁版嵁
@@ -102,19 +103,23 @@
     },
     fetchRealTimeData() {
       this.fetchData((page) => {
-        return fetchHistoryData({
-          deviceCode: this.deviceCode,
-          // startTime: '2024-08-20 06:00:00',
-          // endTime: '2024-08-20 06:02:00',
-          page,
-          perPage: 100
-        }).then((res) => {
+        return fetchHistoryData(
+          {
+            deviceCode: this.deviceCode,
+            // startTime: '2024-08-20 06:00:00',
+            // endTime: '2024-08-20 06:02:00',
+            page,
+            perPage: 100
+          },
+          false
+        ).then((res) => {
           this.onFetchData(res.data);
           this.onMapData(res.data);
           // if (res.data.length > 0) {
           //   this.fetchNextData(res.data[res.data.length - 1].time);
           // }
           this.fetchNextData();
+          thirdPartyDataApi.fetchLatestData(this.deviceType, this.deviceCode);
         });
       });
     },
@@ -133,6 +138,7 @@
         (res) => {
           this.onFetchData(res.data);
           this.onMapData(res.data);
+          thirdPartyDataApi.fetchLatestData(this.deviceType, this.deviceCode);
         }
       );
     },
@@ -143,7 +149,7 @@
         this.notFirstFetch = true;
       }
       startIndex = startIndex < 0 ? 0 : startIndex;
-      return new Promise((resolve, reject) => {
+      return new Promise(() => {
         this.allFactorDatas.addData(dataList, this.drawMode, () => {
           realTimeMapAnimation.moveAnimation(
             this.allFactorDatas,

--
Gitblit v1.9.3