Skip to content

Commit

Permalink
fix(table): restore the property of the table
Browse files Browse the repository at this point in the history
  • Loading branch information
anncwb committed Jan 2, 2021
1 parent e821f4c commit 5c27353
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 9 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.zh_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
### 🐛 Bug Fixes

- 修复表格列配置已知问题
- 恢复 table 的`isTreeTable`属性

## 2.0.0-rc.15 (2020-12-31)

Expand Down
16 changes: 7 additions & 9 deletions src/components/Table/src/hooks/useColumns.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,19 +43,17 @@ function handleIndexColumn(
getPaginationRef: ComputedRef<boolean | PaginationProps>,
columns: BasicColumn[]
) {
const { showIndexColumn, indexColumnProps } = unref(propsRef);
const { showIndexColumn, indexColumnProps, isTreeTable } = unref(propsRef);

let pushIndexColumns = false;
columns.forEach((item) => {
const { children } = item;

const isTreeTable = children && children.length;

if (unref(isTreeTable)) {
return;
}
columns.forEach(() => {
const indIndex = columns.findIndex((column) => column.flag === INDEX_COLUMN_FLAG);

if (showIndexColumn && !isTreeTable) {
if (showIndexColumn) {
pushIndexColumns = indIndex === -1;
} else if (!showIndexColumn && !isTreeTable && indIndex !== -1) {
} else if (!showIndexColumn && indIndex !== -1) {
columns.splice(indIndex, 1);
}
});
Expand Down
2 changes: 2 additions & 0 deletions src/components/Table/src/props.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ import { propTypes } from '/@/utils/propTypes';
export const basicProps = {
clickToRowSelect: propTypes.bool.def(true),

isTreeTable: propTypes.bool.def(false),

tableSetting: {
type: Object as PropType<TableSetting>,
},
Expand Down
1 change: 1 addition & 0 deletions src/components/Table/src/types/table.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ export interface TableSetting {
export interface BasicTableProps<T = any> {
// 点击行选中
clickToRowSelect?: boolean;
isTreeTable?: boolean;
// 自定义排序方法
sortFn?: (sortInfo: SorterResult) => any;
// 排序方法
Expand Down
1 change: 1 addition & 0 deletions src/views/demo/table/TreeTable.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
:dataSource="data"
rowKey="id"
:indentSize="20"
isTreeTable
/>
</div>
</template>
Expand Down

0 comments on commit 5c27353

Please sign in to comment.