guhongwei 4 年之前
父節點
當前提交
20175a9e09
共有 1 個文件被更改,包括 27 次插入1 次删除
  1. 27 1
      src/views/test/dialogs.vue

+ 27 - 1
src/views/test/dialogs.vue

@@ -18,6 +18,17 @@
                 </template>
               </el-table-column>
             </el-table>
+            <el-col :span="24" class="page">
+              <el-pagination
+                background
+                @current-change="handleCurrentChange"
+                :current-page="currentPage"
+                layout="total,  prev, pager, next, jumper"
+                :total="total"
+                :page-size="pageSize"
+              >
+              </el-pagination>
+            </el-col>
           </el-col>
         </el-col>
       </el-col>
@@ -60,8 +71,12 @@ export default {
   data: function() {
     return {
       list: [],
+      total: 0,
       dialogFormVisible: false,
       form: {},
+      currentPage: 0,
+      pageSize: 10,
+      skip: '',
     };
   },
   created() {
@@ -71,9 +86,11 @@ export default {
     ...lunbo(['query', 'fetch', 'create', 'update', 'delete']),
     // 查询列表
     async search({ skip = 0, limit = 10, ...info } = {}) {
+      skip = this.skip;
       let res = await this.query({ skip, limit, ...info });
       if (this.$checkRes(res)) {
         this.$set(this, `list`, res.data);
+        this.$set(this, `total`, res.total);
       }
     },
     // 提交
@@ -124,6 +141,10 @@ export default {
     uploadSuccess({ type, data }) {
       this.$set(this.form, `${type}`, data.uri);
     },
+    handleCurrentChange(currentPage) {
+      this.$set(this, `skip`, (currentPage - 1) * this.pageSize);
+      this.search();
+    },
   },
   computed: {
     ...mapState(['user']),
@@ -131,4 +152,9 @@ export default {
 };
 </script>
 
-<style lang="less" scoped></style>
+<style lang="less" scoped>
+.page {
+  text-align: center;
+  margin: 15px 0;
+}
+</style>