Browse Source

ChartCell 列表不刷新问题修改。

周壕 1 year ago
parent
commit
223f5bfddc
1 changed files with 25 additions and 5 deletions
  1. 25 5
      vue/src/components/basic/chart/chart-cell.vue

+ 25 - 5
vue/src/components/basic/chart/chart-cell.vue

@@ -10,7 +10,7 @@
 </template>
 
 <script lang="ts">
-  import {defineComponent, computed, markRaw} from 'vue';
+  import {defineComponent, computed, markRaw, watch} from 'vue';
   import * as echarts from "echarts";
   import {get} from '@/api/common';
 
@@ -29,7 +29,6 @@
         cell : null as any,
         chart : null as any,
         serieType : 'line',
-        id : Date.now(),
         hovered : false,
         datas : null
       }
@@ -46,17 +45,31 @@
       const wellId = computed(() => {
         return props.wellId ? props.wellId : null
       });
+      const id = computed(() => {
+        return wellId.value + "-" + dataType.value;
+      });
 
       return{
         timeType,
         dataType,
-        wellId
+        wellId,
+        id
       }
     },
     mounted(){
-      console.log("mounted" , this.id);
+      console.log("mounted chart-cell" , this.id);
       this.readerCell();
-      //this.readerChart();
+
+      watch(
+        () => this.id,
+        (n, o) => {
+          if(n!=o) {
+            console.log("wellId change",this.id, n, o);
+            this.chartDispose();
+            this.readerCell();
+          }
+        }
+      );
     },
     methods:{
       getDatas:async function(){
@@ -122,6 +135,13 @@
           this.chart.resize();
         }
       },
+      chartDispose:function (){
+        if(this.chart!=null) this.chart.dispose();
+        if(this.cell!=null) this.cell.dispose();
+        this.chart = null;
+        this.cell = null;
+        this.datas = null;
+      },
       onOpenChange:function(visible){
         console.log("onOpenChange", visible);
         if(visible) {