fix(table): restore the property of the table

This commit is contained in:
vben 2021-01-02 22:34:32 +08:00
parent e821f4c706
commit 5c27353467
5 changed files with 12 additions and 9 deletions

View File

@ -7,6 +7,7 @@
### 🐛 Bug Fixes ### 🐛 Bug Fixes
- 修复表格列配置已知问题 - 修复表格列配置已知问题
- 恢复 table 的`isTreeTable`属性
## 2.0.0-rc.15 (2020-12-31) ## 2.0.0-rc.15 (2020-12-31)

View File

@ -43,19 +43,17 @@ function handleIndexColumn(
getPaginationRef: ComputedRef<boolean | PaginationProps>, getPaginationRef: ComputedRef<boolean | PaginationProps>,
columns: BasicColumn[] columns: BasicColumn[]
) { ) {
const { showIndexColumn, indexColumnProps } = unref(propsRef); const { showIndexColumn, indexColumnProps, isTreeTable } = unref(propsRef);
let pushIndexColumns = false; let pushIndexColumns = false;
columns.forEach((item) => { if (unref(isTreeTable)) {
const { children } = item; return;
}
const isTreeTable = children && children.length; columns.forEach(() => {
const indIndex = columns.findIndex((column) => column.flag === INDEX_COLUMN_FLAG); const indIndex = columns.findIndex((column) => column.flag === INDEX_COLUMN_FLAG);
if (showIndexColumn) {
if (showIndexColumn && !isTreeTable) {
pushIndexColumns = indIndex === -1; pushIndexColumns = indIndex === -1;
} else if (!showIndexColumn && !isTreeTable && indIndex !== -1) { } else if (!showIndexColumn && indIndex !== -1) {
columns.splice(indIndex, 1); columns.splice(indIndex, 1);
} }
}); });

View File

@ -16,6 +16,8 @@ import { propTypes } from '/@/utils/propTypes';
export const basicProps = { export const basicProps = {
clickToRowSelect: propTypes.bool.def(true), clickToRowSelect: propTypes.bool.def(true),
isTreeTable: propTypes.bool.def(false),
tableSetting: { tableSetting: {
type: Object as PropType<TableSetting>, type: Object as PropType<TableSetting>,
}, },

View File

@ -125,6 +125,7 @@ export interface TableSetting {
export interface BasicTableProps<T = any> { export interface BasicTableProps<T = any> {
// 点击行选中 // 点击行选中
clickToRowSelect?: boolean; clickToRowSelect?: boolean;
isTreeTable?: boolean;
// 自定义排序方法 // 自定义排序方法
sortFn?: (sortInfo: SorterResult) => any; sortFn?: (sortInfo: SorterResult) => any;
// 排序方法 // 排序方法

View File

@ -8,6 +8,7 @@
:dataSource="data" :dataSource="data"
rowKey="id" rowKey="id"
:indentSize="20" :indentSize="20"
isTreeTable
/> />
</div> </div>
</template> </template>