<template>
  <div class="search-box" :style="{ width }">
    <el-input placeholder="输入关键词查询" :value="value" @input="changeInput">
      <i
        v-show="value"
        slot="suffix"
        class="el-icon-circle-close"
        @click="handleClose"
      ></i>
    </el-input>
    <el-button class="search-btn" @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-color1),
    var(--main-assist-color1)
  );
  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: 20px;
}
:deep(.el-input__inner) {
  height: 72px;
  padding-right: 240px;
  font-size: 24px;
  border-radius: 8px;
  color: #333;
}
</style>