|
|
@ -1,35 +1,36 @@
|
|
|
|
<template>
|
|
|
|
<template>
|
|
|
|
<div>
|
|
|
|
<div>
|
|
|
|
<slot :filter="filter"> </slot>
|
|
|
|
<slot :filter="filter"></slot>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
|
|
<script>
|
|
|
|
<script>
|
|
|
|
let cancelId;
|
|
|
|
let cancelId;
|
|
|
|
|
|
|
|
|
|
|
|
export default {
|
|
|
|
export default {
|
|
|
|
name: "AutoCompleteWrapper",
|
|
|
|
name: "AutoCompleteWrapper",
|
|
|
|
props: {
|
|
|
|
props: {
|
|
|
|
callback: {
|
|
|
|
callback: {
|
|
|
|
type: Function,
|
|
|
|
type: Function,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
methods: {
|
|
|
|
filter(e) {
|
|
|
|
filter(e) {
|
|
|
|
clearTimeout(cancelId);
|
|
|
|
clearTimeout(cancelId);
|
|
|
|
if (
|
|
|
|
if (
|
|
|
|
e.target.value &&
|
|
|
|
e.target.value &&
|
|
|
|
e.target.value.length > 1 &&
|
|
|
|
e.target.value.length > 1 &&
|
|
|
|
e.code !== "Tab" &&
|
|
|
|
e.code !== "Tab" &&
|
|
|
|
e.code !== "Enter"
|
|
|
|
e.code !== "Enter"
|
|
|
|
) {
|
|
|
|
) {
|
|
|
|
cancelId = setTimeout(() => {
|
|
|
|
cancelId = setTimeout(() => {
|
|
|
|
this.callback(e.target.value);
|
|
|
|
this.$emit('filter', e.target.value);
|
|
|
|
}, 400);
|
|
|
|
this.callback(e.target.value);
|
|
|
|
}
|
|
|
|
}, 400);
|
|
|
|
},
|
|
|
|
}
|
|
|
|
},
|
|
|
|
},
|
|
|
|
};
|
|
|
|
},
|
|
|
|
|
|
|
|
};
|
|
|
|
</script>
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
|
|
<style>
|
|
|
|
<style>
|
|
|
|