fix(接口测试): 修复sql协议切换环境,没有显示第一个数据源的缺陷

--bug=1027588 --user=王孝刚 【接口测试】SQL协议-API/TEST/CASE/切换运行环境-数据源显示为空
https://www.tapd.cn/55049933/s/1389900
This commit is contained in:
wxg0103 2023-07-05 17:50:17 +08:00 committed by f2c-ci-robot[bot]
parent 8b1af2b919
commit ae0219625c
1 changed files with 21 additions and 0 deletions

View File

@ -261,6 +261,12 @@ export default {
},
deep: true,
},
// /
'request.environmentId': function () {
if (!this.scenarioId) {
this.setStep(undefined, undefined, this.request.targetDataSourceName);
}
},
},
created() {
this.getEnvironments();
@ -535,6 +541,21 @@ export default {
environmentConfigClose() {
this.getEnvironments();
},
setStep(envId, currentEnvironment, targetDataSourceName) {
let envs = this.environments.filter((item) => this.request && item.id === this.request.environmentId);
if (envs && envs.length === 0) {
let id = this.request.projectId ? this.request.projectId : this.projectId;
this.result = getEnvironmentByProjectId(id).then((response) => {
this.environments = response.data;
this.environments.forEach((environment) => {
parseEnvironment(environment);
});
this.initDataSource(envId, currentEnvironment, targetDataSourceName);
});
} else {
this.initDataSource(envId, currentEnvironment, targetDataSourceName);
}
},
},
};
</script>