fix(接口定义): 修复环境选择问题

This commit is contained in:
fit2-zhao 2020-12-23 17:53:45 +08:00
parent 6e75c66673
commit 7e1f9127a8
1 changed files with 15 additions and 5 deletions

View File

@ -13,12 +13,12 @@
<el-option v-for="(environment, index) in environments" :key="index"
:label="environment.name + (environment.config.httpConfig.socket ? (': ' + environment.config.httpConfig.protocol + '://' + environment.config.httpConfig.socket) : '')"
:value="environment.id"/>
<el-button class="environment-button" size="mini" type="primary" @click="openEnvironmentConfig">
<el-button class="environment-button" size="small" type="primary" @click="openEnvironmentConfig">
{{ $t('api_test.environment.environment_config') }}
</el-button>
<template v-slot:empty>
<div class="empty-environment">
<el-button class="environment-button" size="mini" type="primary" @click="openEnvironmentConfig">
<el-button class="environment-button" size="small" type="primary" @click="openEnvironmentConfig">
{{ $t('api_test.environment.environment_config') }}
</el-button>
</div>
@ -43,11 +43,11 @@
<el-form-item :label="$t('api_test.request.sql.result_variable')" prop="resultVariable">
<el-input v-model="request.resultVariable" maxlength="300" show-word-limit/>
<el-input v-model="request.resultVariable" maxlength="300" show-word-limit size="small"/>
</el-form-item>
<el-form-item :label="$t('api_test.request.sql.variable_names')" prop="variableNames">
<el-input v-model="request.variableNames" maxlength="300" show-word-limit/>
<el-input v-model="request.variableNames" maxlength="300" show-word-limit size="small"/>
</el-form-item>
<el-tabs v-model="activeName">
@ -136,7 +136,7 @@
isReloadData: false,
activeName: "variables",
rules: {
environmentId: [{required: true, message: this.$t('test_track.case.input_maintainer'), trigger: 'change'}],
environmentId: [{required: true, message: this.$t('api_test.definition.request.run_env'), trigger: 'change'}],
dataSourceId: [{required: true, message: this.$t('api_test.request.sql.dataSource'), trigger: 'change'}],
},
}
@ -209,6 +209,16 @@
this.environments.forEach(environment => {
parseEnvironment(environment);
});
let hasEnvironment = false;
for (let i in this.environments) {
if (this.environments[i].id === this.request.environmentId) {
hasEnvironment = true;
break;
}
}
if (!hasEnvironment) {
this.request.environmentId = undefined;
}
this.initDataSource();
});
},