<template>
  <el-form-item :label="label" :rules="requireRule(!disabled && required, label)" :prop="prop">
    <el-select
      v-model="$parent.model[prop]"
      :multiple="multiple" :clearable="clearable" filterable :disabled="disabled">
      <el-option v-for="item in data" :key="item[`${valueProp}`]" :value="String(item[`${valueProp}`])"  :label="item[`${labelProp}`]"/>
    </el-select>
  </el-form-item>
</template>

<script>
import mixin from './mixin'
/**
 * 下拉框组件
 */
export default {
  mixins: [mixin],
  props: {
    multiple: {
      type: Boolean,
      default: false
    },
    data: {
      type: Array,
      default: () => []
    },
    valueProp: {
      type: String,
      default: 'value'
    },
    labelProp: {
      type: String,
      default: 'label'
    }
  }
}
</script>
