From f0cff349408ac3183b6dd2f3a264493fa0df45ca Mon Sep 17 00:00:00 2001
From: Xu Zhimeng <xuzhimeng@qq.com>
Date: Wed, 21 Feb 2024 14:38:22 +0800
Subject: [PATCH] =?UTF-8?q?fix:=20=E5=A4=84=E7=90=86=E6=8E=A5=E5=8F=A3?=
 =?UTF-8?q?=E6=9C=AA=E8=BF=94=E5=9B=9EnewEToC=E3=80=81newCToE=E3=80=81newL?=
 =?UTF-8?q?ineSeries=E6=97=B6=E5=AD=98=E5=9C=A8=E7=9A=84=E9=97=AE=E9=A2=98?=
 =?UTF-8?q?=EF=BC=8C=E5=A4=84=E7=90=86=E6=9C=AA=E9=94=80=E6=AF=81betaRefre?=
 =?UTF-8?q?sh=E4=BA=8B=E4=BB=B6=E7=9A=84=E9=97=AE=E9=A2=98?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 .../components/BetaDetectorCalibration.vue    | 38 +++++++++----------
 .../components/GammaDetectorCalibration.vue   | 38 +++++++++----------
 2 files changed, 35 insertions(+), 41 deletions(-)

diff --git a/src/views/spectrumAnalysis/components/Modals/BetaGammaModals/BetaGammaEnergyCalibrationModal/components/BetaDetectorCalibration.vue b/src/views/spectrumAnalysis/components/Modals/BetaGammaModals/BetaGammaEnergyCalibrationModal/components/BetaDetectorCalibration.vue
index 2876da0..d547111 100644
--- a/src/views/spectrumAnalysis/components/Modals/BetaGammaModals/BetaGammaEnergyCalibrationModal/components/BetaDetectorCalibration.vue
+++ b/src/views/spectrumAnalysis/components/Modals/BetaGammaModals/BetaGammaEnergyCalibrationModal/components/BetaDetectorCalibration.vue
@@ -629,6 +629,10 @@ export default {
     this.$bus.$on('betaRefresh', this.getData)
     this.getData()
   },
