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: 自定义上报回显保存 #4627

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
22 changes: 19 additions & 3 deletions bklog/web/src/mixins/storage-mixin.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,12 @@ export default {
watch: {
'formData.storage_cluster_id': {
handler(newVal, oldVal) {
if (oldVal) {
const oldRes = this.storageList.find(res => res.storage_cluster_id === oldVal);
if (oldRes) {
this.handlerSetFormData(oldRes);
}
}
this.storageList.forEach(res => {
if (res.storage_cluster_id === newVal) {
this.selectedStorageCluster = res; // 当前选择的存储集群
Expand Down Expand Up @@ -179,13 +185,23 @@ export default {
this.basicLoading = false;
}
},
/**
* @desc: 在切换前保存之前的选择,并在展示时优先展示保存的选择
* @param {*} res // 旧选项对应的存储集群
*/
handlerSetFormData(res) {
const { retention, storage_replies, es_shards } = this.formData;
res.setup_config.retention = retention // 过期时间
res.setup_config.storage_replies = storage_replies //副本数
res.setup_config.es_shards = es_shards // 分片数
},
// 选择存储集群
handleSelectStorageCluster(res) {
// 因为有最大天数限制,不同集群限制可能不同,所以切换集群时展示默认
const { setup_config: setupConfig } = res;
this.formData.retention = setupConfig?.retention_days_default || '7';
this.formData.storage_replies = setupConfig?.number_of_replicas_default || 0;
this.formData.es_shards = setupConfig?.es_shards_default || 0;
this.formData.retention = setupConfig?.retention || setupConfig?.retention_days_default || '7';
this.formData.storage_replies = setupConfig?.storage_replies || setupConfig?.number_of_replicas_default || 0;
this.formData.es_shards = setupConfig?.es_shards || setupConfig?.es_shards_default || 0;
this.replicasMax = setupConfig?.number_of_replicas_max || 0;
this.shardsMax = setupConfig?.es_shards_max || 1;
this.formData.allocation_min_days = '0';
Expand Down
Loading