Commit c3096e26ff24c8afd9555e676c898030664846d7

Authored by Vben
1 parent 1d7608ee

fix(table): fix table check column configuration failure close #391

CHANGELOG.zh_CN.md
... ... @@ -17,6 +17,7 @@
17 17 - 修复 Modal 组件 loadingTip 配置不生效
18 18 - 修复后台权限指令不生效
19 19 - 确保 progress 进度条正确关闭
  20 +- 修复表格勾选列配置失效问题
20 21  
21 22 ## 2.1.0 (2021-03-15)
22 23  
... ...
src/components/Table/src/components/settings/ColumnSetting.vue
... ... @@ -113,6 +113,7 @@
113 113  
114 114 import { isNullAndUnDef } from '/@/utils/is';
115 115 import { getPopupContainer } from '/@/utils';
  116 + import { omit } from 'lodash-es';
116 117  
117 118 import type { BasicColumn } from '../../types/table';
118 119  
... ... @@ -147,7 +148,7 @@
147 148 const { t } = useI18n();
148 149 const table = useTableContext();
149 150  
150   - const defaultRowSelection = table.getRowSelection();
  151 + const defaultRowSelection = omit(table.getRowSelection(), 'selectedRowKeys');
151 152 let inited = false;
152 153  
153 154 const cachePlainOptions = ref<Options[]>([]);
... ...
src/components/Table/src/hooks/useRowSelection.ts
... ... @@ -16,10 +16,11 @@ export function useRowSelection(
16 16 if (!rowSelection) {
17 17 return null;
18 18 }
  19 +
19 20 return {
20 21 selectedRowKeys: unref(selectedRowKeysRef),
21 22 hideDefaultSelections: false,
22   - onChange: (selectedRowKeys: string[], selectedRows: any[]) => {
  23 + onChange: (selectedRowKeys: string[], selectedRows: Recordable[]) => {
23 24 selectedRowKeysRef.value = selectedRowKeys;
24 25 selectedRowRef.value = selectedRows;
25 26 emit('selection-change', {
... ... @@ -27,7 +28,7 @@ export function useRowSelection(
27 28 rows: selectedRows,
28 29 });
29 30 },
30   - ...rowSelection,
  31 + ...(rowSelection === undefined ? {} : rowSelection),
31 32 };
32 33 });
33 34  
... ...