<template>
  <div class="checkboxList">
    <el-checkbox-group v-model="List" @change="$emit('change', List)">
      <el-checkbox v-for="item in data" :key="item.id" class="checkbox" :label="item.id">{{ item.name }}</el-checkbox>
    </el-checkbox-group>
  </div>
</template>
<script>
// const cityOptions = ['上海', '北京', '广州', '深圳', 'ss', 'qq', 'www', 'eeee', 'ssss', 'vvvv', 'ggg', 'jjj']
export default {
  props: {
    selectedList: {
      type: Array,
      required: false,
      default: () => []
    },
    data: {
      type: Array,
      required: false,
      default: () => []
    }
  },
  data() {
    return {
      checkAll: false,
      // checkedCities: ['上海', '北京'],
      // cities: cityOptions,
      isIndeterminate: true,
      List: this.selectedList
    }
  },
  methods: {
    handleCheckAllChange(val) {
      // this.checkedCities = val ? cityOptions : []
      this.isIndeterminate = false
    },
    handleCheckedCitiesChange(value) {
      const checkedCount = value.length
      this.checkAll = checkedCount === this.cities.length
      this.isIndeterminate = checkedCount > 0 && checkedCount < this.cities.length
    }
  }
}
</script>
<style scoped lang='scss'>
.checkboxList {
  width: 800px;
  .checkbox {
    // width: 130px;
    // margin-right: 50px;
    margin: 10px 40px 10px 0;
  }
}

</style>
