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

defaultValue类型为number时, 点击编辑 setFieldsValue的值会被覆盖掉 #3274

Closed
4 tasks
mxchhz opened this issue Nov 11, 2023 · 4 comments · Fixed by #3288
Closed
4 tasks

defaultValue类型为number时, 点击编辑 setFieldsValue的值会被覆盖掉 #3274

mxchhz opened this issue Nov 11, 2023 · 4 comments · Fixed by #3288

Comments

@mxchhz
Copy link

mxchhz commented Nov 11, 2023

⚠️ 重要 ⚠️ 在进一步操作之前,请检查下列选项。如果您忽视此模板或者没有提供关键信息,您的 Issue 将直接被关闭

  • 已阅读 文档.
  • 确保您的代码已是最新或者所报告的 Bug 在最新版本中可以重现. (部分 Bug 可能已经在最近的代码中修复)
  • 已在 Issues 中搜索了相关的关键词
  • 不是 ant design vue 组件库的 Bug

描述 Bug

请清晰地描述此 Bug 的具体表现。

复现 Bug

请描述在演示页面中复现 Bug 的详细步骤,以确保我们可以理解并定位问题。部分 Bug 如果未在 Demo 中涉及,请务必提供关键代码

系统信息

  • 操作系统:
  • Node 版本:
  • 包管理器 (npm/yarn/pnpm) 及其版本:

{
field: 'orderNo',
label: '排序',
component: 'InputNumber',
defaultValue: 100,// 这里是数字
required: true,
}

src\components\Form\src\hooks\useFormEvents.ts
315行 isEmpty(currentFieldsValue[item.field])) 这里好像不对,大佬们看看什么问题

@qwecxzpoi
Copy link

setFiledValue 本来就会将值修改了呀。你可以再描述的清楚一点

@mxchhz
Copy link
Author

mxchhz commented Nov 12, 2023

setFiledValue 本来就会将值修改了呀。你可以再描述的清楚一点

不好意思哈,这是复现条件:

  • formSchema 中 component: 'InputNumber'或'RadioButtonGroup',并设置了 defaultValue:123(number 类型)

这两个组件,只要 defaultValue 是 number 类型就会有问题

// menu.data.ts
{
  field: 'orderNo',
  label: '排序',
  component: 'InputNumber',
  defaultValue: 123,
}

// MenuDrawer.vue
const [registerDrawer, { setDrawerProps, closeDrawer }] = useDrawerInner(async (data) => {
  resetFields();
  setDrawerProps({ confirmLoading: false });
  isUpdate.value = !!data?.isUpdate;
  if (unref(isUpdate)) {
    // setFieldsValue({
    //   ...data.record,
    // }); // 点击编辑,这里数据设置不上

    setFieldsValue({
      orderNo: 1,
    }); // 失败 orderNo=1 => orderNo=123;先是设置1成功,然后又覆盖成了默认值123

    // setFieldsValue({
    //   orderNo: '2',
    // }); // 成功 orderNo='2'
  }
  const treeData = await getMenuList();
  updateSchema({
    field: 'parentMenu',
    componentProps: { treeData },
  });
});

@mxchhz
Copy link
Author

mxchhz commented Nov 12, 2023

版本是最新的,昨晚上克隆的

@zwtvip
Copy link

zwtvip commented Nov 12, 2023

版本是最新的,昨晚上克隆的

是有这个问题,我遇到在弹框中,Select的defaultValue如果是number 类型 用setFieldsValue也设置不上值

@github-actions github-actions bot locked and limited conversation to collaborators Aug 13, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants