<template>
  <div>
    <div style="margin-top: 15px; width: 80%">
      <input
        placeholder="请输入内容"
        v-model="searchValue"
        class="input-with-select"
        clearable
        ref="input"
        @focus="onInputFocus"
        @blur="onInputBlur"
        @input="onInputFocus"
      />
      <select v-model="select" slot="prepend" placeholder="热舞广泛的给">
        <option label="餐厅名" value="1"></option>
        <option label="订单号" value="2"></option>
        <option label="用户电话" value="3"></option>
      </select>
      <button slot="append" icon="icon-search">搜索</button>

      <div class="selset_wrap" v-if="selsetWrapShow">
        <div class="selset_wrap_title">历史记录</div>
        <div
          class="selset_wrap_list"
          v-for="(item, index) in inputData"
          :key="index"
        >
          <div class="selset_wrap_list_list">
            <div
              class="selset_wrap_list_list_name"
              @mousedown.prevent="searchValueFn(item)"
            >
              {{ item.name }}
            </div>
            <div
              class="selset_wrap_list_list_remove"
              @mousedown.prevent="removeFn(index)"
            >
              <i class="icon-delete"></i>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      searchValue: "",
      select: "餐厅名",
      restaurants: [],
      state: "",
      timeout: null,
      selsetWrapShow: false,
      inputData: [
        { name: "在知识的山峰上登得越高,眼前的景色越壮阔", id: "1" },
        { name: "万事皆由人的意志创造。", id: "2" },
        { name: "万般皆是命,半点不由人", id: "3" },
        { name: "身外障碍事小,心中障碍事大。", id: "4" },
        {
          name: "实力的来源不是胜利。唯有奋斗才能增强实力。当你历经苦难而不气馁,那就是实力。唯有奋斗才能增强实力。当你历经苦难而不气馁,那就是实力唯有奋斗才能增强实力。当你历经苦难而不气馁,那就是实力",
          id: "5",
        },
        {
          name: "实力的来源不是胜利。唯有奋斗才能增强实力。当你历经苦难而不气馁,那就是实力。",
          id: "6",
        },
      ],
    };
  },
  methods: {
    onInputFocus() {
      this.selsetWrapShow = true;
      console.log("获取焦点");
    },
    onInputBlur() {
      this.selsetWrapShow = false;
      console.log("失去焦点");
    },
    searchValueFn(val) {
      this.selsetWrapShow = false;
      this.searchValue = val.name;
      this.$refs["input"].blur();
      console.log(this.searchValue);
    },
    removeFn(index) {
      this.selsetWrapShow = true;
      console.log("删除");
      this.inputData.splice(index, 1);
    },
  },
  mounted() {},
};
</script>

<style>
.selset_wrap {
  /* border: 1px solid; */
  margin-top: 5px;
  background: #ffffff;
  box-shadow: 3px 3px 3px 3px #999999;
}
.selset_wrap_title {
  color: #999999;
  height: 32px;
  width: 96%;
  line-height: 32px;
  margin: 0 auto;
  font-size: 12px;
}
.input-group__prepend {
  width: 60px;
}

.selset_wrap_list {
  /* height: 32px; */
  width: 100%;
  font-size: 12px;
  cursor: pointer;
}
.selset_wrap_list:hover {
  color: #fe774e;
  background: #f5f5f5;
}
.selset_wrap_list_list {
  width: 96%;
  line-height: 32px;
  margin: 0 auto;
  display: flex;
  flex-wrap: nowrap;
  justify-content: space-between;
}
.selset_wrap_list_list_name {
  width: 97%;
}
.selset_wrap_list_list_remove {
  width: 2%;
}
</style>

Logo

魔乐社区(Modelers.cn) 是一个中立、公益的人工智能社区,提供人工智能工具、模型、数据的托管、展示与应用协同服务,为人工智能开发及爱好者搭建开放的学习交流平台。社区通过理事会方式运作,由全产业链共同建设、共同运营、共同享有,推动国产AI生态繁荣发展。

更多推荐