Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JSearchSelect组件文本回显问题 #7008

Closed
modefeng opened this issue Aug 1, 2024 · 6 comments
Closed

JSearchSelect组件文本回显问题 #7008

modefeng opened this issue Aug 1, 2024 · 6 comments

Comments

@modefeng
Copy link

modefeng commented Aug 1, 2024

版本号:

3.6.3

问题描述:

在data.ts中,通过defaultValue来设置使用JSearchSelect组件的字段的默认值,在详情或者编辑页面时,如果这个字段的值是空,JSearchSelect会显示为defaultValue值对应的文本,不会显示为空。

错误截图:

友情提示:

  • 未按格式要求发帖、描述过于简单的,会被直接删掉;
  • 描述问题请图文并茂,方便我们理解并快速定位问题;
  • 如果使用的不是master,请说明你使用的分支;
@zhangdaiscott
Copy link
Member

zhangdaiscott commented Aug 3, 2024

jl

@sjlei
Copy link

sjlei commented Aug 7, 2024

未复现该问题,请更新到最新版尝试,或贴出详细的复现代码

@modefeng
Copy link
Author

modefeng commented Aug 7, 2024

data.ts中组件的代码为,通过defaultValue设置默认值
{
label: '测试',
field: 'orgCode',
component: 'JSearchSelect',
defaultValue: '510107064',
componentProps: {
dict: 'organise,orgname,orgcode',
pageSize: 6,
async: true,
},
},
在打开basicModal的时候表单赋值时,如果在data中orgCode的值是null,组件显示的内容是defaultValue的510107064,而不是空。
const [registerModal, { setModalProps, closeModal }] = useModalInner(async (data) => {
//重置表单
await resetFields();
setModalProps({ confirmLoading: false, showCancelBtn: !!data?.showFooter, showOkBtn: !!data?.showFooter });
isUpdate.value = !!data?.isUpdate;
if (unref(isUpdate)) {
//表单赋值
await setFieldsValue({
...data.record,
});
}
// 隐藏底部时禁用整个表单
setProps({ disabled: !data?.showFooter });
});

@sjlei
Copy link

sjlei commented Aug 8, 2024

你可以在setFieldsValue的时候补充一下orgCode字段,因为在setFieldsValue时,参数里不存在的值是不会处理的。

//表单赋值
await setFieldsValue({
    orgCode: '',
    ...data.record,
});

image

@modefeng
Copy link
Author

modefeng commented Aug 8, 2024

我打印了data,data中是存在这个字段的
1
2
3

@sjlei
Copy link

sjlei commented Aug 8, 2024

经测试是你加了async参数的原因,该问题目前已修复,下版本发布

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants