fix(接口测试): 修复场景自定义sql请求环境显示为id的缺陷

--bug=1025017 --user=王孝刚 【接口测试】场景导出导入后-运行环境显示错误
https://www.tapd.cn/55049933/s/1358378
This commit is contained in:
wxg0103 2023-03-31 18:37:11 +08:00 committed by fit2-zhao
parent 9c9b959501
commit 81f508da6e
4 changed files with 12 additions and 6 deletions

View File

@ -273,10 +273,12 @@ export default {
let currentEnvironment = {}; let currentEnvironment = {};
this.result = getEnvironmentByProjectId(id).then((response) => { this.result = getEnvironmentByProjectId(id).then((response) => {
this.environments = response.data; this.environments = response.data;
let hasEnvironment = false;
this.environments.forEach((environment) => { this.environments.forEach((environment) => {
parseEnvironment(environment); parseEnvironment(environment);
// //
if (environment.id === this.request.environmentId && environment.id !== envId) { if (environment.id === this.request.environmentId && environment.id !== envId) {
hasEnvironment = true;
if (environment.config && environment.config.databaseConfigs) { if (environment.config && environment.config.databaseConfigs) {
environment.config.databaseConfigs.forEach((item) => { environment.config.databaseConfigs.forEach((item) => {
if (item.id === this.request.dataSourceId) { if (item.id === this.request.dataSourceId) {
@ -290,6 +292,9 @@ export default {
this.environments = [currentEnvironment]; this.environments = [currentEnvironment];
} }
}); });
if (!hasEnvironment) {
this.request.environmentId = "";
}
this.initDataSource(envId, currentEnvironment, targetDataSourceName); this.initDataSource(envId, currentEnvironment, targetDataSourceName);
}); });
}, },

View File

@ -113,7 +113,5 @@ export default {
</script> </script>
<style scoped> <style scoped>
:deep(.ace_text-layer){
padding:0px !important;
}
</style> </style>

View File

@ -415,10 +415,12 @@ export default {
} }
getEnvironmentByProjectId(id).then((response) => { getEnvironmentByProjectId(id).then((response) => {
this.environments = response.data; this.environments = response.data;
let hasEnvironment = false;
this.environments.forEach((environment) => { this.environments.forEach((environment) => {
parseEnvironment(environment); parseEnvironment(environment);
// //
if (environment.id === this.request.environmentId && environment.id !== envId) { if (environment.id === this.request.environmentId && environment.id !== envId) {
hasEnvironment = true;
if (environment.config && environment.config.databaseConfigs) { if (environment.config && environment.config.databaseConfigs) {
environment.config.databaseConfigs.forEach((item) => { environment.config.databaseConfigs.forEach((item) => {
if (item.id === this.request.dataSourceId) { if (item.id === this.request.dataSourceId) {
@ -434,6 +436,9 @@ export default {
} }
} }
}); });
if (!hasEnvironment) {
this.request.environmentId = "";
}
this.initDataSource(envId, currentEnvironment, targetDataSourceName); this.initDataSource(envId, currentEnvironment, targetDataSourceName);
}); });
}, },

View File

@ -115,7 +115,5 @@ export default {
</script> </script>
<style scoped> <style scoped>
:deep(.ace_text-layer){
padding:0px !important;
}
</style> </style>