<template>
  <el-radio-group class="ps-radio" v-model="inputValue" :disabled="disabled" @input="operaInput">
    <el-radio :label="defalutProps ? item[defalutProps.id] : item.id" v-for="(item, index) in dataSource"
      :key="index">{{ defalutProps ? item[defalutProps.desc] : item.desc }}</el-radio>
  </el-radio-group>
</template>

<script>
export default {
  name: "PsRadio",
  props: {
    value: null,
    dataSource: {
      type: Array,
      default: () => []
    },
    defalutProps: {
      type: Object,
      default: () => undefined
    },
    
    disabled: {
      type: Boolean,
      default: false
    },

    id: { type: String, default: "" }
  },
  //处理v-model语法糖的emit事件
  model: {
    prop: 'value',
    event: 'handler'
  },
  watch: {
    value: {
      handler(val) {
        this.inputValue = val
      },
      immediate: true
    }
  },
  data() {
    return {
      inputValue: null,
    };
  },
  created() {

  },
  mounted() {
  },
  methods: {
    operaInput(e) {
      
      this.$emit('handler', e)
      this.$emit("change", e);
    },
  },
};
</script>

<style></style>
