Skip to content

Commit

Permalink
fix(frontend): sqlserver数据迁移交互问题修复 TencentBlueKing#8341
Browse files Browse the repository at this point in the history
  • Loading branch information
jinquantianxia authored and zhangzhw8 committed Dec 2, 2024
1 parent 6158290 commit c633c02
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 29 deletions.
3 changes: 3 additions & 0 deletions dbm-ui/frontend/src/locales/zh-cn.json
Original file line number Diff line number Diff line change
Expand Up @@ -3659,5 +3659,8 @@
"请选择本地 SQL 文件": "请选择本地 SQL 文件",
"忽略错误": "忽略错误",
"强制失败节点成功": "强制失败节点成功",
"源集群不能为空": "源集群不能为空",
"源集群不存在": "源集群不存在",
"源集群重复": "源集群重复",
"这行勿动!新增翻译请在上一行添加!": ""
}
2 changes: 1 addition & 1 deletion dbm-ui/frontend/src/types/auto-imports.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,6 @@ declare global {
// for type re-export
declare global {
// @ts-ignore
export type { Component, ComponentPublicInstance, ComputedRef, ExtractDefaultPropTypes, ExtractPropTypes, ExtractPublicPropTypes, InjectionKey, PropType, Ref, VNode, WritableComputedRef } from 'vue'
export type { Component, ComponentPublicInstance, ComputedRef, DirectiveBinding, ExtractDefaultPropTypes, ExtractPropTypes, ExtractPublicPropTypes, InjectionKey, PropType, Ref, MaybeRef, MaybeRefOrGetter, VNode, WritableComputedRef } from 'vue'
import('vue')
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,11 @@
:tab-list-config="clusterSelectorTabConfig"
@change="handelClusterChange" />
</template>
<script lang="ts">
<!-- <script lang="ts">
const clusterIdMemo: Record<string, number> = {};
</script>
</script> -->
<script setup lang="ts">
import { onBeforeUnmount, ref, watch } from 'vue';
import { ref, watch } from 'vue';
import { useI18n } from 'vue-i18n';

import SqlServerHaModel from '@services/model/sqlserver/sqlserver-ha';
Expand All @@ -53,8 +53,7 @@
import ClusterSelector from '@components/cluster-selector/Index.vue';
import TableEditInput from '@components/render-table/columns/input/index.vue';

import { random } from '@utils';

// import { random } from '@utils';
import type { IDataRow } from './Row.vue';

interface Props {
Expand All @@ -73,8 +72,8 @@
cloudId: null | number;
}>();

const instanceKey = `render_dst_cluster_${random()}`;
clusterIdMemo[instanceKey] = 0;
// const instanceKey = `render_dst_cluster_${random()}`;
// clusterIdMemo[instanceKey] = 0;

const compareVersion = (dstVersion: string, srcVersion: string) => {
const versionMatchReg = /[^\d]*(\d+)$/;
Expand Down Expand Up @@ -149,26 +148,26 @@
cloudId: data[0].bk_cloud_id,
domain: data[0].master_domain,
};
clusterIdMemo[instanceKey] = data[0].id;
// clusterIdMemo[instanceKey] = data[0].id;
return true;
}
clusterIdMemo[instanceKey] = 0;
// clusterIdMemo[instanceKey] = 0;
modelValue.value = undefined;
return false;
}),
message: t('目标集群不存在'),
},
{
validator: () => {
const otherClusterIdMemo = { ...clusterIdMemo };
delete otherClusterIdMemo[instanceKey];
if (Object.values(otherClusterIdMemo).includes(modelValue.value!.id)) {
return false;
}
return true;
},
message: t('目标集群重复'),
},
// {
// validator: () => {
// const otherClusterIdMemo = { ...clusterIdMemo };
// delete otherClusterIdMemo[instanceKey];
// if (Object.values(otherClusterIdMemo).includes(modelValue.value!.id)) {
// return false;
// }
// return true;
// },
// message: t('目标集群重复'),
// },
];

// 同步外部值
Expand All @@ -177,7 +176,7 @@
() => {
if (modelValue.value) {
localDomain.value = modelValue.value.domain;
clusterIdMemo[instanceKey] = modelValue.value.id;
// clusterIdMemo[instanceKey] = modelValue.value.id;
} else {
localDomain.value = '';
}
Expand All @@ -203,15 +202,15 @@
domain: clusterData.master_domain,
};
localDomain.value = clusterData.master_domain;
clusterIdMemo[instanceKey] = clusterData.id;
// clusterIdMemo[instanceKey] = clusterData.id;
setTimeout(() => {
editRef.value!.getValue();
});
};

onBeforeUnmount(() => {
delete clusterIdMemo[instanceKey];
});
// onBeforeUnmount(() => {
// delete clusterIdMemo[instanceKey];
// });

defineExpose<Exposes>({
getValue(field) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@
const rules = [
{
validator: (value: string) => Boolean(value),
message: t('目标集群不能为空'),
message: t('源集群不能为空'),
},
{
validator: (value: string) =>
Expand All @@ -124,7 +124,7 @@
modelValue.value = undefined;
return false;
}),
message: t('目标集群不存在'),
message: t('源集群不存在'),
},
{
validator: () => {
Expand All @@ -135,7 +135,7 @@
}
return true;
},
message: t('目标集群重复'),
message: t('源集群重复'),
},
];

Expand Down

0 comments on commit c633c02

Please sign in to comment.