fix(接口测试): 修复sql步骤没有切换同名数据源的缺陷

--bug=1032777 --user=王孝刚 【接口测试】github#27497,切换自动化运行环境时,SQL步骤没有切换到对应环境的同名数据源 https://www.tapd.cn/55049933/s/1436469
This commit is contained in:
wxg0103 2023-11-14 18:20:49 +08:00 committed by 刘瑞斌
parent 34b8689e22
commit 84467c1063
1 changed files with 19 additions and 1 deletions

View File

@ -47,7 +47,7 @@
:label="$t('api_test.request.sql.dataSource')" :label="$t('api_test.request.sql.dataSource')"
prop="dataSourceId" prop="dataSourceId"
style="margin-left: 10px"> style="margin-left: 10px">
<el-select v-model="request.dataSourceId" size="small" @change="reload"> <el-select v-model="request.dataSourceId" size="small" @change="reloadDataSource">
<el-option <el-option
v-for="(item, index) in databaseConfigsOptions" v-for="(item, index) in databaseConfigsOptions"
:key="index" :key="index"
@ -287,6 +287,14 @@ export default {
}, },
}, },
methods: { methods: {
reloadDataSource(dataSourceId) {
this.databaseConfigsOptions.forEach((item) => {
if (item.id === dataSourceId) {
this.request.targetDataSourceName = item.name;
}
});
this.reload();
},
tabClick() { tabClick() {
if (this.activeName === 'preOperate') { if (this.activeName === 'preOperate') {
this.$refs.preStep.filter(); this.$refs.preStep.filter();
@ -440,6 +448,13 @@ export default {
if (!this.isCase) { if (!this.isCase) {
this.environments = [currentEnvironment]; this.environments = [currentEnvironment];
} }
if (environment.config && environment.config.databaseConfigs) {
environment.config.databaseConfigs.forEach((item) => {
if (item.id === this.request.dataSourceId) {
this.request.targetDataSourceName = item.name;
}
});
}
} }
}); });
if (!hasEnvironment) { if (!hasEnvironment) {
@ -452,6 +467,9 @@ export default {
this.$refs.environmentConfig.open(this.request.projectId ? this.request.projectId : getCurrentProjectID()); this.$refs.environmentConfig.open(this.request.projectId ? this.request.projectId : getCurrentProjectID());
}, },
initDataSource(envId, currentEnvironment, targetDataSourceName) { initDataSource(envId, currentEnvironment, targetDataSourceName) {
if (!targetDataSourceName) {
targetDataSourceName = this.request.targetDataSourceName;
}
this.databaseConfigsOptions = []; this.databaseConfigsOptions = [];
if (envId) { if (envId) {
this.request.environmentId = envId; this.request.environmentId = envId;