Blame view

src/utils/mixin/table.js 798 Bytes
任超 committed
1
import { mapGetters } from 'vuex'
任超 committed
2
export default {
任超 committed
3 4 5 6 7 8 9 10
  data () {
    return {
      pageData: {
        currentPage: 1,
        pageSize: 10
      }
    }
  },
任超 committed
11 12 13
  computed: {
    ...mapGetters(['dictData']),
  },
任超 committed
14 15 16
  created () {
    this.fetchData()
  },
任超 committed
17 18
  methods: {
    handleSizeChange (val) {
任超 committed
19
      this.pageData.currentPage = 1
任超 committed
20 21
      this.pageData.pageSize = val
      this.fetchData()
任超 committed
22 23
    },
    handleCurrentChange (val) {
任超 committed
24 25
      this.pageData.currentPage = val
      this.fetchData()
任超 committed
26 27 28 29 30
    },
    handleDel () {
      let deleteAfterPage = Math.ceil((this.tableData.total - 1) / this.pageData.pageSize)
      let currentPage = this.pageData.currentPage > deleteAfterPage ? deleteAfterPage : this.pageData.currentPage
      this.pageData.currentPage = currentPage < 1 ? 1 : currentPage
任超 committed
31
    }
任超 committed
32 33
  }
}