<template>
  <div class="pagination-box">
    <el-pagination
      hide-on-single-page
      @current-change="handleCurrentChange"
      :current-page="currentPage"
      :page-size="pageSize"
      layout="total, prev, pager, next"
      :total="total">
    </el-pagination>
  </div>
</template>
<script>
export default {
  components: {},
  props: {
    total: { type: Number, default: 0 },
    pageSize: { type: Number, default: 20 }
  },
  data() {
    return {
      currentPage: 1
    };
  },
  computed: {},
  mounted() {},
  methods: {
    handleCurrentChange(e) {
      // this.currentPage = e > 0 ? e - 1 : 0;
      this.$emit('query', { paging: { page: e > 0 ? e - 1 : 0, size: this.pageSize } });
    },
    resetPage(e) {
      if (e == -1) {
        this.currentPage = 0;
      } else {
        this.currentPage = Math.ceil(this.total / this.pageSize);
      }
      this.$emit('query', { page: this.currentPage, size: this.pageSize });
    }
  }
};
</script>
<style lang="scss" scoped>
.pagination-box {
  margin-top: 10px;
  .el-pagination {
    ::v-deep .btn-prev {
      background: none !important;
    }
    ::v-deep .btn-next {
      background: none !important;
    }
    ::v-deep .el-pager li {
      background: none !important;
    }
  }
}
</style>
