Blame view

src/utils/mixin/table.js 1.08 KB
任超 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
  created () {
任超 committed
15 16 17
    if (this.fetchData) {
      this.fetchData()
    }
任超 committed
18
  },
任超 committed
19 20
  methods: {
    handleSizeChange (val) {
任超 committed
21
      this.pageData.currentPage = 1
任超 committed
22
      this.pageData.pageSize = val
任超 committed
23
      this.queryClick()
任超 committed
24 25
    },
    handleCurrentChange (val) {
任超 committed
26
      this.pageData.currentPage = val
任超 committed
27 28 29
      if (this.fetchData) {
        this.fetchData()
      }
任超 committed
30
      console.log('this.queryClick,', this.queryClick, 'this.fetchData', this.fetchData);
任超 committed
31 32 33
      if (this.queryClick) {
        this.queryClick()
      }
任超 committed
34
      console.log(val, this.pageData.currentPage, 'this.pageDatathis.pageData');
任超 committed
35 36 37 38 39
    },
    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
40
    }
任超 committed
41 42
  }
}