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
import { computed, defineComponent } from 'vue';
import { useNamespace } from '@ibiz-template/vue-util';
import '@ibiz-template/theme/style/components/common/quick-search/quick-search.scss';
export const QuickSearch = defineComponent({
name: 'QuickSearch',
props: {
value: {
type: String,
},
viewMode: {
type: String,
required: true,
},
placeholder: {
type: String,
},
},
setup(props, { emit }) {
const ns = useNamespace('quick-search');
const inputValue = computed({
get() {
return props.value;
},
set(val: string | undefined) {
emit('update', val!);
},
});
const search = () => {
emit('search');
};
const onChange = (e: InputEvent) => {
if (e.target) {
inputValue.value = (e.target as unknown as { value: string }).value;
}
};
return { ns, inputValue, search, onChange };
},
render() {
return (
<i-input
value={this.value}
class={[this.ns.b(), this.ns.m(this.viewMode.toLowerCase())]}
search={true}
placeholder={this.placeholder}
on-on-change={this.onChange}
on-on-enter={this.search}
on-on-search={this.search}
></i-input>
);
},
});
export default QuickSearch;