From d58b7ec5be59dfe384e27b1e0b42d76998593619 Mon Sep 17 00:00:00 2001
From: riku <risaku@163.com>
Date: 星期五, 30 五月 2025 11:55:13 +0800
Subject: [PATCH] 动态溯源功能(待完成)

---
 src/views/historymode/HistoryMode.vue      |   38 ++++++++++++++++--
 src/api/index.js                           |    2 
 src/constant/scene-types/options-jingan.js |    4 ++
 src/components/search/SearchBar.vue        |   26 ++++++------
 src/views/realtimemode/RealtimeMode.vue    |    3 +
 src/router/index.js                        |    2 
 src/api/thirdPartyDataApi.js               |    6 +-
 7 files changed, 57 insertions(+), 24 deletions(-)

diff --git a/src/api/index.js b/src/api/index.js
index cfe583e..130eb33 100644
--- a/src/api/index.js
+++ b/src/api/index.js
@@ -1,7 +1,7 @@
 import axios from 'axios';
 import { ElMessage } from 'element-plus';
 
-const debug = true;
+const debug = false;
 
 let ip1 = 'http://47.100.191.150:9029/';
 let ws = `47.100.191.150:9030`;
diff --git a/src/api/thirdPartyDataApi.js b/src/api/thirdPartyDataApi.js
index cc326dd..093b51b 100644
--- a/src/api/thirdPartyDataApi.js
+++ b/src/api/thirdPartyDataApi.js
@@ -35,10 +35,10 @@
     }
     if (!label) return;
 
-    let params = `label=${label}&deviceType=${deviceType}&deviceCode=${deviceCode}`;
-    params += startTime ? `&startTime=${startTime}` : '';
     return $http
-      .get(`air/thirdParty/data/fetch/latest?${params}`)
+      .get(`air/thirdParty/data/fetch/latest`, {
+        params: { label, deviceType, deviceCode, startTime }
+      })
       .then((res) => res.data);
   }
 };
diff --git a/src/components/search/SearchBar.vue b/src/components/search/SearchBar.vue
index a6fe820..16572cc 100644
--- a/src/components/search/SearchBar.vue
+++ b/src/components/search/SearchBar.vue
@@ -65,20 +65,20 @@
     mission(nV, oV) {
       if (nV != oV) {
         this.onInit(() => {
-          this.formSearch.timeArray = [
-            new Date(nV.startTime),
-            new Date(nV.endTime)
-          ];
-          this.dateRange = [new Date(nV.startTime), new Date(nV.endTime)];
-          this.formSearch.deviceType = nV.deviceType;
-          this.formSearch.deviceCode = nV.deviceCode;
-
-          // 浠h〃棣栨杩涘叆鐣岄潰锛屾鏃惰嚜鍔ㄦ墽琛岄涓换鍔$殑鏁版嵁鏌ヨ鎿嶄綔
-          if (oV == undefined) {
-            setTimeout(() => {
+          setTimeout(() => {
+            // 寤舵椂璧嬪�硷紝鍥犱负deviceType鍜宒eviceCode涔熸湁榛樿鍒濆鍊�
+            this.formSearch.timeArray = [
+              new Date(nV.startTime),
+              new Date(nV.endTime)
+            ];
+            this.dateRange = [new Date(nV.startTime), new Date(nV.endTime)];
+            this.formSearch.deviceType = nV.deviceType;
+            this.formSearch.deviceCode = nV.deviceCode;
+            // 浠h〃棣栨杩涘叆鐣岄潰锛屾鏃惰嚜鍔ㄦ墽琛岄涓换鍔$殑鏁版嵁鏌ヨ鎿嶄綔
+            if (oV == undefined) {
               this.handleClick();
-            }, 500);
-          }
+            }
+          }, 500);
         });
       }
     }
diff --git a/src/constant/scene-types/options-jingan.js b/src/constant/scene-types/options-jingan.js
index f8cc40f..8e739b6 100644
--- a/src/constant/scene-types/options-jingan.js
+++ b/src/constant/scene-types/options-jingan.js
@@ -89,5 +89,9 @@
   {
     label: '甯傛帶鐐�',
     value: '20'
+  },
+  {
+    label: '灏忓井绔�',
+    value: '21'
   }
 ];
