From 4b6025cb9a3ef067680201ec3052bc651e0a0c1b Mon Sep 17 00:00:00 2001 From: 无木 <netfan@foxmail.com> Date: 星期五, 13 八月 2021 08:50:28 +0800 Subject: [PATCH] fix(table): `getSelectRows` support multi-page --- src/components/Table/src/hooks/useRowSelection.ts | 10 ++++++++-- 1 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/components/Table/src/hooks/useRowSelection.ts b/src/components/Table/src/hooks/useRowSelection.ts index ee6fa9e..f900a53 100644 --- a/src/components/Table/src/hooks/useRowSelection.ts +++ b/src/components/Table/src/hooks/useRowSelection.ts @@ -67,13 +67,19 @@ function setSelectedRowKeys(rowKeys: string[]) { selectedRowKeysRef.value = rowKeys; - selectedRowRef.value = findNodeAll( - toRaw(unref(tableData)), + const allSelectedRows = findNodeAll( + toRaw(unref(tableData)).concat(toRaw(unref(selectedRowRef))), (item) => rowKeys.includes(item[unref(getRowKey) as string]), { children: propsRef.value.childrenColumnName ?? 'children', } ); + const trueSelectedRows: any[] = []; + rowKeys.forEach((key: string) => { + const found = allSelectedRows.find((item) => item[unref(getRowKey) as string] === key); + found && trueSelectedRows.push(found); + }); + selectedRowRef.value = trueSelectedRows; } function setSelectedRows(rows: Recordable[]) { -- Gitblit v1.8.0