Blame view

src/utils/mixin/table.js 2.09 KB
1 2 3
/*
 * @Description: 
 * @Autor: renchao
4
 * @LastEditTime: 2023-10-30 09:01:21
5
 */
任超 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 34
        console.log("安");
        this.handleSearch()
      }
35
    },
yuanbo committed
36 37 38 39
    /**
     * @description: handleSearch
     * @author: renchao
     */
40
    handleSearch () {
yangwei committed
41 42 43 44 45 46 47 48
      this.pageData.currentPage = 1
      if (this.fetchData) {
        this.fetchData()
      }
      if (this.queryClick) {
        this.queryClick()
      }
    },
yuanbo committed
49 50 51 52 53
    /**
     * @description: handleSizeChange
     * @param {*} val
     * @author: renchao
     */
任超 committed
54
    handleSizeChange (val) {
任超 committed
55
      this.pageData.currentPage = 1
任超 committed
56
      this.pageData.pageSize = val
任超 committed
57
      this.queryClick()
任超 committed
58
    },
yuanbo committed
59 60 61 62 63
    /**
     * @description: handleCurrentChange
     * @param {*} val
     * @author: renchao
     */
任超 committed
64
    handleCurrentChange (val) {
任超 committed
65
      this.pageData.currentPage = val
任超 committed
66 67 68
      if (this.queryClick) {
        this.queryClick()
      }
任超 committed
69
    },
yuanbo committed
70 71 72 73
    /**
     * @description: handleDel
     * @author: renchao
     */
任超 committed
74 75 76 77
    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
78
    },
yuanbo committed
79 80 81 82 83
    /**
     * @description: resetForm
     * @param {*} isYwbl
     * @author: renchao
     */
84
    resetForm (isYwbl) {
85 86 87 88 89
      if (isYwbl) {
        this.queryForm = defaultParameters.defaultParameters();
        this.pageData.currentPage = 1;
        this.queryClick()
      }
任超 committed
90
    }
任超 committed
91 92
  }
}