From 08ffcf9d7ffafaa82d8de7f9b5fcfdb49e9c3688 Mon Sep 17 00:00:00 2001
From: riku <risaku@163.com>
Date: 星期三, 05 十一月 2025 17:33:54 +0800
Subject: [PATCH] 动态溯源 1. 修复CO因子文本没有正常显示的问题;

---
 src/views/sourcetrace/SourceTrace.vue |   98 +++++++++++++++++++++++++++++++++++-------------
 1 files changed, 71 insertions(+), 27 deletions(-)

diff --git a/src/views/sourcetrace/SourceTrace.vue b/src/views/sourcetrace/SourceTrace.vue
index 2ef9353..5c738de 100644
--- a/src/views/sourcetrace/SourceTrace.vue
+++ b/src/views/sourcetrace/SourceTrace.vue
@@ -200,7 +200,10 @@
         }
 
         // 鍒ゆ柇鍦烘櫙绫诲瀷鏄惁閫変腑
-        if (v.pollutedSource.sceneList.length == 0) {
+        if (
+          v.pollutedSource == undefined ||
+          v.pollutedSource.sceneList.length == 0
+        ) {
           b3 = selectedSceneTypes.value.indexOf(NO_SCENE) != -1;
         } else {
           b3 =
@@ -229,15 +232,44 @@
     type3: 0
   };
   streams.value.forEach((v) => {
+    let b2, b3;
+    // 鍒ゆ柇鐩戞祴鍥犲瓙绫诲瀷鏄惁閫変腑
+    for (const key in v.pollutedData.statisticMap) {
+      const value = v.pollutedData.statisticMap[key];
+      b2 = b2 || selectedFactorTypes.value.indexOf(value.factorId) != -1;
+    }
+
+    // 鍒ゆ柇鍦烘櫙绫诲瀷鏄惁閫変腑
+    if (
+      v.pollutedSource == undefined ||
+      v.pollutedSource.sceneList.length == 0
+    ) {
+      b3 = selectedSceneTypes.value.indexOf(NO_SCENE) != -1;
+    } else {
+      b3 =
+        v.pollutedSource.sceneList.findIndex(
+          (v) => selectedSceneTypes.value.indexOf(v.typeId) != -1
+        ) != -1;
+    }
     switch (v._type) {
       case '1':
-        count.type1++;
+        if (b2 && b3) {
+          count.type1++;
+        }
         break;
       case '2':
-        count.type2++;
+        b3 =
+          v.sortedSceneList.findIndex(
+            (v) => selectedSceneTypes.value.indexOf(v.first.typeId) != -1
+          ) != -1;
+        if (b3) {
+          count.type2++;
+        }
         break;
       case '3':
-        count.type3++;
+        if (b2 && b3) {
+          count.type3++;
+        }
         break;
     }
   });
@@ -306,25 +338,29 @@
       }
 
       // 绛涢�夊満鏅被鍨�
-      if (objData.pollutedSource.sceneList.length == 0) {
-        // 鑻ユ病鏈夋壘鍒伴闄╂簮鏃讹紝灏嗚鍒嗙被璁惧畾涓簄ull
-        if (sceneOptions.value.findIndex((v) => v.value == NO_SCENE) == -1) {
-          sceneOptions.value.push({
-            label: '鏈煡',
-            value: NO_SCENE
-          });
-          selectedSceneTypes.value.push(NO_SCENE);
-        }
-      } else {
-        objData.pollutedSource.sceneList.forEach((s) => {
-          if (sceneOptions.value.findIndex((v) => v.value == s.typeId) == -1) {
+      if (objData.pollutedSource != undefined) {
+        if (objData.pollutedSource.sceneList.length == 0) {
+          // 鑻ユ病鏈夋壘鍒伴闄╂簮鏃讹紝灏嗚鍒嗙被璁惧畾涓簄ull
+          if (sceneOptions.value.findIndex((v) => v.value == NO_SCENE) == -1) {
             sceneOptions.value.push({
-              label: s.type,
-              value: s.typeId
+              label: '鏈煡',
+              value: NO_SCENE
             });
-            selectedSceneTypes.value.push(s.typeId);
+            selectedSceneTypes.value.push(NO_SCENE);
           }
-        });
+        } else {
+          objData.pollutedSource.sceneList.forEach((s) => {
+            if (
+              sceneOptions.value.findIndex((v) => v.value == s.typeId) == -1
+            ) {
+              sceneOptions.value.push({
+                label: s.type,
+                value: s.typeId
+              });
+              selectedSceneTypes.value.push(s.typeId);
+            }
+          });
+        }
       }
     // case '2':
     //   break;
@@ -355,6 +391,10 @@
   dataAnalysisApi
     .fetchPollutionTraceHistory(props.missionCode)
     .then((res) => {
+      factorOptions.value = [];
+      selectedFactorTypes.value = [];
+      sceneOptions.value = [];
+      selectedSceneTypes.value = [];
       const objList = JSON.parse(res.data);
       objList.forEach((obj) => {
         obj._type = obj.msgType + '';
@@ -499,13 +539,17 @@
   factorDatas.setData(obj.pollutedData.historyDataList, 0, () => {
     for (const key in obj.pollutedData.statisticMap) {
       const value = obj.pollutedData.statisticMap[key];
-      value._chartOptions = factorDataParser.parseData(factorDatas, [
-        {
-          label: value.factorName,
-          name: value.factorName,
-          value: value.factorId + ''
-        }
-      ]);
+      value._chartOptions = factorDataParser.parseData(
+        factorDatas,
+        [
+          {
+            label: value.factorName,
+            name: value.factorName,
+            value: value.factorId + ''
+          }
+        ],
+        false
+      );
     }
     // obj._chartOptions = factorDataParser.parseData(factorDatas, [
     //   {

--
Gitblit v1.9.3