diff --git a/CHANGELOG.zh_CN.md b/CHANGELOG.zh_CN.md index bef9028f76a30144991e597f8801435fbe844807..00248fda7a1b8cad8110e6fa046d73e39813ec8e 100644 --- a/CHANGELOG.zh_CN.md +++ b/CHANGELOG.zh_CN.md @@ -13,6 +13,7 @@ - 修复全屏模式下看不到子组件弹出层(popconfirm 以及 select、treeSelect 等编辑组件)的问题 - 修复启用`expandRowByClick`时,点击不可展开的行可能会导致样式错误的问题 - 修复`pagination`属性动态改变不生效的问题 + - 修复`getSelectRows`不支持树形表格子级数据的问题 - **Dark Theme** 黑暗主题下的配色问题修正 - 修复`Tree`组件被选中节点的背景颜色 - 修复`Alert`组件的颜色配置 diff --git a/src/components/Table/src/hooks/useRowSelection.ts b/src/components/Table/src/hooks/useRowSelection.ts index b984e91eb44f4bb0ba1abe2930d9c0ad4f114c70..f8a1447e84b530b0a5e8f5b02fe5bf6c48de5320 100644 --- a/src/components/Table/src/hooks/useRowSelection.ts +++ b/src/components/Table/src/hooks/useRowSelection.ts @@ -1,8 +1,9 @@ import { isFunction } from '/@/utils/is'; import type { BasicTableProps, TableRowSelection } from '../types/table'; -import { computed, ref, unref, ComputedRef, Ref, toRaw, watch, nextTick } from 'vue'; +import { computed, ComputedRef, nextTick, Ref, ref, toRaw, unref, watch } from 'vue'; import { ROW_KEY } from '../const'; import { omit } from 'lodash-es'; +import { findNodeAll } from '/@/utils/helper/treeHelper'; export function useRowSelection( propsRef: ComputedRef, @@ -21,11 +22,12 @@ export function useRowSelection( return { selectedRowKeys: unref(selectedRowKeysRef), hideDefaultSelections: false, - onChange: (selectedRowKeys: string[], selectedRows: Recordable[]) => { - selectedRowKeysRef.value = selectedRowKeys; - selectedRowRef.value = selectedRows; + onChange: (selectedRowKeys: string[]) => { + setSelectedRowKeys(selectedRowKeys); + // selectedRowKeysRef.value = selectedRowKeys; + // selectedRowRef.value = selectedRows; }, - ...omit(rowSelection === undefined ? {} : rowSelection, ['onChange']), + ...omit(rowSelection, ['onChange']), }; }); @@ -64,11 +66,13 @@ export function useRowSelection( function setSelectedRowKeys(rowKeys: string[]) { selectedRowKeysRef.value = rowKeys; - - const rows = toRaw(unref(tableData)).filter((item) => - rowKeys.includes(item[unref(getRowKey) as string]) + selectedRowRef.value = findNodeAll( + toRaw(unref(tableData)), + (item) => rowKeys.includes(item[unref(getRowKey) as string]), + { + children: propsRef.value.childrenColumnName ?? 'children', + } ); - selectedRowRef.value = rows; } function setSelectedRows(rows: Recordable[]) {