Browse Source

feat(table): support pagination configuration

Casper Dai 3 years ago
parent
commit
e517a56c68

+ 1 - 0
src/components/table/GridTable/index.vue

@@ -84,6 +84,7 @@
         :total="options.totalCount"
         :page.sync="options.params.pageNum"
         :limit.sync="options.params.pageSize"
+        v-bind="paginationConfig"
         @pagination="onPagination"
       />
     </template>

+ 9 - 3
src/components/table/Pagination/index.vue

@@ -3,9 +3,8 @@
     <el-pagination
       :current-page.sync="currentPage"
       :page-size="limit"
-      :pager-count="5"
       :total="Number(total)"
-      layout="total,prev,pager,next,jumper"
+      :layout="layout"
       background
       hide-on-single-page
       v-bind="$attrs"
@@ -24,11 +23,15 @@ export default {
     },
     page: {
       type: Number,
-      default: 1
+      default: 10
     },
     limit: {
       type: Number,
       default: 20
+    },
+    layout: {
+      type: String,
+      default: 'total,prev,pager,next,jumper'
     }
   },
   computed: {
@@ -41,6 +44,9 @@ export default {
       }
     }
   },
+  created () {
+    console.log(this.$attrs)
+  },
   methods: {
     onCurrentChange (val) {
       this.$emit('pagination', { page: val, limit: this.limit })

+ 1 - 0
src/components/table/Table/index.vue

@@ -97,6 +97,7 @@
         :total="options.totalCount"
         :page.sync="options.params.pageNum"
         :limit.sync="options.params.pageSize"
+        v-bind="paginationConfig"
         @pagination="onPagination"
       />
     </slot>

+ 4 - 0
src/components/table/mixins/table.js

@@ -9,6 +9,7 @@ const ButtonConfig = {
 // {
 //   keepalive?: false,
 //   singlePage?: false,
+//   pagination?: Object,
 //   condition?: Object,
 //   list: Function,
 //   transform?: Function
@@ -69,6 +70,9 @@ export default {
     },
     isManualPagination () {
       return this.schema.singlePage
+    },
+    paginationConfig () {
+      return this.schema.pagination
     }
   },
   watch: {