Commit 5c2735346745cf91aa9812a0afbf62e4625faf40

Authored by vben
1 parent e821f4c7

fix(table): restore the property of the table

CHANGELOG.zh_CN.md
@@ -7,6 +7,7 @@ @@ -7,6 +7,7 @@
7 ### 🐛 Bug Fixes 7 ### 🐛 Bug Fixes
8 8
9 - 修复表格列配置已知问题 9 - 修复表格列配置已知问题
  10 +- 恢复 table 的`isTreeTable`属性
10 11
11 ## 2.0.0-rc.15 (2020-12-31) 12 ## 2.0.0-rc.15 (2020-12-31)
12 13
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 &#39;/@/utils/propTypes&#39;; @@ -16,6 +16,8 @@ import { propTypes } from &#39;/@/utils/propTypes&#39;;
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 // 排序方法
src/views/demo/table/TreeTable.vue
@@ -8,6 +8,7 @@ @@ -8,6 +8,7 @@
8 :dataSource="data" 8 :dataSource="data"
9 rowKey="id" 9 rowKey="id"
10 :indentSize="20" 10 :indentSize="20"
  11 + isTreeTable
11 /> 12 />
12 </div> 13 </div>
13 </template> 14 </template>