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 7 ### 🐛 Bug Fixes
8 8  
9 9 - 修复表格列配置已知问题
  10 +- 恢复 table 的`isTreeTable`属性
10 11  
11 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 43 getPaginationRef: ComputedRef<boolean | PaginationProps>,
44 44 columns: BasicColumn[]
45 45 ) {
46   - const { showIndexColumn, indexColumnProps } = unref(propsRef);
  46 + const { showIndexColumn, indexColumnProps, isTreeTable } = unref(propsRef);
47 47  
48 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 53 const indIndex = columns.findIndex((column) => column.flag === INDEX_COLUMN_FLAG);
55   -
56   - if (showIndexColumn && !isTreeTable) {
  54 + if (showIndexColumn) {
57 55 pushIndexColumns = indIndex === -1;
58   - } else if (!showIndexColumn && !isTreeTable && indIndex !== -1) {
  56 + } else if (!showIndexColumn && indIndex !== -1) {
59 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 16 export const basicProps = {
17 17 clickToRowSelect: propTypes.bool.def(true),
18 18  
  19 + isTreeTable: propTypes.bool.def(false),
  20 +
19 21 tableSetting: {
20 22 type: Object as PropType<TableSetting>,
21 23 },
... ...
src/components/Table/src/types/table.ts
... ... @@ -125,6 +125,7 @@ export interface TableSetting {
125 125 export interface BasicTableProps<T = any> {
126 126 // 点击行选中
127 127 clickToRowSelect?: boolean;
  128 + isTreeTable?: boolean;
128 129 // 自定义排序方法
129 130 sortFn?: (sortInfo: SorterResult) => any;
130 131 // 排序方法
... ...
src/views/demo/table/TreeTable.vue
... ... @@ -8,6 +8,7 @@
8 8 :dataSource="data"
9 9 rowKey="id"
10 10 :indentSize="20"
  11 + isTreeTable
11 12 />
12 13 </div>
13 14 </template>
... ...