HeaderSearch.vue
2.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
<template>
<div class="header-search">
<div class="btn-group">
<el-button type="primary" icon="el-icon-plus" @click="handleAdd">
添加
</el-button>
<el-button
icon="el-icon-delete"
:disabled="deldisabled"
@click="handleDel"
>
删除
</el-button>
</div>
<div class="search-input">
<el-input
v-model="searchKey"
clearable
:placeholder="searchTips"
@focus="handleFocus"
@blur="handleBlur"
@keyup.enter.native="searchByKey"
></el-input>
<i
ref="icon"
class="iconfont icon-flow-center-search"
@click="searchByKey"
></i>
</div>
</div>
</template>
<script>
import { mapGetters } from 'vuex'
export default {
name: 'HeaderSearch',
props: {
searchTips: {
type: String,
default: '请输入关键词进行检索',
},
deldisabled: {
type: Boolean,
default: false,
},
},
data() {
return {
searchKey: '',
}
},
computed: {
...mapGetters({
themeColor: 'settings/themeColor',
}),
},
methods: {
handleAdd() {
this.$emit('handle-add')
},
handleDel() {
this.$emit('handle-del')
},
searchByKey() {
this.$emit('search-by-key', this.searchKey)
},
handleFocus() {
this.$refs.icon.style.color = this.themeColor
},
handleBlur() {
this.$refs.icon.style.color = '#c0c4cc'
},
},
}
</script>
<style lang="scss" scoped>
.header-search {
display: flex;
align-items: center;
justify-content: space-between;
flex-wrap: wrap;
margin-bottom: 16px;
::v-deep .el-input {
width: 268px;
.el-input__inner {
padding-right: 60px;
}
.el-input__suffix {
right: 30px;
}
}
.search-input {
position: relative;
.iconfont {
font-size: 14px;
width: 30px;
height: 32px;
line-height: 32px;
position: absolute;
top: 0px;
right: 0px;
color: #c0c4cc;
text-align: center;
cursor: pointer;
}
}
}
</style>