mirror of
https://github.com/vbenjs/vben-admin-thin-next.git
synced 2025-02-03 02:18:40 +08:00
fix(table): fix getSelectRows
for treeTable
修复getSelectRows不支持树形表格子级数据的问题 fixed: #1003
This commit is contained in:
parent
d2c361803b
commit
f2b8bb43a0
@ -13,6 +13,7 @@
|
|||||||
- 修复全屏模式下看不到子组件弹出层(popconfirm 以及 select、treeSelect 等编辑组件)的问题
|
- 修复全屏模式下看不到子组件弹出层(popconfirm 以及 select、treeSelect 等编辑组件)的问题
|
||||||
- 修复启用`expandRowByClick`时,点击不可展开的行可能会导致样式错误的问题
|
- 修复启用`expandRowByClick`时,点击不可展开的行可能会导致样式错误的问题
|
||||||
- 修复`pagination`属性动态改变不生效的问题
|
- 修复`pagination`属性动态改变不生效的问题
|
||||||
|
- 修复`getSelectRows`不支持树形表格子级数据的问题
|
||||||
- **Dark Theme** 黑暗主题下的配色问题修正
|
- **Dark Theme** 黑暗主题下的配色问题修正
|
||||||
- 修复`Tree`组件被选中节点的背景颜色
|
- 修复`Tree`组件被选中节点的背景颜色
|
||||||
- 修复`Alert`组件的颜色配置
|
- 修复`Alert`组件的颜色配置
|
||||||
|
@ -1,8 +1,9 @@
|
|||||||
import { isFunction } from '/@/utils/is';
|
import { isFunction } from '/@/utils/is';
|
||||||
import type { BasicTableProps, TableRowSelection } from '../types/table';
|
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 { ROW_KEY } from '../const';
|
||||||
import { omit } from 'lodash-es';
|
import { omit } from 'lodash-es';
|
||||||
|
import { findNodeAll } from '/@/utils/helper/treeHelper';
|
||||||
|
|
||||||
export function useRowSelection(
|
export function useRowSelection(
|
||||||
propsRef: ComputedRef<BasicTableProps>,
|
propsRef: ComputedRef<BasicTableProps>,
|
||||||
@ -21,11 +22,12 @@ export function useRowSelection(
|
|||||||
return {
|
return {
|
||||||
selectedRowKeys: unref(selectedRowKeysRef),
|
selectedRowKeys: unref(selectedRowKeysRef),
|
||||||
hideDefaultSelections: false,
|
hideDefaultSelections: false,
|
||||||
onChange: (selectedRowKeys: string[], selectedRows: Recordable[]) => {
|
onChange: (selectedRowKeys: string[]) => {
|
||||||
selectedRowKeysRef.value = selectedRowKeys;
|
setSelectedRowKeys(selectedRowKeys);
|
||||||
selectedRowRef.value = selectedRows;
|
// 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[]) {
|
function setSelectedRowKeys(rowKeys: string[]) {
|
||||||
selectedRowKeysRef.value = rowKeys;
|
selectedRowKeysRef.value = rowKeys;
|
||||||
|
selectedRowRef.value = findNodeAll(
|
||||||
const rows = toRaw(unref(tableData)).filter((item) =>
|
toRaw(unref(tableData)),
|
||||||
rowKeys.includes(item[unref(getRowKey) as string])
|
(item) => rowKeys.includes(item[unref(getRowKey) as string]),
|
||||||
|
{
|
||||||
|
children: propsRef.value.childrenColumnName ?? 'children',
|
||||||
|
}
|
||||||
);
|
);
|
||||||
selectedRowRef.value = rows;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function setSelectedRows(rows: Recordable[]) {
|
function setSelectedRows(rows: Recordable[]) {
|
||||||
|
Loading…
Reference in New Issue
Block a user