fix(环境管理): 通用配置参数名称校验
--bug=1007489 --user=赵勇 【环境配置】-添加的全局变量名称可以重复 https://www.tapd.cn/55049933/s/1059272
This commit is contained in:
parent
729d5a2aa0
commit
99e6d2c6eb
|
@ -76,7 +76,13 @@ export default {
|
||||||
change: function () {
|
change: function () {
|
||||||
let isNeedCreate = true;
|
let isNeedCreate = true;
|
||||||
let removeIndex = -1;
|
let removeIndex = -1;
|
||||||
|
let repeatKey = "";
|
||||||
this.items.forEach((item, index) => {
|
this.items.forEach((item, index) => {
|
||||||
|
this.items.forEach((row, rowIndex) => {
|
||||||
|
if (item.name === row.name && index !== rowIndex) {
|
||||||
|
repeatKey = item.name;
|
||||||
|
}
|
||||||
|
});
|
||||||
if (!item.name && !item.value) {
|
if (!item.name && !item.value) {
|
||||||
// 多余的空行
|
// 多余的空行
|
||||||
if (index !== this.items.length - 1) {
|
if (index !== this.items.length - 1) {
|
||||||
|
@ -86,11 +92,15 @@ export default {
|
||||||
isNeedCreate = false;
|
isNeedCreate = false;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
if (isNeedCreate) {
|
if (repeatKey !== "") {
|
||||||
|
this.$warning(this.$t('api_test.environment.common_config') + "【" + repeatKey + "】" + this.$t('load_test.param_is_duplicate'));
|
||||||
|
}
|
||||||
|
if (isNeedCreate && !repeatKey) {
|
||||||
this.items.push(new KeyValue({enable: true}));
|
this.items.push(new KeyValue({enable: true}));
|
||||||
}
|
}
|
||||||
this.$emit('change', this.items);
|
this.$emit('change', this.items);
|
||||||
// TODO 检查key重复
|
// TODO 检查key重复
|
||||||
|
|
||||||
},
|
},
|
||||||
isDisable: function (index) {
|
isDisable: function (index) {
|
||||||
return this.items.length - 1 === index;
|
return this.items.length - 1 === index;
|
||||||
|
|
|
@ -84,6 +84,7 @@
|
||||||
import {getUUID} from "@/common/js/utils";
|
import {getUUID} from "@/common/js/utils";
|
||||||
import Jsr233ProcessorContent from "@/business/components/api/automation/scenario/common/Jsr233ProcessorContent";
|
import Jsr233ProcessorContent from "@/business/components/api/automation/scenario/common/Jsr233ProcessorContent";
|
||||||
import {createComponent} from "@/business/components/api/definition/components/jmeter/components";
|
import {createComponent} from "@/business/components/api/definition/components/jmeter/components";
|
||||||
|
import {KeyValue} from "@/business/components/api/test/model/ScenarioModel";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: "EnvironmentEdit",
|
name: "EnvironmentEdit",
|
||||||
|
@ -212,11 +213,29 @@
|
||||||
}
|
}
|
||||||
return uploadFiles;
|
return uploadFiles;
|
||||||
},
|
},
|
||||||
|
check (items) {
|
||||||
|
let repeatKey = "";
|
||||||
|
items.forEach((item, index) => {
|
||||||
|
items.forEach((row, rowIndex) => {
|
||||||
|
if (item.name === row.name && index !== rowIndex) {
|
||||||
|
repeatKey = item.name;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
return repeatKey;
|
||||||
|
},
|
||||||
_save(environment) {
|
_save(environment) {
|
||||||
if(!this.projectId){
|
if(!this.projectId){
|
||||||
this.$warning(this.$t('api_test.select_project'));
|
this.$warning(this.$t('api_test.select_project'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if(environment && environment.config && environment.config.commonConfig &&environment.config.commonConfig.variables){
|
||||||
|
let repeatKey = this.check(environment.config.commonConfig &&environment.config.commonConfig.variables);
|
||||||
|
if (repeatKey !== "") {
|
||||||
|
this.$warning(this.$t('api_test.environment.common_config') + "【" + repeatKey + "】" + this.$t('load_test.param_is_duplicate'));
|
||||||
|
return ;
|
||||||
|
}
|
||||||
|
}
|
||||||
let bodyFiles = this.geFiles(environment);
|
let bodyFiles = this.geFiles(environment);
|
||||||
let param = this.buildParam(environment);
|
let param = this.buildParam(environment);
|
||||||
let url = '/api/environment/add';
|
let url = '/api/environment/add';
|
||||||
|
|
Loading…
Reference in New Issue