<template>
  <div>
    <el-tooltip v-bind="$attrs.tooltipAttrs || {}" :disabled="disabled">
      <div slot="content">{{$attrs.tooltipAttrs.tooltipText || ''}}</div>
      <el-input v-bind="$attrs.inputAttrs || {}" v-model.trim="currentValue" @focus="focus" @blur="blur"></el-input>
    </el-tooltip>
  </div>
</template>

<script>
export default {
  name: 'tipElInput',
  props: {
    // v-model绑定的数据
    value: {
      type: [Array, String],
      default: function () {
        return null
      }
    }
  },
  data () {
    return {
      disabled: false
    }
  },
  mounted () {
    console.log(this.$attrs)
    console.log(this.$listeners)
  },
  computed: {
    // 转换绑定的选中数据，与v-model同步
    currentValue: {
      get: function () {
        return this.value
      },
      set: function (value) {
        this.$emit('input', value)
      }
    }
  },
  methods: {
    focus () {
      if (!this.disabled) {
        this.disabled = true
      }
    },
    blur () {
      if (this.disabled) {
        this.disabled = false
      }
    }
  }
}
</script>

<style scoped>

</style>
