fix(接口定义): 修复sql接口和用例,保存的环境被删除后,运行环境显示了ID的缺陷

--bug=1023102 --user=王孝刚 【接口测试】sql接口和用例,保存的环境被删除后,运行环境显示了ID
https://www.tapd.cn/55049933/s/1336062
This commit is contained in:
wxg0103 2023-02-16 11:04:35 +08:00 committed by 刘瑞斌
parent b863ea4fda
commit 60cbe31fda
1 changed files with 17 additions and 0 deletions

View File

@ -341,6 +341,7 @@ export default {
this.environments = response.data; this.environments = response.data;
let targetDataSourceName = undefined; let targetDataSourceName = undefined;
let currentEnvironment = undefined; let currentEnvironment = undefined;
let hasEnvironment = false;
this.environments.forEach((environment) => { this.environments.forEach((environment) => {
parseEnvironment(environment); parseEnvironment(environment);
// //
@ -348,6 +349,7 @@ export default {
currentEnvironment = environment; currentEnvironment = environment;
} }
if (environment.id === this.request.environmentId) { if (environment.id === this.request.environmentId) {
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) {
@ -357,6 +359,21 @@ export default {
} }
} }
}); });
if (!hasEnvironment) {
this.request.environmentId = store.useEnvironment;
this.environments.forEach((environment) => {
if (environment.id === store.useEnvironment) {
currentEnvironment = environment;
}
if (environment.config && environment.config.databaseConfigs) {
environment.config.databaseConfigs.forEach((item) => {
if (item.id === this.request.dataSourceId) {
targetDataSourceName = item.name;
}
});
}
});
}
this.initDataSource(environmentId, currentEnvironment, targetDataSourceName); this.initDataSource(environmentId, currentEnvironment, targetDataSourceName);
}); });
}, },