Эх сурвалжийг харах

Merge branch 'dev1.1' of http://192.168.3.207:10080/jianyu/page_dataexport into dev1.1

cuiyalong 5 жил өмнө
parent
commit
8862e3f29f
1 өөрчлөгдсөн 14 нэмэгдсэн , 17 устгасан
  1. 14 17
      src/views/main/Home.vue

+ 14 - 17
src/views/main/Home.vue

@@ -111,7 +111,7 @@ export default class Home extends Vue {
     next()
   }
 
-  getReportList () {
+  getReportList (type = 'load') {
     this.listState.loading = true
     this.getList(`page_index=${this.listState.currentPage}`).then((res: any) => {
       if (res.error_code === 0 && res.data.list) {
@@ -126,6 +126,10 @@ export default class Home extends Vue {
           this.listState.finished = true
         }
         if (this.listState.currentPage === 1) {
+          if (type === 'refresh') {
+            this.isLoading = false
+            Toast('刷新成功')
+          }
           this.listState.list = rows
         } else {
           this.listState.list = this.listState.list.concat(rows)
@@ -148,22 +152,15 @@ export default class Home extends Vue {
   }
 
   onRefresh () {
-    setTimeout(() => {
-      this.isLoading = false
-      this.clearList()
-      this.$nextTick(() => {
-        this.listState = {
-          list: [],
-          loading: false,
-          finished: false,
-          currentPage: 1,
-          totalPage: 0,
-          scroll: 0
-        }
-        this.getReportList()
-        Toast('刷新成功')
-      })
-    }, 1000)
+    this.clearList(this.listState)
+    this.listState.loading = false
+    this.listState.finished = false
+    this.listState.currentPage = 1
+    this.listState.totalPage = 0
+    this.listState.scroll = 0
+    this.$nextTick(() => {
+      this.getReportList('refresh')
+    })
   }
 }
 </script>