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

[Table] 可编辑表格编辑组件之间的联动不生效 #2558

Closed
kuoruan opened this issue Oct 19, 2023 · 7 comments
Closed

[Table] 可编辑表格编辑组件之间的联动不生效 #2558

kuoruan opened this issue Oct 19, 2023 · 7 comments
Labels
📒 documentation Improvements or additions to documentation to be published fixed, not be published

Comments

@kuoruan
Copy link

kuoruan commented Oct 19, 2023

tdesign-react 版本

1.2.6

重现链接

https://tdesign.tencent.com/react/components/table?tab=demo#%E5%8F%AF%E7%BC%96%E8%BE%91%E8%A1%8C%E7%9A%84%E8%A1%A8%E6%A0%BC

重现步骤

申请事项字段:

{
  title: '申请事项',
  colKey: 'letters',
  cell: ({ row }) => row?.letters?.join('、'),
  width: 200,
  edit: {
    component: Select,
    // props, 透传全部属性到 Select 组件
    // props 为函数时,参数有:col, row, rowIndex, colIndex, editedRow。一般用于实现编辑组件之间的联动
    props: ({ editedRow }) => ({
      multiple: true,
      minCollapsedNum: 1,
      autoWidth: true,
      options: [
        { label: '宣传物料制作费用', value: '宣传物料制作费用' },
        { label: 'algolia 服务报销', value: 'algolia 服务报销' },
        // 如果状态选择了 已过期,则 Letters 隐藏 G 和 H
        { label: '相关周边制作费', value: '相关周边制作费', show: () => editedRow.status !== 0 },
        { label: '激励奖品快递费', value: '激励奖品快递费', show: () => editedRow.status !== 0 },
      ].filter((t) => (t.show === undefined ? true : t.show())),
    }),
    showEditIcon: false,
    // 校验规则,此处同 Form 表单
    rules: [{ validator: (val) => val && val.length < 3, message: '数量不能超过 2 个' }],
  },
},

按代码所示,应该是 status 字段发生变化时,letters 的 options 发生变化,但实际修改申请状态时,申请事项的选项并没有发生变化。

期望结果

可编辑组件间能正常实现联动

实际结果

没有任何变化

框架版本

React(18.2.0)

浏览器版本

Chrome(118.0.5993.89)

系统版本

Windows 11

Node版本

Node(16.20.2)

补充说明

No response

@github-actions
Copy link
Contributor

👋 @kuoruan,感谢给 TDesign 提出了 issue。
请根据 issue 模版确保背景信息的完善,我们将调查并尽快回复你。

@github-actions
Copy link
Contributor

♥️ 有劳 @yunfeic @tengcaifeng @Yacent @basecss 尽快确认问题。
确认有效后将下一步计划和可能需要的时间回复给 @kuoruan

@HaixingOoO HaixingOoO added 🐞 bug Something isn't working 💭 discussion we are discussing usage and removed 🐞 bug Something isn't working 💭 discussion we are discussing labels Oct 19, 2023
@HaixingOoO
Copy link
Collaborator

@kuoruan 您好,我看了一下是文档的写法有点问题,实际功能是可以的,感兴趣的话可以提pr!!!

@HaixingOoO HaixingOoO added the 📒 documentation Improvements or additions to documentation label Oct 19, 2023
@kuoruan
Copy link
Author

kuoruan commented Oct 19, 2023

@Zzongke 能给一下正确的写法吗?现在的实现只有在修改被提交之后的再次渲染才能联动相邻组件,但是通常会要求一个组件值发生变化之后马上同步给其他组件

@HaixingOoO
Copy link
Collaborator

截屏2023-10-19 23 05 39

现在这个就是编辑行的时候触发的事件是吧,然后你看了下面全量数据效验,也就是要单行效验就去掉那个判断,然后setData(data)改成setData([...data])就可以修改单行时更新数据了,希望能帮到你!

截屏2023-10-19 23 09 38

这里的文档写错了,应该是判断!==1才不显示。

@HaixingOoO HaixingOoO added the good first issue Good for newcomers label Oct 19, 2023
@kuoruan kuoruan closed this as completed Oct 20, 2023
@HaixingOoO HaixingOoO reopened this Oct 20, 2023
@HaixingOoO
Copy link
Collaborator

@kuoruan 欢迎提交pr解決文档描述错误,暂时先不关闭这个issue。

@uyarn
Copy link
Collaborator

uyarn commented Nov 15, 2023

fixed in 1.3.1

@uyarn uyarn closed this as completed Nov 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
📒 documentation Improvements or additions to documentation to be published fixed, not be published
Projects
None yet
Development

No branches or pull requests

3 participants