From 5a0b0e0fc8b4ef4a519de0753fb1457f02abb00e Mon Sep 17 00:00:00 2001
From: chenwenchang <479999519@qq.com>
Date: Wed, 27 Nov 2024 15:28:51 +0800
Subject: [PATCH] =?UTF-8?q?fix(frontend):=20=E4=BF=AE=E5=A4=8Dmysql?=
=?UTF-8?q?=E6=B7=BB=E5=8A=A0proxy=E9=87=8D=E5=A4=8D=E6=A0=A1=E9=AA=8C?=
=?UTF-8?q?=E6=9C=AA=E6=A0=87=E7=BA=A2=E6=8F=90=E7=A4=BA=E9=97=AE=E9=A2=98?=
=?UTF-8?q?=20#8206=20#=20Reviewed,=20transaction=20id:=2025022?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../edit-field/ClusterWithRelateCluster.vue | 26 ++++++++++++---
.../mysql/proxy-add/pages/page1/Index.vue | 21 +-----------
.../mysql/proxy-replace/pages/page1/Index.vue | 33 +------------------
.../components/ReplaceInstance.vue | 2 +-
4 files changed, 24 insertions(+), 58 deletions(-)
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 93a2cc125e..e56784a575 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
@@ -23,6 +23,8 @@
v-model="localDomain"
:placeholder="t('请输入集群域名或从表头批量选择')"
:rules="rules"
+ @blur="handleEditBlur"
+ @clear="handleEditClear"
@submit="handleEditSubmit" />
{
+ editRef.value.getValue().then(() => {
+ isShowEdit.value = false;
+ nextTick(() => {
+ initRelateClusterPopover();
+ });
+ });
+ };
+
+ const handleEditClear = () => {
+ clusterIdMemo[instanceKey] = {};
+ realateCheckedMap.value = {};
+ selectRelateClusterList.value = [];
+ };
+
// 提交编辑
const handleEditSubmit = (value: string) => {
if (!value) {
+ handleEditClear();
return;
}
-
- isShowEdit.value = false;
- nextTick(() => {
- initRelateClusterPopover();
- });
+ handleEditBlur();
};
// 显示管理集群列表
@@ -382,6 +396,8 @@
};
// 用户输入未完成验证
if (editRef.value) {
+ // 先切回编辑态才能正常校验
+ handleShowEdit();
return editRef.value.getValue().then(() => result);
}
// 用户输入错误
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 041751f02f..fa85f16b34 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,25 +202,7 @@
const handleSubmit = async () => {
try {
isSubmitting.value = true;
- 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]),
- }));
+ const infos = await Promise.all(rowRefs.value.map((item: { getValue: () => Promise }) => item.getValue()));
await createTicket({
ticket_type: 'MYSQL_PROXY_ADD',
remark: remark.value,
@@ -230,7 +212,6 @@
bk_biz_id: currentBizId,
}).then((data) => {
window.changeConfirm = false;
-
router.push({
name: 'MySQLProxyAdd',
params: {
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 e027429282..4eca371402 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,38 +114,7 @@
const handleSubmit = async () => {
try {
isSubmitting.value = true;
- 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}`]),
- }),
- );
+ const infos = await tableRef.value!.getValue();
await createTicket({
bk_biz_id: window.PROJECT_CONFIG.BIZ_ID,
ticket_type: TicketTypes.MYSQL_PROXY_SWITCH,
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 c3c98a7530..07787923b6 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
@@ -45,7 +45,7 @@
width: 220,
},
{
- label: t('同机关联集群'),
+ label: t('关联集群'),
field: 'relatedClusters',
width: 220,
render: ({ data }: { data: RowData }) => data.relatedClusters.map((item) => {item}
),