tableMixin.js 1.52 KB
import { mapGetters } from 'vuex'
// 引入详情弹框
import dataDetails from "@/components/EditDialog";
let mixin = {
  data () {
    return {
      title: '',
      formData: {
        pageSize: 10
      }
    }
  },
  components: {
    dataDetails,
  },
  computed: {
    ...mapGetters(['dicData'])
  },
  created () {
    this.featchData()
  },
  methods: {
    // 表格索引得问题
    indexMethod (index) {
      return index + 1 + (this.form.currentPage - 1) * this.formData.pageSize;
    },
    handleSizeChange (val) {
      this.formData.pageSize = val
      this.featchData()
    },
    handleCurrentChange (val) {
      this.form.currentPage = val
      this.featchData()
    },
    handleSubmit () {
      this.tableData.data = []
      this.featchData()
    },
    // 详情
    handleEdit (row) {
      let Title = ''
      this.dicData['A21'].map(item => {
        if (item.DCODE == row.DJLX || item.DCODE == row.djlx) {
          Title = item.DNAME
          return
        }
      })

      this.dicData['A8'].map(item => {
        if (item.DCODE == row.QLLX || item.DCODE == row.qllx) {
          Title += '-' + item.DNAME
          return
        }
      })
      this.title = Title
      this.$refs.editLog.isShow(row);
    },
    // // 重置表单
    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()
    }
  }
}
export default mixin