<template>
  <el-checkbox-group v-model="labelResult" @change="handleChange">
    <el-checkbox
      v-for="(item, index) in checkboxList"
      :key="index"
      :label="item.label"
      :disabled="typeof item == 'string' ? false : item.disabled == true ? true :false"
    ></el-checkbox>
  </el-checkbox-group>
</template>

<script>
export default {
  name: "PsCheckBox",
  props: {
    checkboxList: {
      type: Array,
      default: () => {
        return [];
      },
    },
    disabled: {
      type: Boolean,
      default: false,
    },
    label: {
      type: String,
      default: "label",
    },
  },
  data() {
    return {
      labelResult: [],
      labelList: [
      ],
      labelMap: {},
      value: Boolean,
    }
  },
  mounted() {
    this.loadData(); 
  },
  computed: {

  },
  watch: {
    checkboxList() {
      this.loadData();
    }
  },
  methods: {
    //初始化数据
    loadData() {
      this.checkboxList.forEach((res) => {
        this.labelList.push(res["label"]);
        this.labelMap[res["label"]] = res["value"];
      });
    },
    handleChange() {
      this.$emit("handleChange", !this.value)
    },
  },
}
</script>