<template>
  <div>
    <el-input v-bind="$attrs" v-on="currentListeners">
      <el-button v-if="showAppend" slot="append" icon="el-icon-search" @click="search">
      </el-button>
    </el-input>
  </div>
</template>

<script>
export default {
  name: 'ExcludeSpecialInput.vue',
  props: {
    showAppend: {
      type: Boolean,
      default () {
        return false
      }
    }
  },
  computed: {
    currentListeners () {
      let _this = this
      return Object.assign({}, this.$listeners, {
        input: function (val) {
          _this.inputEvent(val)
        }
      })
    }
  },
  methods: {
    search () {
      this.$emit('search')
    },
    inputEvent (val) {
      let reg = /(^$)|(^[\u4E00-\u9FA5a-zA-Z0-9,，]{1,250}$)/
      if (!reg.test(val)) {
        return
      }
      this.$emit('input', val)
    }
  }
}
</script>

<style scoped>

</style>
