<template>
  <div>
    <el-table ref="table" @selection-change="selectionChange" :row-class-name="tableClassName" highlight-current-row :data="data"  size="mini" :height="height" @row-click="rowClick" style="width:100%;min-height:300px"  border>
      <el-table-column
          type="selection"
          width="55"  >
      </el-table-column>
      <el-table-column v-for="col in layout" :key="col.tablecolid" :prop="col.columnname" :label="col.title" :width="width && col.width === 0 ? 150 : col.width" :fixed="fixedName ? fixedName.indexOf(col.columnname)!= -1?'right':false : false">
        <template slot-scope="scope">
          <div class="table-panel">
            <!-- 自定义表格显示内容 -->
            <slot v-if="custom" name="customcol" :column="{data:scope.row,columnname:col.columnname}"></slot>
            <!-- 否则就是默认 -->
            <span v-else>{{scope.row[col.columnname]}}</span>
            <!-- 操作结构内容 -->
            <slot v-if="col.columnname === 'operation'" name="opreation" :data="scope.row"></slot>
          </div>
        </template>
      </el-table-column>
    </el-table>
  </div>
</template>

<script>
import {mapGetters} from "vuex"
export default {
  /*
    layout:表结构数据;
    data:表渲染数据;
    custom:是否启用自定义结构;
    opwidth:操作列宽度
  */
  props:['layout','data','custom','height','checkbox','height','fixedName','width'],
  data () {
    return {
      list:[],
    }
  },
  computed:{
    ...mapGetters({
      loading:'loading'
    })
  },
  methods:{
    rowClick (row) {
      console.log(row,'勾选')
      this.$emit('rowClick',row)
    },
    tableClassName ({row,rowIndex}) {
      row.index = rowIndex
    },
    selectionChange(val) {
      this.$emit('checkboxCallBack',val)
    },
    isCheck(row,rowIndex) {
      if (!row.status) return true
      if(row.status == '待跟进' || row.status == '跟进中' || row.projectnum) {
        return true
      } else {
        return false
      }
    },

  },
  mounted () {
    // this.listData()
  }
}

</script>
<style>
</style>