Blame view

src/mixins/tableMixin.js 1.85 KB
任超 committed
1
import { mapGetters } from 'vuex'
任超 committed
2
// 引入详情弹框
3
import dataDetails from "@/components/EditDialog";
任超 committed
4 5 6
let mixin = {
  data () {
    return {
任超 committed
7
      title: '',
任超 committed
8 9 10 11 12
      formData: {
        pageSize: 10
      }
    }
  },
任超 committed
13 14 15
  components: {
    dataDetails,
  },
任超 committed
16 17 18
  computed: {
    ...mapGetters(['dicData'])
  },
赵千 committed
19
  mounted () {
任超 committed
20
    this.handleSearch()
任超 committed
21 22 23 24 25 26 27 28 29 30
  },
  methods: {
    // 表格索引得问题
    indexMethod (index) {
      return index + 1 + (this.form.currentPage - 1) * this.formData.pageSize;
    },
    handleSizeChange (val) {
      this.formData.pageSize = val
      this.featchData()
    },
任超 committed
31 32 33 34 35 36 37 38 39 40
    handleSearch () {
      this.form.currentPage = 1
      this.tableData.data = []
      if (this.featchData) {
        this.featchData()
      }
      if (this.queryClick) {
        this.queryClick()
      }
    },
任超 committed
41 42 43 44 45
    handleCurrentChange (val) {
      this.form.currentPage = val
      this.featchData()
    },
    handleSubmit () {
任超 committed
46
      this.tableData.data = []
任超 committed
47
      this.featchData()
任超 committed
48 49 50
    },
    // 详情
    handleEdit (row) {
任超 committed
51 52 53 54 55 56 57 58 59 60
      if (row.rectypeName) {
        this.title = row.rectypeName
      } else {
        let Title = ''
        this.dicData['A21'].map(item => {
          if (item.DCODE == row.DJLX || item.DCODE == row.djlx) {
            Title = item.DNAME
            return
          }
        })
任超 committed
61

任超 committed
62 63 64 65 66 67 68 69
        this.dicData['A8'].map(item => {
          if (item.DCODE == row.QLLX || item.DCODE == row.qllx) {
            Title += '-' + item.DNAME
            return
          }
        })
        this.title = Title
      }
任超 committed
70
      this.$refs.editLog.isShow(row);
任超 committed
71
    },
任超 committed
72
    // 重置表单
任超 committed
73 74 75 76 77 78 79 80
    resetForm () {
      if (!this.form) return
      Object.keys(this.form).forEach((key) => {
        if (key !== 'currentPage') this.form[key] = '';
      })
      this.form.currentPage = 1
      this.tableData.data = []
      this.featchData()
任超 committed
81 82 83
    }
  }
}
赵千 committed
84
export default mixin