<template>
  <div>
    <el-table :data="featuresList" style="height: 200px;overflow: auto;">
      <el-table-column prop="index" label="#" width="50px" align="center">
        <template slot-scope="scope">
          <div>
            <el-checkbox :label="scope.row.label" @change="changeSelect(scope.row)"
              :checked="selected.indexOf(scope.row.features) !== -1">
              <span>{{ (scope.$index + 1) }}</span>
            </el-checkbox>
          </div>
        </template>
      </el-table-column>

      <el-table-column prop="features" label="特征" align="center">
        <template slot-scope="scope">
          {{ scope.row.features }}
        </template>
      </el-table-column>
    </el-table>
    <div style="display:flex;justify-content: flex-end;margin-top:10px">
      <el-button type="primary" size="small" @click="submit">确定</el-button>
      <el-button type="primary" size="small" @click="cancel">取消</el-button>
    </div>
  </div>
</template>

<script>
export default {
  props:['patentNo','rightFeaturesList'],
  data() {
    return {
      featuresList:this.rightFeaturesList,
      selected:[],
      proofGroups: [],
    }
  },
  watch: {
    rightFeaturesList(val) {
      this.featuresList=val
    }
  },
  computed: {},
  mounted() {
   
  },
  methods: {
    
    submit() {
      if (this.proofGroups.length == 0) {
        this.$message.error('请选择后再添加')
        return false
      }
      
      // console.log(this.form,this.proofGroups);
      let a = {
        proofGroups: this.proofGroups,
        close:false,
      }
      this.$emit('checkFeatures',a)
      this.cancel()
    },
    cancel() {
      // this.proofGroups = []
      this.featuresList=[]
      this.selected = []
      this.$emit('closeFeatures',false)
    },
    // change选中
    changeSelect(row) {
      console.log(row);
      const index = this.selected.indexOf(row.features)
      if (index === -1) {
        this.selected.push(row.features)
        this.proofGroups.push(row)
      } else {
        this.selected.splice(index, 1)
        this.proofGroups.splice(index, 1)
      }
      console.log(this.proofGroups,this.selected);
    },
  },
}
</script>

<style lang="scss" scoped></style>