<template>
  <div class="index-input">
    <el-input placeholder="请输入任务名称" v-model="searchText">
      <el-select v-model="value" slot="prepend">
        <el-option
          v-for="item in options"
          :key="item.value"
          :label="item.label"
          :value="item.value"
        >
        </el-option>
      </el-select>
      <el-button slot="append" @click="searchJump">
        <i class="el-icon-search"></i>
        搜索
      </el-button>
    </el-input>
  </div>
</template>

<script>
export default {
  name:'SearchIpt',
  data() {
    return {
      searchText: "",
      options: [
        {
          value: 'task',
          label: "任务信息搜索",
        },
        {
          value: 'quota',
          label: "指标体系",
        },
        {
          value: 'plan',
          label: "工作体系",
        },
        {
          value: 'policy',
          label: "政策体系",
        },
        {
          value: 'comment',
          label: "评价体系",
        },
        {
          value: 'all',
          label: "全景信息",
        },
      ],
      value: this.$route.query.methodCode?this.$route.query.methodCode:'all',
    };
  },
  created() {
    this.searchText = this.$route.query.searchText?this.$route.query.searchText:'';
  },
  methods: {
    searchJump() {
      if (this.$route.path == "/search") {
        this.$router.push(
          "/search?searchText=" + this.searchText + "&methodCode=" + this.value
        );
        this.$router.go(0);
      } else{
        this.$router.push(
          "/search?searchText=" + this.searchText + "&methodCode=" + this.value
        );
      }
    },
  },
};
</script>

<style lang="scss" scoped>
.index-input {
  width: 50%;
  margin: 45px auto 30px;
  >>> .el-input-group__prepend {
    width: 15%;
    .el-input__inner {
      padding-left: 10px;
      padding-right: 25px;
    }
  }
  >>> input {
    height: 45px;
    line-height: 45px;
    font-size: 16px;
  }
  >>> .el-input-group__append {
    text-align: center;
    height: 44px;
    width: 10%;
    background-color: #1492ff;
    border: 0;
    color: #fff;
    padding: 0;
    font-size: 16px;
  }
}
</style>