<template>
  <el-radio-group v-model="radioValue" @change="change" v-bind="$props">
    <el-radio-button v-for="dict in dictList" :key="dict.value" :value="dict.value" :label="dict.value">{{ dict.label }}</el-radio-button>
  </el-radio-group>
</template>

<script>
export default {
  props: ['radioData', 'radioList', 'size', 'value', 'showAll', 'filter'],
  emits: ['change', 'input'],
  data() {
    return {
      dictList: []
    };
  },
  computed: {
    radioValue: {
      get() {
        return this.radioValue;
      },
      set(v) {
        this.$emit('update:modelValue', v);
      }
    }
  },
  async created() {
    if (this.radioList && this.radioList.length > 0) {
      this.dictList = this.radioList;
    } else {
      if (this.radioData) {
        const resDic = await this.getDictionaryByKey(this.radioData);
        this.dictList = resDic;
      }
    }
  },
  methods: {
    change(val) {
      this.$emit('update:modelValue', val);
    }
  }
};
</script>
