From a5c41bea17d59dc75f34e00854843ecd6b90cd47 Mon Sep 17 00:00:00 2001 From: ShineKOT <1917095344@qq.com> Date: Thu, 3 Jul 2025 11:11:20 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E9=80=89=E6=8B=A9=E7=B1=BB=E7=BC=96=E8=BE=91=E5=99=A8=E5=80=BC?= =?UTF-8?q?=E5=9B=9E=E6=98=BE=E5=BC=82=E5=B8=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 1 + .../ibiz-picker-dropdown.tsx | 33 ++++++++----------- .../ibiz-picker-link/ibiz-picker-link.tsx | 17 +++++----- .../data-picker/ibiz-picker/ibiz-picker.tsx | 22 +++++-------- 4 files changed, 31 insertions(+), 42 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 07dee0c7a..3811ec546 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,7 @@ - 修复关系栏默认选中异常 - 修复关系分页默认选中和默认是否隐藏编辑项异常 - 修复应用启动视图未隐藏应用级别的加载提示异常 +- 修复数据选择类编辑器值回显异常 ### Added diff --git a/src/editor/data-picker/ibiz-picker-dropdown/ibiz-picker-dropdown.tsx b/src/editor/data-picker/ibiz-picker-dropdown/ibiz-picker-dropdown.tsx index 36c7bcb2c..a21458b19 100644 --- a/src/editor/data-picker/ibiz-picker-dropdown/ibiz-picker-dropdown.tsx +++ b/src/editor/data-picker/ibiz-picker-dropdown/ibiz-picker-dropdown.tsx @@ -82,37 +82,32 @@ export const IBizPickerDropDown = defineComponent({ }); const resetCurValue = () => { + const { value } = props; if (c.model.valueType === 'OBJECT') { - curValue.value = props.value - ? (props.value as IData)[c.objectNameField as string] - : null; + curValue.value = + value && c.objectNameField + ? (value as IData)[c.objectNameField] + : null; } else { - curValue.value = props.value as string; + curValue.value = value as string; } - if (props.value === null) { - curValue.value = ''; - } - const value = props.data[c.valueItem]; - refValue.value = value || (curValue.value as string); + const valueItem = props.data[c.valueItem]; + refValue.value = valueItem || curValue.value; const index = items.value.findIndex((item: IData) => - Object.is(item[c.keyName], value), + Object.is(item[c.keyName], valueItem), ); - if (index !== -1) { - return; - } + if (index !== -1) return; // items里匹配不到当前值项值时,生成自身的选项 items.value = []; - if (!isNil(props.value) && !isNil(value)) { - items.value.push({ [c.textName]: props.value, [c.keyName]: value }); + if (!isNil(props.value) && !isNil(valueItem)) { + items.value.push({ [c.textName]: props.value, [c.keyName]: valueItem }); } }; watch( () => props.value, - newVal => { - if (newVal || newVal === null) { - resetCurValue(); - } + () => { + resetCurValue(); }, { immediate: true }, ); diff --git a/src/editor/data-picker/ibiz-picker-link/ibiz-picker-link.tsx b/src/editor/data-picker/ibiz-picker-link/ibiz-picker-link.tsx index 5f93b0c2b..e15c1b205 100644 --- a/src/editor/data-picker/ibiz-picker-link/ibiz-picker-link.tsx +++ b/src/editor/data-picker/ibiz-picker-link/ibiz-picker-link.tsx @@ -71,15 +71,14 @@ export const IBizPickerLink = defineComponent({ watch( () => props.value, - (newVal, oldVal) => { - if (newVal && newVal !== oldVal) { - if (c.model.valueType === 'OBJECT') { - curValue.value = newVal - ? (newVal as IData)[c.objectNameField as string] - : ''; - } else { - curValue.value = newVal as string; - } + newVal => { + if (c.model.valueType === 'OBJECT') { + curValue.value = + newVal && c.objectNameField + ? (newVal as IData)[c.objectNameField] + : null; + } else { + curValue.value = newVal as string; } }, { immediate: true }, diff --git a/src/editor/data-picker/ibiz-picker/ibiz-picker.tsx b/src/editor/data-picker/ibiz-picker/ibiz-picker.tsx index 8f52be2a5..f635d1beb 100644 --- a/src/editor/data-picker/ibiz-picker/ibiz-picker.tsx +++ b/src/editor/data-picker/ibiz-picker/ibiz-picker.tsx @@ -73,24 +73,20 @@ export const IBizPicker = defineComponent({ }); const resetCurValue = () => { - const value = props.value; + const { value } = props; if (c.model.valueType === 'OBJECT') { - curValue.value = value - ? (value as IData)[c.objectNameField as string] - : null; + curValue.value = + value && c.objectNameField + ? (value as IData)[c.objectNameField] + : null; } else { curValue.value = value as string; } - if (value === null) { - curValue.value = ''; - } const valueItem = props.data[c.valueItem]; const index = items.value.findIndex((item: IData) => Object.is(item[c.keyName], valueItem), ); - if (index !== -1) { - return; - } + if (index !== -1) return; // items里匹配不到当前值项值时,生成自身的选项 items.value = []; if (value && !isEmpty(valueItem)) { @@ -100,10 +96,8 @@ export const IBizPicker = defineComponent({ watch( () => props.value, - newVal => { - if (newVal || newVal === null) { - resetCurValue(); - } + () => { + resetCurValue(); }, { immediate: true }, ); -- Gitee