Purpose 9 months ago
parent
commit
e81ce2ae33
1 changed files with 7 additions and 4 deletions
  1. 7 4
      src/utils/BaseCurdList.js

+ 7 - 4
src/utils/BaseCurdList.js

@@ -16,6 +16,11 @@ export default (target, hasPagination = true) => ({
     total: 0
   }),
   methods: {
+    afterLoadList () {
+      setTimeout(() => {
+        this.$refs.table && this.$refs.table.doLayout()
+      }, 0)
+    },
     loadList () {
       let query = Object.assign({}, this.query)
       if (hasPagination) {
@@ -24,15 +29,13 @@ export default (target, hasPagination = true) => ({
           .then(data => {
             this.total = data.count
             this.data = Object.freeze(bindPrototype(data.list, target))
-            setTimeout(() => {
-              this.$refs.table && this.$refs.table.doLayout()
-            }, 0)
+            this.afterLoadList()
           }).catch(console.error).finally(() => {})
       } else {
         this.$$request(target.$$api.getList, this.query).then(list => {
           this.total = list.length
           this.data = Object.freeze(bindPrototype(Object.freeze(list), target))
-          this.$refs.table && this.$refs.table.doLayout()
+          this.afterLoadList()
         }).catch(console.error).finally(() => {})
       }
     },