Skip to content

Commit

Permalink
fix(frontend): 权限查询页查询条件手输无法查询 TencentBlueKing#8207
Browse files Browse the repository at this point in the history
  • Loading branch information
3octaves committed Dec 9, 2024
1 parent 5a0801a commit f00f16d
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 11 deletions.
1 change: 1 addition & 0 deletions dbm-ui/frontend/src/locales/zh-cn.json
Original file line number Diff line number Diff line change
Expand Up @@ -3711,5 +3711,6 @@
"删除规则后将不能恢复,请谨慎操作": "删除规则后将不能恢复,请谨慎操作",
"请输入访问DB名_以字母开头_支持字母_数字_下划线_多个使用英文逗号_分号或换行分隔": "请输入访问DB名,以字母开头,支持字母,数字,下划线。多个使用英文逗号、分号或换行分隔",
"单据协助设置": "单据协助设置",
"主域名,从域名,单节点必须分开查询": "主域名,从域名,单节点必须分开查询",
"这行勿动!新增翻译请在上一行添加!": ""
}
2 changes: 1 addition & 1 deletion dbm-ui/frontend/src/services/source/dbbase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export function filterClusters<
master_domain: string;
status: string;
},
>(params: { bk_biz_id: number; exact_domain?: string; cluster_ids?: string }) {
>(params: { bk_biz_id: number; exact_domain?: string; cluster_ids?: string; domain?: string }) {
return http.get<T[]>(`${path}/filter_clusters/`, params);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,16 @@
return ipList.length <= 20;
},
},
{
message: t('主域名,从域名,单节点必须分开查询'),
validator: () => {
if (props.accountType === AccountTypes.MYSQL) {
const nonEmptyList = Object.values(selectedClusters.value).filter((selectItem) => selectItem.length > 0);
return nonEmptyList.length <= 1;
}
return true;
},
},
];
const clusterSelectorShow = ref(false);
Expand All @@ -142,17 +152,20 @@
const disableClusterSubmitMethod = (clusterList: string[]) =>
clusterList.length <= 20 ? false : t('至多n台', { n: 20 });
const updateClusterInfo = () => {
const clusterList = Object.values(selectedClusters.value).find((clusterList) => clusterList.length > 0);
clusterType.value = (clusterList?.[0].cluster_type || ClusterTypes.TENDBSINGLE) as ClusterTypes;
isMaster.value = !selectedClusters.value?.tendbhaSlave?.length;
};
const handleClusterSelectorChange = (selected: Record<string, Array<SelectorModelType>>) => {
selectedClusters.value = selected;
const domainList = Object.keys(selected).reduce<string[]>(
(prevList, key) => prevList.concat(selected[key].map((item) => item.master_domain)),
[],
);
modelValue.value = domainList.join(',');
const clusterList = Object.values(selected).find((clusterList) => clusterList.length > 0);
clusterType.value = (clusterList?.[0].cluster_type || ClusterTypes.TENDBSINGLE) as ClusterTypes;
isMaster.value = !selectedClusters.value?.tendbhaSlave?.length;
updateClusterInfo();
emits('change');
};
Expand Down Expand Up @@ -217,9 +230,9 @@
const deleteSet = new Set(deleteList);
if (addList.length) {
filterClusters({
filterClusters<SelectorModelType>({
bk_biz_id: window.PROJECT_CONFIG.BIZ_ID,
exact_domain: addList.join(','),
domain: addList.join(','),
}).then((clusterResultList) => {
// 删除时,删去已选集群
deleteSelectedCluster(deleteSet);
Expand All @@ -230,10 +243,7 @@
selected[clusterItem.cluster_type] = selected[clusterItem.cluster_type].concat(clusterItem);
});
selectedClusters.value = selected;
const clusterList = Object.values(selected).find((clusterList) => clusterList.length > 0);
clusterType.value = (clusterList?.[0].cluster_type || ClusterTypes.TENDBSINGLE) as ClusterTypes;
isMaster.value = !selectedClusters.value?.tendbhaSlave?.length;
updateClusterInfo();
nextTick(() => {
emits('change');
Expand All @@ -253,6 +263,7 @@
const clusterList = selectedClusters.value[key];
selectedClusters.value[key] = clusterList.filter((clusterItem) => !deleteSet.has(clusterItem.master_domain));
});
updateClusterInfo();
}
};
Expand Down

0 comments on commit f00f16d

Please sign in to comment.