Commit 4b6025cb9a3ef067680201ec3052bc651e0a0c1b
1 parent
2f6d133b
fix(table): `getSelectRows` support multi-page
getSelectRows支持跨页选择 close: #914
Showing
2 changed files
with
9 additions
and
2 deletions
CHANGELOG.zh_CN.md
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[]) { | ... | ... |