Blame view

src/utils/mixin/table.js 2.07 KB
1 2 3 4 5
/*
 * @Description: 
 * @Autor: renchao
 * @LastEditTime: 2023-11-14 13:28:47
 */
任超 committed
6
import { mapGetters } from 'vuex'
7
import { defaultParameters } from "../../views/ywbl/ywsq/javascript/publicDefaultPar";
任超 committed
8
export default {
任超 committed
9 10 11 12 13 14 15 16
  data () {
    return {
      pageData: {
        currentPage: 1,
        pageSize: 10
      }
    }
  },
任超 committed
17 18 19
  computed: {
    ...mapGetters(['dictData']),
  },
任超 committed
20
  mounted () {
xiaomiao committed
21
    window.addEventListener('keydown', this.handkeyCode, true)//开启监听键盘按下事件
yangwei committed
22
    this.handleSearch()
任超 committed
23
  },
任超 committed
24
  methods: {
yuanbo committed
25 26 27 28 29
    /**
     * @description: handkeyCode
     * @param {*} e
     * @author: renchao
     */
30 31
    handkeyCode (e) {
      if (e.keyCode === 13) {
xiaomiao committed
32 33
        this.handleSearch()
      }
34
    },
yuanbo committed
35 36 37 38
    /**
     * @description: handleSearch
     * @author: renchao
     */
39
    handleSearch () {
yangwei committed
40 41 42 43 44 45 46 47
      this.pageData.currentPage = 1
      if (this.fetchData) {
        this.fetchData()
      }
      if (this.queryClick) {
        this.queryClick()
      }
    },
yuanbo committed
48 49 50 51 52
    /**
     * @description: handleSizeChange
     * @param {*} val
     * @author: renchao
     */
任超 committed
53
    handleSizeChange (val) {
任超 committed
54
      this.pageData.currentPage = 1
任超 committed
55
      this.pageData.pageSize = val
任超 committed
56
      this.queryClick()
任超 committed
57
    },
yuanbo committed
58 59 60 61 62
    /**
     * @description: handleCurrentChange
     * @param {*} val
     * @author: renchao
     */
任超 committed
63
    handleCurrentChange (val) {
任超 committed
64
      this.pageData.currentPage = val
任超 committed
65 66 67
      if (this.queryClick) {
        this.queryClick()
      }
任超 committed
68
    },
yuanbo committed
69 70 71 72
    /**
     * @description: handleDel
     * @author: renchao
     */
任超 committed
73 74 75 76
    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
77
    },
yuanbo committed
78 79 80 81 82
    /**
     * @description: resetForm
     * @param {*} isYwbl
     * @author: renchao
     */
83
    resetForm (isYwbl) {
84 85 86 87 88
      if (isYwbl) {
        this.queryForm = defaultParameters.defaultParameters();
        this.pageData.currentPage = 1;
        this.queryClick()
      }
任超 committed
89
    }
任超 committed
90 91
  }
}