refactor(系统设置): 优化环境设置保存时提示模块不能为空 (#13157)

Co-authored-by: wxg0103 <727495428@qq.com>
This commit is contained in:
MeterSphere Bot 2022-04-27 17:40:20 +08:00 committed by GitHub
parent 111f8b4fdb
commit f63acc306e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 22 additions and 21 deletions

View File

@ -384,6 +384,27 @@ export default {
return;
}
}
let message = '';
if (environment && environment.config && environment.config.httpConfig && environment.config.httpConfig.conditions) {
environment.config.httpConfig.conditions.forEach(env => {
if (env.type === "MODULE" && env.details.length === 0) {
message += this.$t('load_test.domain') + ":" + env.socket + ":" + this.$t('api_test.environment.module_warning');
return;
}
if (env.type === "PATH" && env.details) {
env.details.forEach(item => {
if (!item.name) {
message += this.$t('load_test.domain') + ":" + env.socket + ":" + this.$t('api_test.environment.path_warning');
return;
}
})
}
})
}
if (message) {
this.$warning(message);
return;
}
let bodyFiles = this.geFiles(environment);
let param = this.buildParam(environment);
let url = '/api/environment/add';

View File

@ -55,7 +55,7 @@
<el-button type="primary" style="float: right;margin-left: 10px" size="mini" @click="clear">
{{ $t('commons.clear') }}
</el-button>
<el-button type="primary" style="float: right" size="mini" @click="update">{{
<el-button type="primary" style="float: right" size="mini" @click="update(condition)">{{
$t('commons.update')
}}
</el-button>
@ -274,10 +274,6 @@ export default {
data.forEach((item) => {
this.condition.details.push(new KeyValue({name: item.name, value: item.id}));
});
} else {
this.condition.ids = [];
this.$warning(this.$t('api_test.environment.module_warning'));
return;
}
},
update() {
@ -294,16 +290,8 @@ export default {
time: this.condition.time
};
if (obj.type === "PATH") {
if (this.pathDetails.name === '') {
this.$warning(this.$t('api_test.environment.path_warning'));
return;
}
this.httpConfig.conditions[index].details = [this.pathDetails];
} else {
if (this.condition.type === "MODULE" && this.condition.details.length === 0) {
this.$warning(this.$t('api_test.environment.module_warning'));
return;
}
obj.details = this.condition.details ? JSON.parse(JSON.stringify(this.condition.details)) : this.condition.details;
}
if (index !== -1) {
@ -352,16 +340,8 @@ export default {
domain: this.condition.domain, port: this.condition.port, time: new Date().getTime(), description: this.condition.description
};
if (this.condition.type === "PATH") {
if (this.pathDetails.name === '') {
this.$warning(this.$t('api_test.environment.path_warning'));
return;
}
obj.details = [JSON.parse(JSON.stringify(this.pathDetails))];
} else {
if (this.condition.type === "MODULE" && this.condition.details.length === 0) {
this.$warning(this.$t('api_test.environment.module_warning'));
return;
}
obj.details = this.condition.details ? JSON.parse(JSON.stringify(this.condition.details)) : this.condition.details;
}
this.httpConfig.conditions.unshift(obj);