<template>
  <label>启用<input type="checkbox" v-model="value"  @click="onChange('启用')" :disabled="value.includes('保持不变')"  value="启用"/></label>
  <label>保持不变<input type="checkbox" v-model="value" @click="onChange('保持不变')" :disabled="value.includes('启用')" value="保持不变"/></label>
</template>

<script>
export default {
  name: 'RadioBtn',
  title: 'RadioBtn',
  props: {
    value: {
      type: Array,
      default: ['保持不变']
    },
    title: {
      type: String,
      default: ''
    }
  },
  data () {
    return {
      checked: []
    }
  },
  model: {
    prop: 'value'
  },
  methods: {
    onChange (e) {
      let _value = []
      this.$emit('input', e)
      // 因为数组元素个数只有1或者0 判断相同的已经存在就是取消操作
      if (!this.value.includes(e)) {
        _value.push(e)
      }
      this.$dispatch('toggle', this.title, _value)
    }
  }
}
</script>

<style scoped>

</style>