+  destroyed() {
+    this.$bus.$off('betaRefresh', this.handleReset)
+    this.$bus.$off('betaRefresh', this.getData)
+  },
   watch: {
     isFirstFitting: {
       handler() {
@@ -702,18 +706,10 @@ export default {
            * 对人工交互的返回数据单独处理
            */
           if (this.sampleData.dbName == 'man') {
+            const result = res.result
+            result.EToC = newEToC || []
+            result.CToE = newCToE
             this.setFirringResult(res.result)
-            if (newCToE) {
-              const [paramA, paramB, paramC] = newCToE
-              this.newCalibrationFuncModel = {
-                paramA: Number(paramA).toPrecision(6),
-                paramB: Number(paramB).toPrecision(6),
-                paramC: Number(paramC).toPrecision(6),
-              }
-            }
-            if (newEToC) {
-              this.newE2C = newEToC
-            }
           }
         } else {
           this.$message.error(res.message)
@@ -1009,21 +1005,23 @@ export default {
           paramC: Number(paramC).toPrecision(6),
         }
       }
+      if (newLineSeries) {
+        const energyValues = newLineSeries.map((item) => item.y)
 
-      const energyValues = newLineSeries.map((item) => item.y)
+        const { max: prevMax, min: prevMin } = this.oldChartOption.yAxis
 
-      const { max: prevMax, min: prevMin } = this.oldChartOption.yAxis
+        const energyMax = Math.max(Math.max(...energyValues), prevMax)
+        const energyMin = Math.min(Math.min(...energyValues), prevMin)
 
-      const energyMax = Math.max(Math.max(...energyValues), prevMax)
-      const energyMin = Math.min(Math.min(...energyValues), prevMin)
+        const { min, max, interval } = splitAxis(energyMax, energyMin, 4)
 
-      const { min, max, interval } = splitAxis(energyMax, energyMin, 4)
+        this.figureChartOption.yAxis.max = max
+        this.figureChartOption.yAxis.min = min
+        this.figureChartOption.yAxis.interval = interval
 
-      this.figureChartOption.yAxis.max = max
-      this.figureChartOption.yAxis.min = min
-      this.figureChartOption.yAxis.interval = interval
+        this.figureChartOption.series[1].data = newLineSeries.map(({ x, y }) => [x, y])
+      }
 
-      this.figureChartOption.series[1].data = newLineSeries.map(({ x, y }) => [x, y])
       if (newScatterSeriesData) {
         this.figureChartOption.series[1].markPoint.data = newScatterSeriesData.map(({ x, y }) => {
           return {
diff --git a/src/views/spectrumAnalysis/components/Modals/BetaGammaModals/BetaGammaEnergyCalibrationModal/components/GammaDetectorCalibration.vue b/src/views/spectrumAnalysis/components/Modals/BetaGammaModals/BetaGammaEnergyCalibrationModal/components/GammaDetectorCalibration.vue
index 3dae514..9fe21dd 100644
--- a/src/views/spectrumAnalysis/components/Modals/BetaGammaModals/BetaGammaEnergyCalibrationModal/components/GammaDetectorCalibration.vue
+++ b/src/views/spectrumAnalysis/components/Modals/BetaGammaModals/BetaGammaEnergyCalibrationModal/components/GammaDetectorCalibration.vue
@@ -554,18 +554,10 @@ export default {
            * 对人工交互的返回数据单独处理
            */
           if (this.sampleData.dbName == 'man') {
-            this.setFirringResult(res.result)
-            if (newCToE) {
-              const [paramA, paramB, paramC] = newCToE
-              this.newCalibrationFuncModel = {
-                paramA: Number(paramA).toPrecision(6),
-                paramB: Number(paramB).toPrecision(6),
-                paramC: Number(paramC).toPrecision(6),
-              }
-            }
-            if (newEToC) {
-              this.newE2C = newEToC
-            }
+            const result = res.result
+            result.EToC = newEToC || []
+            result.CToE = newCToE
+            this.setFirringResult(result)
           }
         } else {
           this.$message.error(res.message)
@@ -768,20 +760,24 @@ export default {
           paramC: Number(paramC).toPrecision(6),
         }
       }
-      const energyValues = newLineSeries.map((item) => item.y)
 
-      const { max: prevMax, min: prevMin } = this.oldChartOption.yAxis
+      if (newLineSeries) {
+        const energyValues = newLineSeries.map((item) => item.y)
 
-      const energyMax = Math.max(Math.max(...energyValues), prevMax)
-      const energyMin = Math.min(Math.min(...energyValues), prevMin)
+        const { max: prevMax, min: prevMin } = this.oldChartOption.yAxis
 
-      const { min, max, interval } = splitAxis(energyMax, energyMin, 4)
+        const energyMax = Math.max(Math.max(...energyValues), prevMax)
+        const energyMin = Math.min(Math.min(...energyValues), prevMin)
 
-      this.figureChartOption.yAxis.max = max
-      this.figureChartOption.yAxis.min = min
-      this.figureChartOption.yAxis.interval = interval
+        const { min, max, interval } = splitAxis(energyMax, energyMin, 4)
+
+        this.figureChartOption.yAxis.max = max
+        this.figureChartOption.yAxis.min = min
+        this.figureChartOption.yAxis.interval = interval
+
+        this.figureChartOption.series[1].data = newLineSeries.map(({ x, y }) => [x, y])
+      }
 
-      this.figureChartOption.series[1].data = newLineSeries.map(({ x, y }) => [x, y])
       if (newScatterSeriesData) {
         this.figureChartOption.series[1].markPoint.data = newScatterSeriesData.map(({ x, y }) => ({
           xAxis: x,