doc-search.vue
2.4 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
<template>
<div class="search-box">
<i-form ref="formInline" inline>
<i-form-item>
<Input v-model="keyword" style="width: 300px;">
<Select v-model="searchType" slot="prepend" style="width: 100px">
<Option value="controller">controller</Option>
<Option value="keyword">关键词</Option>
</Select>
</Input>
</i-form-item>
<i-form-item>
<i-button type="primary" @click="searchGroup" v-show="store.groupName">搜当前分组</i-button>
<i-button type="primary" @click="searchAll" >搜全部</i-button>
<i-button type="warning" @click="reset">清空</i-button>
</i-form-item>
</i-form>
</div>
</template>
<script>
import {
FETCH_API_REQUEST
} from 'store/types';
import {mapState} from 'vuex';
export default {
name: 'DocSearch',
computed: {
...mapState(['store'])
},
data() {
return {
searchType: 'controller',
keyword: ''
};
},
methods: {
searchGroup() {
if (this.keyword) {
this.$store.dispatch(FETCH_API_REQUEST, {
groupName: this.store.groupName,
keyword: this.keyword,
searchType: this.searchType
}).then(() => {
window.scrollTo(0, 0);
});
}
},
searchAll() {
if (this.keyword) {
this.$store.dispatch(FETCH_API_REQUEST, {
groupName: '',
keyword: this.keyword,
searchType: this.searchType
}).then(() => {
window.scrollTo(0, 0);
});
}
},
reset() {
if (this.store.apiSearchType) {
this.keyword = '';
this.$store.dispatch(FETCH_API_REQUEST, {
groupName: this.store.groupName,
keyword: '',
searchType: ''
}).then(() => {
window.scrollTo(0, 0);
});
}
}
}
};
</script>
<style lang="scss">
.search-box {
padding: 20px;
border-bottom: solid 1px #dddee1;
.ivu-form-item {
margin-bottom: 0;
}
}
</style>