pet-ai/web/src/view/layout/search/search.vue

65 lines
1.6 KiB
Vue

<template>
<div class="search-component">
<transition name="el-fade-in-linear">
<div class="transition-box" style="display: inline-block; " v-show="show">
<el-select
ref="search-input"
@blur="hiddenSearch"
@change="changeRouter"
filterable
placeholder="请选择"
v-model="value"
>
<el-option
:key="item.value"
:label="item.label"
:value="item.value"
v-for="item in routerList"
></el-option>
</el-select>
</div>
</transition>
<div
:style="{display:'inline-block',float:'right',width:'31px',textAlign:'left',fontSize:'16px',paddingTop:'2px'}"
class="user-box"
>
<i @click="$bus.$emit('reload')" :style="{cursor:'pointer'}" class="el-icon-refresh" />
</div>
<div :style="{display:'inline-block',float:'right'}" class="user-box">
<i :style="{cursor:'pointer'}" @click="showSearch()" class="el-icon-search search-icon"></i>
</div>
</div>
</template>
<script>
import { mapGetters } from "vuex";
export default {
name: "searchComponent",
data() {
return {
value: "",
show: false
};
},
computed: {
...mapGetters("router", ["routerList"])
},
methods: {
changeRouter() {
this.$router.push({ name: this.value });
this.value = "";
},
hiddenSearch() {
this.show = false;
},
showSearch() {
this.show = true;
this.$nextTick(() => {
this.$refs["search-input"].focus();
});
}
}
};
</script>
<style lang="scss">
</style>