<template>
  <el-select v-if="options" v-model="selectVal" :placeholder="$t('请选择')">
    <el-option v-if="allShow"  :label="$t('全部')" :value='-1'></el-option>
    <el-option
      v-for="item in options"
      :key="item[valueKey]"
      :label="item[labelKey]"
      :value="parseInt(item[valueKey])">
    </el-option>
  </el-select>
</template>

<script>
export default {
  name: "customSelectorsDictionary",
  props:{
    options:{
      type:Array,
      default:()=>[]
    },
    value:[String , Number],
    labelKey:{
      type:String,
      default:'label'
    },
    valueKey:{
      type:String,
      default: 'value',
    },
    allShow:{
      type:Boolean,
      default:false
    }
  },
  data(){
    return{
      selectVal:''
    }
  },
  mounted() {
    this.selectVal = this.value;
  },
  watch:{
    selectVal(val){
      this.$emit('input',val)
    },
    value(val){
      this.selectVal = val;
    }
  }
}
</script>

<style scoped lang="scss">
</style>
