Quellcode durchsuchen

工作台定时刷新功能

user5 vor 2 Jahren
Ursprung
Commit
2db213d16b
1 geänderte Dateien mit 24 neuen und 2 gelöschten Zeilen
  1. 24 2
      src/views/modules/sys/dashboard/workBench/Pending.vue

+ 24 - 2
src/views/modules/sys/dashboard/workBench/Pending.vue

@@ -29,6 +29,7 @@
               <span>我的待办({{tablePage.total}})</span>
 
               <div style="float:right;align-items:center;display:flex;height: 18px">
+                <el-button type="text" style="float:right" @click="resetSearch()">刷新</el-button>
                 <el-button type="text" style="float:right" @click="toPendingList()">更多>></el-button>
 
               </div>
@@ -305,7 +306,8 @@
         loading2: false,
         visible: false,
         currentTask: null,
-        processInstanceId: ''
+        processInstanceId: '',
+        timer: null
         // pickerOptions: {
         //   shortcuts: [{
         //     text: '最近一周',
@@ -353,7 +355,23 @@
     },
     // watch: {
     // },
+    mounted () {
+      // 页面加载后
+      // 1.在执行定时器前先执行一次获取接口数据的操作函数, 否则接口会1秒钟后才调用
+      // 2.为了避免退出当前页面后,在其他页面也继续调用接口,退出前需要清除定时器.
+      this.queryInfo()
+      this.timer = setInterval(() => {
+        setTimeout(this.queryInfo, 0)
+      }, 60000)
+    },
+    beforeDestroy () {
+      clearInterval(this.timer)
+      this.timer = null
+    },
     methods: {
+      queryInfo () {
+        this.refreshList()
+      },
       toNotice () {
         this.$router.push('/notify/MyNotifyList')
       },
@@ -370,9 +388,13 @@
           }
         })
       },
+      resetSearch () {
+        this.refreshList()
+      },
       // 获取数据列表
       refreshList () {
         this.loading = true
+        this.loading2 = true
         this.taskService.todoList({
           'current': this.tablePage.currentPage,
           'size': this.tablePage.pageSize,
@@ -392,7 +414,7 @@
         }).then(({data}) => {
           this.dataLists = data.records
           this.noticePage.total = data.total
-          this.loading = false
+          this.loading2 = false
         })
         this.noticeService.list({
           'current': this.noticePageList.currentPage,