<template>
  <div class="query_input el-input el-input--small">
    <input
      v-model="value"
      type="text"
      placeholder="请输入查询内容"
      class="el-input__inner"
      @keyup.enter="query"
    />
    <div class="suf" @click="query">查询</div>
  </div>
</template>

<script>
export default {
  data: () => ({ value: '' }),

  watch: {
    '$attrs.value': {
      immediate: true,
      handler (v) {
        this.value = v
      }
    },

    value (v) {
      this.$emit('input', v)
    }
  },

  methods: {
    query () {
      this.$emit('query')
    }
  }
}
</script>

<style lang="scss" scoped>
.query_input {
  width: 188px;
  position: relative;

  .el-input__inner {
    padding-right: 51px;
  }

  .suf {
    padding: 0 10px 0 6px;
    position: absolute;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    font-size: 12px;
    color: $--color-text-secondary;
    border-left: 1px solid $--color-text-secondary;
    cursor: pointer;
    user-select: none;
  }
}
</style>
