fix(接口测试): 修复复制数据源名称,名称显示不正确的缺陷

--bug=1037631 --user=王孝刚 【项目管理】环境管理-数据库-复制数据源-名称显示不正确
https://www.tapd.cn/55049933/s/1481238
This commit is contained in:
wxg0103 2024-03-26 18:53:23 +08:00 committed by Craftsman
parent bf3ddfec21
commit 4e08283e27
3 changed files with 22 additions and 6 deletions

View File

@ -222,6 +222,13 @@
if (errors) {
return;
}
const isExist = store.currentEnvDetailInfo.config.dataSources.some(
(item) => item.dataSource === form.value.dataSource && item.id !== form.value.id
);
if (isExist) {
Message.error(t('project.environmental.database.nameIsExist'));
return;
}
const { driverId } = form.value;
try {
const index = store.currentEnvDetailInfo.config.dataSources.findIndex((item: any) => item.id === form.value.id);
@ -230,7 +237,6 @@
} else if (index > -1 && props.isCopy) {
const insertItem = {
...form.value,
dataSource: `copy_${form.value.dataSource}`,
id: getGenerateId(),
driver: driverOption.value.find((item) => item.value === driverId)?.label,
};
@ -262,12 +268,20 @@
(item) => item.id === props.currentId
) as DataSourceItem;
if (currentItem) {
form.value = {
...currentItem,
};
if (props.isCopy) {
form.value = {
...currentItem,
id: '',
dataSource: `copy_${currentItem.dataSource}`,
};
} else {
form.value = {
...currentItem,
};
}
} else {
formReset();
}
} else {
formReset();
}
});
</script>

View File

@ -123,4 +123,5 @@ export default {
'project.environmental.env.deleteGroup': 'Whether to delete the environment group `{name}`',
'project.environmental.env.deleteGroupTip':
'Deleting it will cause scenes that reference this environment group to fail to execute properly!',
'project.environmental.database.nameIsExist': 'Database name already exists',
};

View File

@ -127,4 +127,5 @@ export default {
'project.environmental.env.deleteTip': '删除后会导致引用此环境的场景无法正常执行',
'project.environmental.env.deleteGroup': '是否删除环境组 `{name}`',
'project.environmental.env.deleteGroupTip': '删除后会导致引用此环境组的场景无法正常执行',
'project.environmental.database.nameIsExist': '数据源名称已存在',
};