diff --git a/packages/search-criteria/src/code-editor/code-editor.tsx b/packages/search-criteria/src/code-editor/code-editor.tsx index 4c599adb2ec4afd593a92f13a6151f92ee4a0ac8..9a3038e45c70cac2c8cfaba0e2aa0dca26f05032 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 4dd2629e4e4ea93b4afb3d0e48d801f87364172f..1cc462ceded7dcd4ec67acbc873038b3ece670c4 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 80a870f0758d087fa4d4f96b9cbf951cd20643d3..88dce5a8de0d5b65203fa55a47bea95ff7194f94 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 ? (