Commit 4b6025cb9a3ef067680201ec3052bc651e0a0c1b

Authored by 无木
1 parent 2f6d133b

fix(table): `getSelectRows` support multi-page

getSelectRows支持跨页选择

close: #914
CHANGELOG.zh_CN.md
... ... @@ -12,6 +12,7 @@
12 12 - 修复可编辑单元格未能正确显示`0`值的问题
13 13 - 修复 selection-change 事件在取消勾选时未能正确触发的问题
14 14 - 修复浅色主题下的全屏状态背景颜色不正确的问题
  15 + - 修复`getSelectRows`不支持远程数据跨页选择时获取完整数据的问题
15 16 - **Qrcode** 修复二维码组件在创建时未能及时绘制的问题
16 17 - **BasicModal** 修复`helpMessage`属性不起作用的问题
17 18  
... ...
src/components/Table/src/hooks/useRowSelection.ts
... ... @@ -67,13 +67,19 @@ export function useRowSelection(
67 67  
68 68 function setSelectedRowKeys(rowKeys: string[]) {
69 69 selectedRowKeysRef.value = rowKeys;
70   - selectedRowRef.value = findNodeAll(
71   - toRaw(unref(tableData)),
  70 + const allSelectedRows = findNodeAll(
  71 + toRaw(unref(tableData)).concat(toRaw(unref(selectedRowRef))),
72 72 (item) => rowKeys.includes(item[unref(getRowKey) as string]),
73 73 {
74 74 children: propsRef.value.childrenColumnName ?? 'children',
75 75 }
76 76 );
  77 + const trueSelectedRows: any[] = [];
  78 + rowKeys.forEach((key: string) => {
  79 + const found = allSelectedRows.find((item) => item[unref(getRowKey) as string] === key);
  80 + found && trueSelectedRows.push(found);
  81 + });
  82 + selectedRowRef.value = trueSelectedRows;
77 83 }
78 84  
79 85 function setSelectedRows(rows: Recordable[]) {
... ...