import IbpsFieldDesc from '@/components/ibps-field-desc'
export default {
  components: {
    IbpsFieldDesc
  },
  props: {
    value: [String, Number, Date, Boolean, Array, Object],
    label: String,
    name: String,
    size: String,
    placeholder: {
      type: String,
      default: '请选择'
    },
    border: {
      type: Boolean,
      default: true
    },
    disabled: Boolean,
    readonly: {
      type: Boolean,
      default: false
    },
    required: Boolean,
    clearable: {
      type: Boolean,
      default: true
    },
    clickable: Boolean,
    isLink: Boolean,
    error: Boolean,
    errorMessage: String,
    errorMessageAlign: {
      type: String,
      default: 'right'
    },
    arrowDirection: String,
    labelClass: String,
    labelWidth: String,
    labelAlign: String,
    inputAlign: {
      type: String,
      default: 'right'
    },
    autosize: [Boolean, Object],
    leftIcon: String,
    rightIcon: String,
    iconPrefix: String,
    rules: Array,

    desc: String,
    descPosition: {
      type: String
      // default: 'labelIcon'
    }
  },
  data() {
    return {
      inputValue: ''
    }
  },
  computed: {
    editable() {
      return !this.readonly && !this.disabled
    }
  },
  methods: {
    validate() {
      if (!this.editable) {
        return
      }
      if (this.$refs.input) {
        this.$refs.input.validate(this.rules)
      }
    },
    _setInputValue() {
      this.inputValue = this.$utils.isNotEmpty(this.value) ? this.value : ''
      setTimeout(() => {
        this.validate()
      }, 10)
    }
  }
}
