<template>
  <div class="Tables">
    <div class="table-item">
      <el-table
        v-loading="tableLoading"
        :data="tableData"
        element-loading-text="Loading"
        border
        fit
        highlight-current-row
        @sort-change="sortChange"
      >
        <el-table-column
          v-if="isIndex"
          label="序号"
          width="50"
          align="left"
          :fixed="indexFixed"
          :resizable="false">
          <template slot-scope="scope">{{ queryParams.pageNum * queryParams.pageSize - queryParams.pageSize + scope.$index + 1 }}</template>
        </el-table-column>
        <template v-for="item in forData">
          <el-table-column
            v-if="item.slot"
            :label="item.label"
            :prop="item.prop"
            :width="item.width"
            align="left"
            :fixed="item.fixed"
            :sortable="item.sortable"
            :resizable="false">
              <template slot-scope="scope">
                <slot :name="item.prop" :row="item" :index="scope.$index" :data="scope.row.punishReason"></slot>
              </template>
          </el-table-column>
          <el-table-column
            v-else
            :label="item.label"
            :prop="item.prop"
            :width="item.width"
            align="left"
            :fixed="item.fixed"
            :sortable="item.sortable"
            :resizable="false" />
        </template>
      </el-table>
    </div>
    <div class="pagination-box">
      <el-pagination background :current-page="queryParams.pageNum" :page-size="queryParams.pageSize" :total="tableDataTotal" layout="prev, pager, next, jumper" @current-change="handleCurrentChange" @size-change="handleSizeChange" />
    </div>
  </div>
</template>

<script>
export default {
  name: "Tables",
  props: {
    isIndex: {
      type: Boolean,
      default: true
    },
    indexFixed: {
      type: Boolean,
      default: false
    },
    tableLoading: {
      type: Boolean,
      default: false
    },
    tableData: {
      type: Array,
      default: []
    },
    forData: {
      type: Array,
      default: []
    },
    tableDataTotal: {
      type: Number,
      default: 0
    },
    queryParams: {
      type: Object,
      default: {}
    },
  },
  data() {
    return {

    }
  },
  methods:{
    handleCurrentChange(e){
      this.$emit('handle-current-change',e)
    },
    handleSizeChange(e){
      this.$emit('handle-current-change',e)
    },
    sortChange(e){
      this.$emit('sort-change',e)
    }
  }
}
</script>

<style lang="scss" scoped>

</style>