diff --git a/src/router/index.js b/src/router/index.js
index 770dcf5..47edf4f 100644
--- a/src/router/index.js
+++ b/src/router/index.js
@@ -6,7 +6,7 @@
   routes: [
     {
       path: '/',
-      redirect: '/index/underwaymix'
+      redirect: '/login'
     },
     // 鐧婚檰椤甸潰
     {
diff --git a/src/views/historymode/HistoryMode.vue b/src/views/historymode/HistoryMode.vue
index dc4a863..99b1303 100644
--- a/src/views/historymode/HistoryMode.vue
+++ b/src/views/historymode/HistoryMode.vue
@@ -4,17 +4,17 @@
       <SearchBar
         v-show="status == 0"
         :search-time="searchTime"
-        :loading="loading"
+        :loading="loading || thirdPartyLoading"
         @search="onSearch"
       ></SearchBar>
       <TrajectoryState v-show="status != 0" :status="status"></TrajectoryState>
-      <el-button
+      <!-- <el-button
         type="primary"
         class="p-events-auto el-button-custom"
         @click="handleClick"
       >
         鍒嗘瀽
-      </el-button>
+      </el-button> -->
     </el-row>
     <el-row class="m-t-2">
       <FactorRadio
@@ -74,6 +74,7 @@
 import { ElMessage } from 'element-plus';
 import { fetchHistoryData } from '@/utils/factor/data';
 import dataAnalysisApi from '@/api/dataAnalysisApi';
+import thirdPartyDataApi from '@/api/thirdPartyDataApi';
 import { mapStores } from 'pinia';
 import { useSceneStore } from '@/stores/scene';
 
@@ -108,7 +109,10 @@
       // 杞ㄨ抗鍔ㄧ敾鐘舵��
       status: 0,
       // 鏄惁椤甸潰宸茶烦杞�
-      isUnmounted: false
+      isUnmounted: false,
+      // 绗笁鏂规暟鎹幏鍙栨槸鍚﹀皾璇�
+      isFetchThirdParty: false,
+      thirdPartyLoading: false
     };
   },
   watch: {
@@ -236,9 +240,33 @@
           endTime,
           page,
           perPage: pageSize
-        }).then((res) => this.onFetchData(deviceType, res.data));
+        }).then((res) => {
+          this.onFetchData(deviceType, res.data);
+          if (
+            res.data.length == 0 &&
+            this.isFetchThirdParty != mission.missionCode
+          ) {
+            this.onThirdPartyFetch(option);
+          }
+        });
       });
     },
+    onThirdPartyFetch(option) {
+      const { mission } = option;
+      if (import.meta.env.VITE_DATA_MODE == 'jingan') {
+        this.thirdPartyLoading = true;
+        this.isFetchThirdParty = mission.missionCode;
+        // 閫氱煡鏈嶅姟绔惎鍔ㄤ换鍔¤寖鍥村唴鐨勭涓夋柟鏁版嵁鑾峰彇浠诲姟
+        thirdPartyDataApi
+          .fetchMissionData(mission.missionCode)
+          .then((res) => {
+            if (res.data) {
+              this.onSearch(option);
+            }
+          })
+          .finally(() => (this.thirdPartyLoading = false));
+      }
+    },
     handleClick() {
       const { missionCode } = this.mission;
       dataAnalysisApi.pollutionTrace(missionCode).then((res) => {
diff --git a/src/views/realtimemode/RealtimeMode.vue b/src/views/realtimemode/RealtimeMode.vue
index 86b798a..41e5d4e 100644
--- a/src/views/realtimemode/RealtimeMode.vue
+++ b/src/views/realtimemode/RealtimeMode.vue
@@ -48,7 +48,8 @@
 // const mapAnimation = new MapAnimation();
 
 // 璋冭瘯妯″紡
-const mode = 'debug';
+// const mode = 'debug';
+const mode = 'product';
 
 export default {
   components: { DashBoard, RealTimeTrend, DeviceChange, SourceTrace },

--
Gitblit v1.9.3