ces
杨磊
3 天以前 5bc507a8a7be9cbbad0fa2472f72b1d336f31ef2
src/views/home/components/searchBox.vue
@@ -15,7 +15,7 @@
    </el-select>
    <div class="inputBox">
      <input type="text" v-model="searchText" class="search-input" />
      <div class="searchBtn">搜索</div>
      <div class="searchBtn" @click="handleSearch()">搜索</div>
    </div>
  </div>
</template>
@@ -23,23 +23,35 @@
<script>
export default {
  name: "SearchBox",
  props: {
    // 接收外部传入的选项
    options: {
      type: Array,
      default: () => [
        { value: "all", label: "全部" },
        { value: "name", label: "标题" },
        { value: "author", label: "作者" },
        { value: "year", label: "年份" },
        { value: "keyWords", label: "关键词" },
        { value: "abstract", label: "摘要" },
        { value: "source", label: "来源" },
      ],
      searchFun: {
        type: Function,
        default: () => {},
      },
    },
  },
  data() {
    return {
      searchText: "", // 输入框内容
      selectedType: "", // 下拉框选中值
      options: [
        // 下拉选项
        { value: "all", label: "全部" },
        { value: "name", label: "名称" },
        { value: "id", label: "ID" },
        { value: "code", label: "编码" },
      ],
    };
  },
  methods: {
    // 搜索处理
    handleSearch() {
      this.$emit("search", {
      this.$emit("searchFun", {
        text: this.searchText,
        type: this.selectedType,
      });
@@ -54,14 +66,16 @@
  max-width: 800px;
  display: flex;
  align-items: center;
  background-color: #fff;
}
/* 输入框样式 */
.search-input {
  background-color: transparent;
}
.inputBox {
  border: 1px solid #B9A587;
  border: 1px solid #b9a587;
  height: 38px;
  width: 400px;
  display: flex;
@@ -95,10 +109,9 @@
.el-select /deep/ .el-input__inner {
  border-top-right-radius: 0;
  border-bottom-right-radius: 0;
  border: 1px solid #B9A587;
  border: 1px solid #b9a587;
  background-color: transparent;
  border-right: none;
}
.el-input-group__prepend {