Procházet zdrojové kódy

陆运首页新增定时刷新数据

caojunjie před 3 roky
rodič
revize
cdd176905a

+ 10 - 1
src/views/wel/home/landTransportation/components/sales-reached.vue

@@ -36,6 +36,7 @@ export default {
     return {
       loading: false,
       tradeType: null,
+      entrustTimer: null,
       tableData: []
     };
   },
@@ -43,7 +44,15 @@ export default {
     this.getSysType();
   },
   mounted() {
-    this.getSysType();
+    let this_ = this
+    this_.entrustTimer = setInterval(function () {
+      if (JSON.parse(localStorage.getItem("saber-token")).content) {
+        this_.getSysType();
+      }
+    }, 60000)
+  },
+  beforeDestroy() {
+    clearInterval(this.entrustTimer); //关闭
   },
   methods: {
     //点击获取图表数据

+ 9 - 1
src/views/wel/home/landTransportation/components/sales-trend.vue

@@ -60,6 +60,7 @@ export default {
   },
   data() {
     return {
+      entrustTimer:null,
       roleName: localStorage.getItem("roleName").split(','),
       dialogVisible: false,
       loading: false,
@@ -287,6 +288,7 @@ export default {
   },
   beforeDestroy() {
     this.map && this.map.destroy();
+    clearInterval(this.entrustTimer); //关闭
   },
   methods: {
     //自定义列保存
@@ -503,6 +505,12 @@ export default {
     },
     init() {
       this.getsalesTrend();
+      let this_ = this
+      this_.entrustTimer = setInterval(function () {
+        if (JSON.parse(localStorage.getItem("saber-token")).content) {
+          this_.getsalesTrend();
+        }
+      }, 60000)
     },
     query(data) {
       this.getsalesTrend(data)
@@ -518,7 +526,7 @@ export default {
       if (val) return val.replace(/\n/g, '<br/>')
     },
     refresh() {
-      this.init()
+      this.getsalesTrend()
     }
   }
 };