<template>
  <div>
    <el-checkbox-group v-model="auth" :disabled="!selected">
      <el-checkbox
        v-for="item in authList"
        :key="item.value"
        :label="item.value"
        @change="changeBtnAuth"
      >
        {{ item.name }}
      </el-checkbox>
    </el-checkbox-group>
  </div>
</template>

<script>
export default {
  props: {
    authList: {
      type: Array,
      default: () => { return [] }
    },
    sureList: {
      type: Array,
      default: () => { return [] }
    },
    selected: {
      type: Boolean,
      default: false
    },
    parentKey: {
      type: String,
      default: ''
    }
  },
  data() {
    return {
      auth: []
    }
  },
  watch: {
    'sureList'(newV, oldV) {
      this.auth = newV
    }
  },
  methods: {
    changeBtnAuth() {
      this.$emit('changebtnauth', this.auth, this.parentKey)
    }
  }
}
</script>
