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 4, 2024
1 parent 841bf18 commit af4f29d
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 9 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 @@ -3668,5 +3668,6 @@
"请选择Module": "请选择Module",
"安装 Module任务提交成功": "安装 Module任务提交成功",
"仅允许同一管控区域的集群一起安装module": "仅允许同一管控区域的集群一起安装module",
"主域名,从域名,单节点必须分开查询": "主域名,从域名,单节点必须分开查询",
"这行勿动!新增翻译请在上一行添加!": ""
}
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,7 +230,7 @@
const deleteSet = new Set(deleteList);
if (addList.length) {
filterClusters({
filterClusters<SelectorModelType>({
bk_biz_id: window.PROJECT_CONFIG.BIZ_ID,
domain: addList.join(','),
}).then((clusterResultList) => {
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 af4f29d

Please sign in to comment.