diff --git a/CHANGELOG.zh_CN.md b/CHANGELOG.zh_CN.md index 71561d2ba45624e0df3e423548ec000703b329a0..e85fb3f8021394484f86140740d0882e11768846 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 7292881462fdd3fc60034cb7451fc1be88f6e0bc..b5690659cee313a3df32540985b18d980f6acd11 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 45c46e31eae30c0b15d2169d67e430344891e22b..436b991d9859a72b5da6bc6200f6446eeff93af9 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), }; });