<template>
  <div class="table-container">
    <!--<el-row class="table-title">-->
    <!--<el-col :span="6"><div class="title-header"><i class="el-icon-menu"/>数据列表</div></el-col>-->
    <!--</el-row>-->
    <el-table ref="table" :data="list" size="small" class="table" border>
      <el-table-column align="center" type="index" width="30"/>
      <el-table-column v-for="column in tableColumns" :key="column.value" :label="column.text" :width="column.width" align="center">
        <template slot-scope="scope">
          <span v-if="column.type!='button'">{{ scope.row[column.value] }}</span>
          <el-button v-if="column.type=='button'" type="text" class="table-button" @click="showCaseList(scope.row,column.value)">{{ scope.row[column.value] }}</el-button>
        </template>
      </el-table-column>
    </el-table>
    <el-row class="table-block"/>
  </div>
</template>

<script>
export default {
  name: 'DeptAccessList',
  props: {
    list: {
      type: Array,
      default() {
        return []
      }
    },
    query: {
      type: Object,
      default: null
    }
  },
  data() {
    return {
      tableColumns: [
        {
          text: '单位名称',
          value: 'departName',
          type: 'text'
        },
        {
          text: '上期结转数',
          value: 'lastCheckNum',
          width: 60,
          type: 'button'
        },
        {
          text: '本期应处置数',
          value: 'currentCheckNum',
          width: 60,
          type: 'button'
        },
        {
          text: '总应处置数',
          value: 'totalCheckNum',
          width: 60,
          type: 'text'
        },
        {
          text: '工作量比例',
          value: 'workRate',
          width: 65,
          type: 'text'
        },
        {
          text: '工作量调节得分',
          value: 'workGrade',
          width: 65,
          type: 'text'
        },
        {
          text: '处置数',
          value: 'checkedNum',
          width: 60,
          type: 'button'
        },
        {
          text: '超期处置数',
          value: 'delayCheckedNum',
          width: 60,
          type: 'button'
        },
        {
          text: '超期未处置数',
          value: 'delayUncheckNum',
          width: 60,
          type: 'button'
        },
        {
          text: '超期总数',
          value: 'delayTotalNum',
          width: 60,
          type: 'text'
        },
        {
          text: '超期未处置率',
          value: 'delayUnCheckRate',
          width: 65,
          type: 'text'
        },
        {
          text: '超期率',
          value: 'delayCheckRate',
          width: 65,
          type: 'text'
        },
        {
          text: '超期未处置扣分',
          value: 'delayUncheckGrade',
          width: 65,
          type: 'text'
        },
        {
          text: '超期扣分',
          value: 'delayGrade',
          width: 60,
          type: 'text'
        },
        {
          text: '返工率',
          value: 'redoRate',
          width: 65,
          type: 'text'
        },
        {
          text: '返工数',
          value: 'redoNum',
          width: 60,
          type: 'button'
        },
        {
          text: '返工扣分',
          value: 'redoGrade',
          width: 60,
          type: 'text'
        },
        {
          text: '综合指标',
          value: 'score',
          width: 60,
          type: 'text'
        },
        {
          text: '等级',
          value: 'grade',
          width: 55,
          type: 'text'
        }
      ]
    }
  },
  methods: {
    showCaseList(row, value) {
      console.log(row, value, row[value])
      if (row[value] > 0) {
        this.$router.push({
          path: '/assessDeptCaseList',
          query: {
            begTime: this.query.begTime,
            endTime: this.query.endTime,
            caseType: value,
            departmentId: row.depId
          }
        })
      }
    }
  }
}
</script>

<style rel="stylesheet/scss" lang="scss" scoped>
  .table{
    margin-bottom: 20px;
  }
  .pagination-container{
    padding-bottom: 50px;
  }
  .table-title{
    /*background-color:rgba(243, 243, 243, 1);*/
    background-color:#fff;
    .title-header{
      font-size: 15px;
      i{
        margin-left: 10px;
        margin-right: 5px;
      }
      i:focus{
        outline: none;
      }
    }
  }
  .edit_btns{
    padding-top:7px;
    padding-right:5px;
    text-align: right;
  }
  .popper-div{
    line-height: 1.5;
    .popper-btns{
      margin-top:10px;
    }
  }
  .table-container {
    border: 0 !important;
  }

</style>

<style>
  /* 解决element-ui的table表格控件表头与内容列不对齐问题 */
  .el-table th.gutter{
    display: table-cell !important;
  }
</style>
