<template>
  <div class="m20">
    <div class="header">
      <span> {{ title }} </span>
    </div>
    <el-table
      ref="multipleTable"
      v-loading="loading"
      :data="tableInfo.records"
      tooltip-effect="dark"
      style="width: 95%;margin:0 auto"
      :fit="true"
      :row-class-name="tableRowClassName"
      :header-cell-style="{background:'#8cc3fb',color:'#fff'}"
    >
      <el-table-column prop="index" label="序号" min-width="70" align="center">
        <template slot-scope="scope">
          {{ (pageParam.curPage - 1 ) * pageParam.pageSize + scope.$index + 1 }}
        </template>
      </el-table-column>
      <el-table-column prop="sid" label="奖惩措施编码" min-width="180" align="left" />
      <el-table-column prop="mdmc" label="奖惩名单名称" min-width="180" align="left" />
      <el-table-column prop="ztmc" label="主体名称" min-width="180" align="left" />
      <el-table-column prop="ztlb" label="主体类别" min-width="180" align="left" />
      <el-table-column prop="jclb" label="奖惩类型" min-width="100" align="left">
        <template slot-scope="scope">
          <span v-if="scope.row.jclb === '1'">惩戒</span>
          <span v-if="scope.row.jclb === '2'">激励</span>
          <span v-else>-</span>
        </template>
      </el-table-column>
      <el-table-column prop="tyshxydm" label="统一社会信用代码" min-width="180" align="left" />
      <el-table-column prop="qyzch" label="主体工商注册号" min-width="180" align="left" />
      <el-table-column prop="zzjgdm" label="主体组织机构代码" min-width="180" align="left" />
      <el-table-column prop="zjlx" label="主体证件类型" min-width="180" align="left" />
      <el-table-column prop="zjhm" label="证件号码" min-width="180" align="left" />
      <el-table-column prop="csnr" label="执行措施内容" show-overflow-tooltip min-width="180" align="left" />
      <el-table-column prop="sjje" label="涉及金额" min-width="180" align="left" />
      <el-table-column prop="jcsm" label="奖惩说明" show-overflow-tooltip min-width="180" align="left" />
      <el-table-column prop="qlbm" label="事项编码" min-width="180" align="left" />
      <el-table-column prop="qlmc" label="事项名称" min-width="180" align="left" />
      <el-table-column prop="cxcode" label="名单查询流水号" min-width="180" align="left" />
    </el-table>
    <div v-if="showPagination" class="page-box">
      <el-row>
        <el-col :span="18" :offset="6">
          <el-pagination
            :disabled="loading"
            :page-size="pageParam.pageSize"
            :total="tableInfo.total"
            :page-sizes="[10, 20, 30, 40,50,100,200]"
            layout="slot,total, sizes, prev, pager, next, jumper"
            @size-change="pageSizeChange"
            @current-change="pageIndexChange"
          >
            <span>
              第 {{ pageParam.curPage }} 页 /
              共 {{ (tableInfo.total !== 0 ? parseInt((tableInfo.total + pageParam.pageSize - 1)/pageParam.pageSize) : 1) }} 页
            </span>
          </el-pagination>
        </el-col>
      </el-row>
    </div>
  </div>
</template>

<script>
export default {
  props: {
    tableInfo: {
      type: Object,
      default: () => {
        return {
          records: [],
          total: 0
        }
      }
    },
    title: {
      type: String,
      default: () => {
        return ''
      }
    },
    showPagination: {
      type: Boolean,
      default: () => {
        return false
      }
    },
    defaultHeight: {
      type: String,
      default: () => {
        return '300'
      }
    }
  },
  data() {
    return {
      showMore: '',
      loading: false,
      pageParam: {
        curPage: 1,
        pageSize: 10
      }
    }
  },
  watch: {},
  mounted() {},
  methods: {
    tableRowClassName({ row, rowIndex }) {
      if (rowIndex % 2 === 1) {
        return 'warning-row'
      }
    },
    pageSizeChange(val) {
      this.pageParam.pageSize = val
      this.$emit('pageSizeChangeTable', val)
    },
    pageIndexChange(val) {
      this.pageParam.curPage = val
      this.$emit('pageIndexChangeTable', val)
    }
  }
}
</script>

<style lang="scss" scoped>

.page-box{
    margin:10PX;
  .el-pagination{
    text-align: right;
  }
}
.header{
  width: 95%;
  margin: 10px auto;
  display: flex;
  align-items: center;
  font-size: 16px;
  font-weight: 600;
  color: #000;
  img{
    margin-right:10px;
  }
}
</style>
