From f00f16dd129bba9b4d2d9389f6ced635329b5566 Mon Sep 17 00:00:00 2001 From: 3octaves <873551943@qq.com> Date: Tue, 3 Dec 2024 17:54:52 +0800 Subject: [PATCH] =?UTF-8?q?fix(frontend):=20=E6=9D=83=E9=99=90=E6=9F=A5?= =?UTF-8?q?=E8=AF=A2=E9=A1=B5=E6=9F=A5=E8=AF=A2=E6=9D=A1=E4=BB=B6=E6=89=8B?= =?UTF-8?q?=E8=BE=93=E6=97=A0=E6=B3=95=E6=9F=A5=E8=AF=A2=20#8207?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- dbm-ui/frontend/src/locales/zh-cn.json | 1 + dbm-ui/frontend/src/services/source/dbbase.ts | 2 +- .../options/components/item/Domain.vue | 31 +++++++++++++------ 3 files changed, 23 insertions(+), 11 deletions(-) diff --git a/dbm-ui/frontend/src/locales/zh-cn.json b/dbm-ui/frontend/src/locales/zh-cn.json index 851e746f69..dd25416b57 100644 --- a/dbm-ui/frontend/src/locales/zh-cn.json +++ b/dbm-ui/frontend/src/locales/zh-cn.json @@ -3711,5 +3711,6 @@ "删除规则后将不能恢复,请谨慎操作": "删除规则后将不能恢复,请谨慎操作", "请输入访问DB名_以字母开头_支持字母_数字_下划线_多个使用英文逗号_分号或换行分隔": "请输入访问DB名,以字母开头,支持字母,数字,下划线。多个使用英文逗号、分号或换行分隔", "单据协助设置": "单据协助设置", + "主域名,从域名,单节点必须分开查询": "主域名,从域名,单节点必须分开查询", "这行勿动!新增翻译请在上一行添加!": "" } diff --git a/dbm-ui/frontend/src/services/source/dbbase.ts b/dbm-ui/frontend/src/services/source/dbbase.ts index 6c16badaf8..c751f58c63 100644 --- a/dbm-ui/frontend/src/services/source/dbbase.ts +++ b/dbm-ui/frontend/src/services/source/dbbase.ts @@ -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(`${path}/filter_clusters/`, params); } diff --git a/dbm-ui/frontend/src/views/permission-retrieve/components/options/components/item/Domain.vue b/dbm-ui/frontend/src/views/permission-retrieve/components/options/components/item/Domain.vue index 839e69d669..0c2896a91d 100644 --- a/dbm-ui/frontend/src/views/permission-retrieve/components/options/components/item/Domain.vue +++ b/dbm-ui/frontend/src/views/permission-retrieve/components/options/components/item/Domain.vue @@ -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); @@ -142,6 +152,12 @@ 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>) => { selectedClusters.value = selected; const domainList = Object.keys(selected).reduce( @@ -149,10 +165,7 @@ [], ); 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'); }; @@ -217,9 +230,9 @@ const deleteSet = new Set(deleteList); if (addList.length) { - filterClusters({ + filterClusters({ bk_biz_id: window.PROJECT_CONFIG.BIZ_ID, - exact_domain: addList.join(','), + domain: addList.join(','), }).then((clusterResultList) => { // 删除时,删去已选集群 deleteSelectedCluster(deleteSet); @@ -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'); @@ -253,6 +263,7 @@ const clusterList = selectedClusters.value[key]; selectedClusters.value[key] = clusterList.filter((clusterItem) => !deleteSet.has(clusterItem.master_domain)); }); + updateClusterInfo(); } };