From 9acffe295cac4ec7862472075317c5625ee0249c Mon Sep 17 00:00:00 2001 From: lijianxiong <1518062161@qq.com> Date: Tue, 29 Apr 2025 15:01:35 +0800 Subject: [PATCH] =?UTF-8?q?fix=EF=BC=9A=E4=BF=AE=E5=A4=8D=E6=90=9C?= =?UTF-8?q?=E7=B4=A2=E6=9D=A1=E4=BB=B6=E7=BC=96=E8=BE=91=E5=99=A8=E6=96=B0?= =?UTF-8?q?=E5=BB=BA=E6=97=B6=E6=9C=AA=E5=88=9D=E5=A7=8B=E5=8C=96=E9=BB=98?= =?UTF-8?q?=E8=AE=A4=E6=98=BE=E7=A4=BA=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/code-editor/code-editor.tsx | 2 +- .../src/search-criteria/search-criteria.scss | 8 ++++ .../src/search-criteria/search-criteria.tsx | 37 ++++++++++++++----- 3 files changed, 36 insertions(+), 11 deletions(-) diff --git a/packages/search-criteria/src/code-editor/code-editor.tsx b/packages/search-criteria/src/code-editor/code-editor.tsx index 4c599adb..9a3038e4 100644 --- a/packages/search-criteria/src/code-editor/code-editor.tsx +++ b/packages/search-criteria/src/code-editor/code-editor.tsx @@ -101,7 +101,7 @@ export const CodeEditor = defineComponent({ }); // 监听值的变化 - editor.onDidChangeModelContent(() => { + editor.onDidBlurEditorText(() => { currentVal.value = editor!.getValue(); emit('change', currentVal.value); }); diff --git a/packages/search-criteria/src/search-criteria/search-criteria.scss b/packages/search-criteria/src/search-criteria/search-criteria.scss index 4dd2629e..1cc462ce 100644 --- a/packages/search-criteria/src/search-criteria/search-criteria.scss +++ b/packages/search-criteria/src/search-criteria/search-criteria.scss @@ -107,4 +107,12 @@ width: 100%; } + &.el-loading-parent--relative { + min-height: 155px; + .#{bem('search-criteria__custom-button')} { + position: absolute; + bottom: 0; + } + } + } \ No newline at end of file diff --git a/packages/search-criteria/src/search-criteria/search-criteria.tsx b/packages/search-criteria/src/search-criteria/search-criteria.tsx index 80a870f0..88dce5a8 100644 --- a/packages/search-criteria/src/search-criteria/search-criteria.tsx +++ b/packages/search-criteria/src/search-criteria/search-criteria.tsx @@ -59,6 +59,9 @@ export const SearchCriteria = defineComponent({ // 当前值 const curValue = ref(''); + // 是否加载中 + const isLoading = ref(false); + /** * @description 重置过滤器 * @returns {*} {void} @@ -80,7 +83,7 @@ export const SearchCriteria = defineComponent({ * @description 根据实体jsonschema初始化 * @returns {*} {Promise} */ - const initByEditorValue = async (value: string): Promise => { + const initByEditorValue = (value: string) => { if (value) { try { const _value = JSON.parse(value); @@ -114,19 +117,29 @@ export const SearchCriteria = defineComponent({ }; /** - * @description 初始化数据 - * @returns {*} {Promise} + * @description 默认加载 + * + * @return {*} {Promise} */ - const onInitData = async (): Promise => { + const onLoad = async (): Promise => { + isLoading.value = true; allFields.value = await c.loadEntityFiled(props.data); conditionCodeList.value = await c.loadConditionCodeList(); + isLoading.value = false; + }; + + /** + * @description 初始化数据 + * @returns {*} {Promise} + */ + const onInitData = () => { const _value = `${props.value || ''}`; const result = validSearchBarItemJson(_value); if (!result) { customState.value = true; curValue.value = _value; } else { - await initByEditorValue(_value); + initByEditorValue(_value); initCurValue(); } }; @@ -134,9 +147,12 @@ export const SearchCriteria = defineComponent({ watch( () => props.value, async newVal => { - // 第一次调用,需初始化 - if (!curValue.value && newVal) { - await onInitData(); + // 第一次调用,需加载数据 + if (!curValue.value) { + await onLoad(); + } + if (!newVal) { + onInitData(); } }, { immediate: true }, @@ -378,7 +394,7 @@ export const SearchCriteria = defineComponent({ ); })} @@ -534,6 +550,7 @@ export const SearchCriteria = defineComponent({ customState, curValue, filterNodes, + isLoading, onCustomStateChange, renderFilterItem, renderFilterGroup, @@ -542,7 +559,7 @@ export const SearchCriteria = defineComponent({ }, render() { return ( -
+
{this.customState ? (