<template>
  <div class="pagination-wrapper">
    <el-pagination
      @size-change="sizeChange"
      @current-change="currentChange"
      :current-page="pageData.page"
      :page-size="pageData.pageSize"
      :page-sizes="pageSizeList"
      :layout="paginationLayout"
      :prev-text="$t('default.prev')"
      :next-text="$t('default.next')"
      :total="pageData.total"></el-pagination>
  </div>
</template>

<script>
import { mapGetters } from 'vuex'

export default {
  name: 'Pagination',
  data () {
    return {
      pageSizeList: this.$store.state.app.default.pageSizeList
    }
  },
  props: {
    pageData: {
      type: Object,
      default: function () {
        return {
          page: 1,
          pageSize: 15,
          total: 0
        }
      }
    },
    sizeChange: {
      type: Function
    },
    currentChange: {
      type: Function
    }
  },
  computed: {
    ...mapGetters([
      'device'
    ]),
    paginationLayout () {
      if (this.device === 'desktop') { return 'total, sizes, prev, pager, next, jumper' }
      return 'total,prev,next'
    }
  }
}
</script>

<style scoped>

</style>
