<template>
  <el-select
          :value="value"
          @input="$emit('input', $event)"
    v-bind="$attrs"
    @change="changeData"
  >
    <el-option
      v-for="item in dict"
      :key="item.id || item.dictValue"
      :label="item.dictName"
      :value="item.dictValue"
    />
  </el-select>
</template>

<script>
export default {
  name: 'VabDictSelect',
  props: {
    dictCode:{
      required:true,
      type:String
    },
      value:[String,Number],
  },
  emits: ['change', 'update:value'],
    watch:{
      value(newVal){
          if(typeof newVal == 'number'){
              // eslint-disable-next-line vue/no-mutating-props
              this.value = newVal+'';

              this.$forceUpdate();
          }
          console.log(this.dict[0].dictValue ,this.value)
      }
    },
  data(){
    return {
      dict:[],
    }
  },
  computed: {
    localModelValue: {
      get() {
        return this.modelValue;
      },
      set(newValue) {
        this.$emit('update:value', newValue);
      }
    }
  },
    methods:{
      changeData(){
          this.$emit('change',this.value)
      }
    },
  created() {
    this.dict = this.$getDictList(this.dictCode);


  }
}
</script>
