<template>
  <div class="search-box" :style="{ width }">
    <el-input
      placeholder="输入事项表单关键词或排队编号查询"
      :value="value"
      @keyup.native.enter="handleSearch"
      @input="changeInput"
      v-onEvent="{
        eventName: '输入',
        eventCode: 'Put',
        businessCode: 'search',
        businessName: '搜索',
        routers: $route,
      }"
    >
      <i
        v-show="value"
        slot="suffix"
        class="el-icon-circle-close"
        @click="handleClose"
      ></i>
    </el-input>
    <el-button
      class="search-btn"
      v-onEvent="{
        eventName: '点击',
        eventCode: 'Click',
        businessCode: 'search',
        businessName: '搜索',
        routers: $route,
      }"
      @click="handleSearch"
    >
      <span class="flex aic jcc">
        <img class="mr10" src="../assets/img/sousuo.png" /> 搜索
      </span>
    </el-button>
  </div>
</template>

<script>
export default {
  model: {
    prop: "value",
    event: "input",
  },
  props: {
    width: {
      type: String,
      default: "600px",
    },
    value: {
      type: String,
      Number,
      default: "",
    },
  },
  data() {
    return {};
  },
  methods: {
    changeInput(val) {
      this.$emit("input", val);
    },
    handleSearch() {
      this.$emit("click");
    },
    handleClose() {
      this.$emit("clear");
      this.$emit("input", "");
    },
  },
};
</script>

<style lang="less" scoped>
.search-box {
  box-shadow: 0px 7px 13px 0px rgba(0, 0, 0, 0.1);
  border-radius: 8px;
  position: relative;
}
.search-btn {
  width: 167px;
  height: 62px;
  background: linear-gradient(
    90deg,
    var(--main-theme-color),
    var(--main-assist-color)
  );
  border-radius: 8px;
  color: #ffffff;
  font-size: 24px;
  border: none;
  position: absolute;
  right: 5px;
  top: 5px;
}
:deep(.el-input__suffix) {
  display: flex;
  align-items: center;
  justify-content: center;
  position: absolute;
  right: 200px;
}
.el-icon-circle-close {
  font-size: 30px;
}
:deep(.el-input__inner) {
  height: 72px;
  padding-right: 240px;
  font-size: 24px;
  border-radius: 8px;
  color: #333;
  &:hover {
    border-color: var(--main-theme-color);
  }
  &:focus {
    border-color: var(--main-theme-color);
  }
}
</style>
