<template>
  <div>
    <el-table
      ref="table"
      v-loading="loading"
      :data="tableData"
      @selection-change="handleSelectionChange"
      border>
      <el-table-column type="selection" width="60" align="center">
      </el-table-column>
      <el-table-column label="质检字段" prop="columnName" align="center">
      </el-table-column>
      <el-table-column label="中文字段名" prop="columnChnName" align="center">
      </el-table-column>
    </el-table>
  </div>
</template>

<script>
export default {
  props: {
    loading: {
      type: Boolean,
      default: () => true
    },
    tableData: {
      type: Array,
      default: () => []
    }
  },
  components: {},
  data() {
    return {
    };
  },
  watch: {
    'tableData': {
      handler(val, oldVal) {
        // table数据勾选
        this.$nextTick(()=>{
          const selectedRow = val.filter(item=>item.isChecked === 'T');
          selectedRow.forEach(row=>{
            this.$refs.table.toggleRowSelection(row)
          })
        })
      }
    }
  },
  methods: {
    //勾选原文表
    handleSelectionChange(val) {
      this.$emit("handSelect", val);
    }
  }
};
</script>

<style></style>
