diff --git a/src/editor/text-box/input/input.scss b/src/editor/text-box/input/input.scss index fe08edf67bc8b5350b5642f97ce0700a302c1f3f..7b962b7c7bc0985a90a1a21aaa24f7ddd4ef45d7 100644 --- a/src/editor/text-box/input/input.scss +++ b/src/editor/text-box/input/input.scss @@ -47,6 +47,10 @@ $input: ( @include overflow-wrap; } + .el-input__count{ + bottom: 0; + } + @include b(input-input) { height: 100%; diff --git a/src/editor/text-box/input/input.tsx b/src/editor/text-box/input/input.tsx index 905fbc208d565b48f5de9b185c3e93f63b21a763..0c37bbda71f18415a8aacf7eb485198cab36afc5 100644 --- a/src/editor/text-box/input/input.tsx +++ b/src/editor/text-box/input/input.tsx @@ -1,5 +1,6 @@ /* eslint-disable no-nested-ternary */ import { computed, defineComponent, onUnmounted, ref, watch } from 'vue'; +import { debounce } from 'lodash-es'; import { getEditorEmits, getInputProps, @@ -125,6 +126,8 @@ export const IBizInput = defineComponent({ } }; + let isDebounce = false; + let awaitSearch: () => void; let blurCacheValue: string | undefined; // 值变更 const handleChange = (val: string | number) => { @@ -135,18 +138,35 @@ export const IBizInput = defineComponent({ blurCacheValue = undefined; }; + const debounceChange = debounce( + (val: string | number) => { + // 拦截掉blur触发后change + if (blurCacheValue !== val) { + onEmit(val, 'input'); + } + blurCacheValue = undefined; + isDebounce = false; + if (awaitSearch) { + awaitSearch(); + } + }, + 300, + { leading: true }, + ); + const handleInput = (val: string | number) => { - // 拦截掉blur触发后change - if (blurCacheValue !== val) { - onEmit(val, 'input'); - } - blurCacheValue = undefined; + isDebounce = true; + debounceChange(val); }; const handleKeyUp = (e: KeyboardEvent) => { if (e && e.code === 'Enter') { emit('enter', e); - editorRef.value.$el.dispatchEvent(e); + if (isDebounce) { + awaitSearch = () => { + editorRef.value.$el.dispatchEvent(e); + }; + } } };