Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: column setting about action fixed and default not cache #3441

Merged
merged 1 commit into from
Dec 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 26 additions & 7 deletions src/components/Table/src/components/settings/ColumnSetting.vue
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,18 @@
const attrs = useAttrs();
const table = useTableContext();

const props = withDefaults(
defineProps<{
/**
* 是否缓存列的设置
*/
cache?: boolean;
}>(),
{
cache: () => false,
},
);

const getPopupContainer = () => {
return isFunction(attrs.getPopupContainer) ? attrs.getPopupContainer() : getParentContainer();
};
Expand Down Expand Up @@ -168,7 +180,7 @@
// 列表列更新
tableColumnsUpdate();
// 更新列缓存
columnOptionsSave();
props.cache && columnOptionsSave();
}
});

Expand Down Expand Up @@ -197,7 +209,7 @@
// 更新 showIndexColumn
showIndexColumnUpdate(e.target.checked);
// 更新 showIndexColumn 缓存
tableSettingStore.setShowIndexColumn(e.target.checked);
props.cache && tableSettingStore.setShowIndexColumn(e.target.checked);
// 从无到有需要处理
if (e.target.checked) {
const columns = cloneDeep(table?.getColumns());
Expand All @@ -223,7 +235,7 @@
// 更新 showRowSelection
showRowSelectionUpdate(e.target.checked);
// 更新 showRowSelection 缓存
tableSettingStore.setShowRowSelection(e.target.checked);
props.cache && tableSettingStore.setShowRowSelection(e.target.checked);
};

// 更新列缓存
Expand Down Expand Up @@ -273,7 +285,7 @@
// 列表列更新
tableColumnsUpdate();
// 更新列缓存
columnOptionsSave();
props.cache && columnOptionsSave();
};

// 沿用逻辑
Expand Down Expand Up @@ -344,6 +356,13 @@
}
}

// 是否存在 action
const actionIndex = columns.findIndex((o) => o.dataIndex === 'action');
if (actionIndex > -1) {
const actionCol = columns.splice(actionIndex, 1);
columns.push(actionCol[0]);
}

// 设置列表列
tableColumnsSet(columns);
};
Expand Down Expand Up @@ -384,7 +403,7 @@
// 列表列更新
tableColumnsUpdate();
// 更新列缓存
columnOptionsSave();
props.cache && columnOptionsSave();
},
});
}
Expand Down Expand Up @@ -548,10 +567,10 @@
columnOptions.value = cloneDeep(options);

// remove消失的列、push新出现的列
diff();
props.cache && diff();

// 从缓存恢复
restore();
props.cache && restore();

// 更新表单状态
formUpdate();
Expand Down
1 change: 1 addition & 0 deletions src/components/Table/src/components/settings/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
v-if="getSetting.setting"
@columns-change="handleColumnChange"
:getPopupContainer="getTableContainer"
:cache="false"
/>
<FullScreenSetting v-if="getSetting.fullScreen" :getPopupContainer="getTableContainer" />
</div>
Expand Down