<template>
  <select-list
    v-model="currentValue"
    :url="url"
    request-method="get"
    :clearable="clearable"
    :placeholder="placeholder"
    :disabled="disabled"
    :allow-create="allowCreate"
    :filterable="filterable"
    :multiple="multiple"
    :collapse-tags="collapseTags"
    :prop="{label:'desc',key:'name',value:'name'}"
    @change="onChange"
  />
</template>

<script>
import SelectList from './index'

export default {
  components: { SelectList },
  name: 'SelectEnum',
  props: {
    value: {},
    className: {
      type: String,
      required: true
    },
    clearable: {
      type: Boolean,
      default: false
    },
    disabled: Boolean,
    allowCreate: Boolean,
    filterable: Boolean,
    multiple: Boolean,
    collapseTags: Boolean,
    placeholder: {
      type: String,
      default: '请选择'
    }
  },
  data() {
    return {
      currentValue: null
    }
  },
  computed: {
    url() {
      return `/system/enum/getItems?className=${this.className}`
    }
  },
  watch: {
    value(val, oldVal) {
      this.currentValue = val
    }
  },
  methods: {
    onChange(val) {
      this.$emit('input', val)
      this.$emit('change', val)
    }
  }

}
</script>

<style scoped>

</style>
