Sfoglia il codice sorgente

feat: auto refresh

Casper Dai 2 anni fa
parent
commit
db9b3dc109

+ 16 - 1
src/views/external/camera/snap/index.vue

@@ -155,7 +155,7 @@ export default {
     },
     snapSchema () {
       return {
-        list: getSnapPicResults,
+        list: this.getSnapPicResults,
         condition: { cameraId: this.cameraId },
         cols: [
           { prop: 'file', type: 'asset', on: this.onViewAsset, refresh: true },
@@ -181,6 +181,12 @@ export default {
       }
     }
   },
+  created () {
+    this.$timer = -1
+  },
+  beforeDestroy () {
+    clearTimeout(this.$timer)
+  },
   methods: {
     onEditRemark (camera, { newVal, oldVal }) {
       if (newVal === oldVal) {
@@ -238,6 +244,15 @@ export default {
       this.cameraId = camera.id
       this.$refs.resultDialog.show()
     },
+    getSnapPicResults (params) {
+      clearTimeout(this.$timer)
+      if (params.pageNum === 1) {
+        this.$timer = setTimeout(() => {
+          this.$refs.resultDialog?.getTable()?.refreshCurrentPageOnBackground()
+        }, 10000)
+      }
+      return getSnapPicResults(params)
+    },
     onViewAsset ({ file }) {
       this.$refs.previewDialog.show(file)
     }

+ 12 - 0
src/views/realm/ai/ai-timing/index.vue

@@ -87,8 +87,20 @@ export default {
       }
     }
   },
+  created () {
+    this.$timer = -1
+  },
+  beforeDestroy () {
+    clearTimeout(this.$timer)
+  },
   methods: {
     getHistory (params) {
+      clearTimeout(this.$timer)
+      if (params.pageNum === 1) {
+        this.$timer = setTimeout(() => {
+          this.$refs.historyDialog?.getTable()?.refreshCurrentPageOnBackground()
+        }, 10000)
+      }
       return getHistory({
         deviceId: this.device ? this.device.id : void 0,
         ...params