diff --git a/dbm-ui/frontend/src/locales/zh-cn.json b/dbm-ui/frontend/src/locales/zh-cn.json index 5dea872cb4..bc8be72d6d 100644 --- a/dbm-ui/frontend/src/locales/zh-cn.json +++ b/dbm-ui/frontend/src/locales/zh-cn.json @@ -3675,5 +3675,6 @@ "默认协作人": "默认协作人", "冷/热节点": "冷/热节点", "冷_热节点规格": "冷_热节点规格", + "同主机关联的其他集群,勾选后一并添加": "同主机关联的其他集群,勾选后一并添加", "这行勿动!新增翻译请在上一行添加!": "" } diff --git a/dbm-ui/frontend/src/types/auto-imports.d.ts b/dbm-ui/frontend/src/types/auto-imports.d.ts index d0c217f6f1..7021ac5101 100644 --- a/dbm-ui/frontend/src/types/auto-imports.d.ts +++ b/dbm-ui/frontend/src/types/auto-imports.d.ts @@ -71,6 +71,6 @@ declare global { // for type re-export declare global { // @ts-ignore - export type { Component, ComponentPublicInstance, ComputedRef, DirectiveBinding, ExtractDefaultPropTypes, ExtractPropTypes, ExtractPublicPropTypes, InjectionKey, PropType, Ref, MaybeRef, MaybeRefOrGetter, VNode, WritableComputedRef } from 'vue' + export type { Component, ComponentPublicInstance, ComputedRef, ExtractDefaultPropTypes, ExtractPropTypes, ExtractPublicPropTypes, InjectionKey, PropType, Ref, VNode, WritableComputedRef } from 'vue' import('vue') } diff --git a/dbm-ui/frontend/src/views/db-manage/mysql/common/edit-field/ClusterWithRelateCluster.vue b/dbm-ui/frontend/src/views/db-manage/mysql/common/edit-field/ClusterWithRelateCluster.vue index 7b541422cc..93a2cc125e 100644 --- a/dbm-ui/frontend/src/views/db-manage/mysql/common/edit-field/ClusterWithRelateCluster.vue +++ b/dbm-ui/frontend/src/views/db-manage/mysql/common/edit-field/ClusterWithRelateCluster.vue @@ -121,7 +121,9 @@ } interface Exposes { - getValue: () => Array; + getValue: () => { + cluster_ids: number[]; + }; } interface IClusterData { diff --git a/dbm-ui/frontend/src/views/db-manage/mysql/proxy-add/pages/page1/Index.vue b/dbm-ui/frontend/src/views/db-manage/mysql/proxy-add/pages/page1/Index.vue index bbd4cfeda2..041751f02f 100644 --- a/dbm-ui/frontend/src/views/db-manage/mysql/proxy-add/pages/page1/Index.vue +++ b/dbm-ui/frontend/src/views/db-manage/mysql/proxy-add/pages/page1/Index.vue @@ -202,7 +202,25 @@ const handleSubmit = async () => { try { isSubmitting.value = true; - const infos = await Promise.all(rowRefs.value.map((item: { getValue: () => Promise }) => item.getValue())); + const rows = await Promise.all(rowRefs.value.map((item: { getValue: () => Promise }) => item.getValue())); + // 新ip一致,聚合clusterid + const clusterIdsSet: Record> = {}; + rows.forEach( + (item: { + cluster_ids: number[]; + new_proxy: { + ip: string; + }; + }) => { + const key = item.new_proxy.ip; + clusterIdsSet[key] = clusterIdsSet[key] || new Set(); + item.cluster_ids.forEach((id) => clusterIdsSet[key].add(id)); + }, + ); + const infos = rows.map((item) => ({ + ...item, + cluster_ids: Array.from(clusterIdsSet[item.new_proxy.ip]), + })); await createTicket({ ticket_type: 'MYSQL_PROXY_ADD', remark: remark.value, diff --git a/dbm-ui/frontend/src/views/db-manage/mysql/proxy-add/pages/page1/components/RenderData/RenderProxy.vue b/dbm-ui/frontend/src/views/db-manage/mysql/proxy-add/pages/page1/components/RenderData/RenderProxy.vue index eba10945f5..3adfda1bde 100644 --- a/dbm-ui/frontend/src/views/db-manage/mysql/proxy-add/pages/page1/components/RenderData/RenderProxy.vue +++ b/dbm-ui/frontend/src/views/db-manage/mysql/proxy-add/pages/page1/components/RenderData/RenderProxy.vue @@ -43,7 +43,14 @@ } interface Exposes { - getValue: () => Promise>; + getValue: () => Promise<{ + new_proxy: { + bk_biz_id: number; + bk_host_id: number; + bk_cloud_id: number; + ip: string; + }; + }>; } const props = defineProps(); diff --git a/dbm-ui/frontend/src/views/db-manage/mysql/proxy-add/pages/page1/components/RenderData/Row.vue b/dbm-ui/frontend/src/views/db-manage/mysql/proxy-add/pages/page1/components/RenderData/Row.vue index 0351d161a1..ed9db06a8d 100644 --- a/dbm-ui/frontend/src/views/db-manage/mysql/proxy-add/pages/page1/components/RenderData/Row.vue +++ b/dbm-ui/frontend/src/views/db-manage/mysql/proxy-add/pages/page1/components/RenderData/Row.vue @@ -85,7 +85,15 @@ } interface Exposes { - getValue: () => Promise; + getValue: () => Promise<{ + cluster_ids: number[]; + new_proxy: { + bk_biz_id: number; + bk_host_id: number; + bk_cloud_id: number; + ip: string; + }; + }>; } const props = defineProps(); @@ -128,7 +136,7 @@ emits('remove'); }; - const getRowData = () => [clusterRef.value.getValue(), proxyRef.value.getValue()]; + const getRowData = () => [clusterRef.value!.getValue(), proxyRef.value!.getValue()]; const handleClone = () => { Promise.allSettled(getRowData()).then((rowData) => { diff --git a/dbm-ui/frontend/src/views/db-manage/mysql/proxy-replace/pages/page1/Index.vue b/dbm-ui/frontend/src/views/db-manage/mysql/proxy-replace/pages/page1/Index.vue index 4eca371402..e027429282 100644 --- a/dbm-ui/frontend/src/views/db-manage/mysql/proxy-replace/pages/page1/Index.vue +++ b/dbm-ui/frontend/src/views/db-manage/mysql/proxy-replace/pages/page1/Index.vue @@ -114,7 +114,38 @@ const handleSubmit = async () => { try { isSubmitting.value = true; - const infos = await tableRef.value!.getValue(); + const rows = await tableRef.value!.getValue(); + // 原ip和新ip一致,聚合clusterid + const clusterIdsSet: Record> = {}; + rows.forEach( + (item: { + cluster_ids: number[]; + origin_proxy: { + ip: string; + }; + target_proxy: { + ip: string; + }; + }) => { + const key = `${item.origin_proxy.ip}#${item.target_proxy.ip}`; + clusterIdsSet[key] = clusterIdsSet[key] || new Set(); + item.cluster_ids.forEach((id) => clusterIdsSet[key].add(id)); + }, + ); + const infos = rows.map( + (item: { + cluster_ids: number[]; + origin_proxy: { + ip: string; + }; + target_proxy: { + ip: string; + }; + }) => ({ + ...item, + cluster_ids: Array.from(clusterIdsSet[`${item.origin_proxy.ip}#${item.target_proxy.ip}`]), + }), + ); await createTicket({ bk_biz_id: window.PROJECT_CONFIG.BIZ_ID, ticket_type: TicketTypes.MYSQL_PROXY_SWITCH, diff --git a/dbm-ui/frontend/src/views/db-manage/mysql/proxy-replace/pages/page1/components/ReplaceHost/Index.vue b/dbm-ui/frontend/src/views/db-manage/mysql/proxy-replace/pages/page1/components/ReplaceHost/Index.vue index 2e13c0a7db..86af151730 100644 --- a/dbm-ui/frontend/src/views/db-manage/mysql/proxy-replace/pages/page1/components/ReplaceHost/Index.vue +++ b/dbm-ui/frontend/src/views/db-manage/mysql/proxy-replace/pages/page1/components/ReplaceHost/Index.vue @@ -52,7 +52,18 @@ import RenderDataRow, { createRowData, type IDataRow } from './components/RenderData/Row.vue'; interface Exposes { - getValue(): Promise; + getValue(): Promise< + { + cluster_ids: number[]; + origin_proxy: IDataRow['originProxy']; + target_proxy: IDataRow['targetProxy']; + display_info: { + type: string; + related_instances: string[]; + related_clusters: string[]; + }; + }[] + >; reset(): void; } diff --git a/dbm-ui/frontend/src/views/db-manage/mysql/proxy-replace/pages/page1/components/ReplaceHost/components/RenderData/Row.vue b/dbm-ui/frontend/src/views/db-manage/mysql/proxy-replace/pages/page1/components/ReplaceHost/components/RenderData/Row.vue index ed121d6f0a..830edb7518 100644 --- a/dbm-ui/frontend/src/views/db-manage/mysql/proxy-replace/pages/page1/components/ReplaceHost/components/RenderData/Row.vue +++ b/dbm-ui/frontend/src/views/db-manage/mysql/proxy-replace/pages/page1/components/ReplaceHost/components/RenderData/Row.vue @@ -87,6 +87,11 @@ cluster_ids: number[]; origin_proxy: IDataRow['originProxy']; target_proxy: IDataRow['targetProxy']; + display_info: { + type: string; + related_instances: string[]; + related_clusters: string[]; + }; }>; } diff --git a/dbm-ui/frontend/src/views/db-manage/mysql/proxy-replace/pages/page1/components/ReplaceInstance/Index.vue b/dbm-ui/frontend/src/views/db-manage/mysql/proxy-replace/pages/page1/components/ReplaceInstance/Index.vue index 15967e3460..4957b2f429 100644 --- a/dbm-ui/frontend/src/views/db-manage/mysql/proxy-replace/pages/page1/components/ReplaceInstance/Index.vue +++ b/dbm-ui/frontend/src/views/db-manage/mysql/proxy-replace/pages/page1/components/ReplaceInstance/Index.vue @@ -52,7 +52,17 @@ import RenderRow, { createRowData, type IDataRow } from './components/RenderData/Row.vue'; interface Exposes { - getValue(): Promise; + getValue(): Promise< + { + cluster_ids: number[]; + origin_proxy: IDataRow['originProxy']; + target_proxy: IDataRow['targetProxy']; + display_info: { + type: string; + related_clusters: string[]; + }; + }[] + >; reset(): void; } @@ -131,7 +141,6 @@ if (!instanceMemo[instance]) { const row = createRowData({ originProxy: { - cluster_id: item.cluster_id, ip: item.ip, bk_cloud_id: item.bk_cloud_id, bk_host_id: item.bk_host_id, @@ -139,10 +148,12 @@ port: item.port, instance_address: instance, }, - relatedClusters: item.related_clusters.map((item) => ({ - cluster_id: item.id, - domain: item.master_domain, - })), + relatedClusters: [ + { + cluster_id: item.cluster_id, + domain: item.master_domain, + }, + ], }); results.push(row); instanceMemo[instance] = true; diff --git a/dbm-ui/frontend/src/views/db-manage/mysql/proxy-replace/pages/page1/components/ReplaceInstance/components/RenderData/Index.vue b/dbm-ui/frontend/src/views/db-manage/mysql/proxy-replace/pages/page1/components/ReplaceInstance/components/RenderData/Index.vue index cbec3fa712..78ab77dc06 100644 --- a/dbm-ui/frontend/src/views/db-manage/mysql/proxy-replace/pages/page1/components/ReplaceInstance/components/RenderData/Index.vue +++ b/dbm-ui/frontend/src/views/db-manage/mysql/proxy-replace/pages/page1/components/ReplaceInstance/components/RenderData/Index.vue @@ -31,7 +31,7 @@ :min-width="200" :required="false" :width="240"> - {{ t('同机关联集群') }} + {{ t('关联集群') }} ; } diff --git a/dbm-ui/frontend/src/views/db-manage/mysql/proxy-replace/pages/page1/components/ReplaceInstance/components/RenderOriginalProxyInst.vue b/dbm-ui/frontend/src/views/db-manage/mysql/proxy-replace/pages/page1/components/ReplaceInstance/components/RenderOriginalProxyInst.vue index 519b72473c..1957f909d5 100644 --- a/dbm-ui/frontend/src/views/db-manage/mysql/proxy-replace/pages/page1/components/ReplaceInstance/components/RenderOriginalProxyInst.vue +++ b/dbm-ui/frontend/src/views/db-manage/mysql/proxy-replace/pages/page1/components/ReplaceInstance/components/RenderOriginalProxyInst.vue @@ -94,13 +94,14 @@ port: currentData.port, instance_address: currentData.instance_address, }; - const relatedClusters = currentData.related_clusters.map((item) => ({ - cluster_id: item.id, - domain: item.master_domain, - })); emits('inputFinish', { originProxy, - relatedClusters, + relatedClusters: [ + { + cluster_id: currentData.cluster_id, + domain: currentData.master_domain, + }, + ], }); return true; }), diff --git a/dbm-ui/frontend/src/views/tickets/common/components/demand-factory/mysql/proxy-replace/components/ReplaceInstance.vue b/dbm-ui/frontend/src/views/tickets/common/components/demand-factory/mysql/proxy-replace/components/ReplaceInstance.vue index 4595d4bf55..c3c98a7530 100644 --- a/dbm-ui/frontend/src/views/tickets/common/components/demand-factory/mysql/proxy-replace/components/ReplaceInstance.vue +++ b/dbm-ui/frontend/src/views/tickets/common/components/demand-factory/mysql/proxy-replace/components/ReplaceInstance.vue @@ -64,7 +64,7 @@ () => props.ticketDetails.details, () => { tableData.value = props.ticketDetails.details.infos.map(item => ({ - originProxy: item.origin_proxy.ip, + originProxy: `${item.origin_proxy.ip}:${item.origin_proxy.port}`, relatedClusters: item.display_info.related_clusters as string[], targetProxy: item.target_proxy.ip, }));