From c3096e26ff24c8afd9555e676c898030664846d7 Mon Sep 17 00:00:00 2001 From: Vben Date: Sat, 20 Mar 2021 21:45:43 +0800 Subject: [PATCH] fix(table): fix table check column configuration failure close #391 --- CHANGELOG.zh_CN.md | 1 + .../Table/src/components/settings/ColumnSetting.vue | 3 ++- src/components/Table/src/hooks/useRowSelection.ts | 5 +++-- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.zh_CN.md b/CHANGELOG.zh_CN.md index 71561d2b..e85fb3f8 100644 --- a/CHANGELOG.zh_CN.md +++ b/CHANGELOG.zh_CN.md @@ -17,6 +17,7 @@ - 修复 Modal 组件 loadingTip 配置不生效 - 修复后台权限指令不生效 - 确保 progress 进度条正确关闭 +- 修复表格勾选列配置失效问题 ## 2.1.0 (2021-03-15) diff --git a/src/components/Table/src/components/settings/ColumnSetting.vue b/src/components/Table/src/components/settings/ColumnSetting.vue index 72928814..b5690659 100644 --- a/src/components/Table/src/components/settings/ColumnSetting.vue +++ b/src/components/Table/src/components/settings/ColumnSetting.vue @@ -113,6 +113,7 @@ import { isNullAndUnDef } from '/@/utils/is'; import { getPopupContainer } from '/@/utils'; + import { omit } from 'lodash-es'; import type { BasicColumn } from '../../types/table'; @@ -147,7 +148,7 @@ const { t } = useI18n(); const table = useTableContext(); - const defaultRowSelection = table.getRowSelection(); + const defaultRowSelection = omit(table.getRowSelection(), 'selectedRowKeys'); let inited = false; const cachePlainOptions = ref([]); diff --git a/src/components/Table/src/hooks/useRowSelection.ts b/src/components/Table/src/hooks/useRowSelection.ts index 45c46e31..436b991d 100644 --- a/src/components/Table/src/hooks/useRowSelection.ts +++ b/src/components/Table/src/hooks/useRowSelection.ts @@ -16,10 +16,11 @@ export function useRowSelection( if (!rowSelection) { return null; } + return { selectedRowKeys: unref(selectedRowKeysRef), hideDefaultSelections: false, - onChange: (selectedRowKeys: string[], selectedRows: any[]) => { + onChange: (selectedRowKeys: string[], selectedRows: Recordable[]) => { selectedRowKeysRef.value = selectedRowKeys; selectedRowRef.value = selectedRows; emit('selection-change', { @@ -27,7 +28,7 @@ export function useRowSelection( rows: selectedRows, }); }, - ...rowSelection, + ...(rowSelection === undefined ? {} : rowSelection), }; });