Commit 5c2735346745cf91aa9812a0afbf62e4625faf40
1 parent
e821f4c7
fix(table): restore the property of the table
Showing
5 changed files
with
12 additions
and
9 deletions
CHANGELOG.zh_CN.md
src/components/Table/src/hooks/useColumns.ts
@@ -43,19 +43,17 @@ function handleIndexColumn( | @@ -43,19 +43,17 @@ function handleIndexColumn( | ||
43 | getPaginationRef: ComputedRef<boolean | PaginationProps>, | 43 | getPaginationRef: ComputedRef<boolean | PaginationProps>, |
44 | columns: BasicColumn[] | 44 | columns: BasicColumn[] |
45 | ) { | 45 | ) { |
46 | - const { showIndexColumn, indexColumnProps } = unref(propsRef); | 46 | + const { showIndexColumn, indexColumnProps, isTreeTable } = unref(propsRef); |
47 | 47 | ||
48 | let pushIndexColumns = false; | 48 | let pushIndexColumns = false; |
49 | - columns.forEach((item) => { | ||
50 | - const { children } = item; | ||
51 | - | ||
52 | - const isTreeTable = children && children.length; | ||
53 | - | 49 | + if (unref(isTreeTable)) { |
50 | + return; | ||
51 | + } | ||
52 | + columns.forEach(() => { | ||
54 | const indIndex = columns.findIndex((column) => column.flag === INDEX_COLUMN_FLAG); | 53 | const indIndex = columns.findIndex((column) => column.flag === INDEX_COLUMN_FLAG); |
55 | - | ||
56 | - if (showIndexColumn && !isTreeTable) { | 54 | + if (showIndexColumn) { |
57 | pushIndexColumns = indIndex === -1; | 55 | pushIndexColumns = indIndex === -1; |
58 | - } else if (!showIndexColumn && !isTreeTable && indIndex !== -1) { | 56 | + } else if (!showIndexColumn && indIndex !== -1) { |
59 | columns.splice(indIndex, 1); | 57 | columns.splice(indIndex, 1); |
60 | } | 58 | } |
61 | }); | 59 | }); |
src/components/Table/src/props.ts
@@ -16,6 +16,8 @@ import { propTypes } from '/@/utils/propTypes'; | @@ -16,6 +16,8 @@ import { propTypes } from '/@/utils/propTypes'; | ||
16 | export const basicProps = { | 16 | export const basicProps = { |
17 | clickToRowSelect: propTypes.bool.def(true), | 17 | clickToRowSelect: propTypes.bool.def(true), |
18 | 18 | ||
19 | + isTreeTable: propTypes.bool.def(false), | ||
20 | + | ||
19 | tableSetting: { | 21 | tableSetting: { |
20 | type: Object as PropType<TableSetting>, | 22 | type: Object as PropType<TableSetting>, |
21 | }, | 23 | }, |
src/components/Table/src/types/table.ts
@@ -125,6 +125,7 @@ export interface TableSetting { | @@ -125,6 +125,7 @@ export interface TableSetting { | ||
125 | export interface BasicTableProps<T = any> { | 125 | export interface BasicTableProps<T = any> { |
126 | // 点击行选中 | 126 | // 点击行选中 |
127 | clickToRowSelect?: boolean; | 127 | clickToRowSelect?: boolean; |
128 | + isTreeTable?: boolean; | ||
128 | // 自定义排序方法 | 129 | // 自定义排序方法 |
129 | sortFn?: (sortInfo: SorterResult) => any; | 130 | sortFn?: (sortInfo: SorterResult) => any; |
130 | // 排序方法 | 131 | // 排序方法 |