fix_接口测试_接口自动化_批量填加

This commit is contained in:
wxg0103 2021-09-22 19:44:01 +08:00 committed by fit2-zhao
parent bb108e595a
commit 0111e8398f
1 changed files with 38 additions and 23 deletions

View File

@ -174,37 +174,51 @@ export default {
this.$refs.batchAddHeader.open();
},
_handleBatchVars(data) {
let params = data.split("\n");
let keyValues = [];
params.forEach(item => {
let line = item.split(/|,/);
let required = false;
if (line[1] === '必填' || line[1] === 'Required' || line[1] === 'true') {
required = true;
}
keyValues.push(new KeyValue({
name: line[0],
required: required,
value: line[2],
description: line[3],
type: "text",
valid: false,
file: false,
encode: true,
enable: true,
contentType: "text/plain"
}));
});
return keyValues;
if (data) {
let params = data.split("\n");
let keyValues = [];
params.forEach(item => {
let line = item.split(/|:/);
let required = false;
keyValues.unshift(new KeyValue({
name: line[0],
required: required,
value: line[1],
description: line[2],
type: "text",
valid: false,
file: false,
encode: true,
enable: true,
contentType: "text/plain"
}));
})
return keyValues;
}
},
batchSaveHeader(data) {
if (data) {
let keyValues = this._handleBatchVars(data);
keyValues.forEach(item => {
this.headers.unshift(item);
this.format(this.headers,item);
});
}
},
format(array, obj) {
if (array) {
let isAdd = true;
for (let i in array) {
let item = array[i];
if (item.name === obj.name) {
item.value = obj.value;
isAdd = false;
}
}
if (isAdd) {
this.headers.unshift(obj);
}
}
},
batchSaveParameter(data) {
if (data) {
let keyValues = this._handleBatchVars(data);
@ -232,6 +246,7 @@ export default {
return '';
},
addParameters(v) {
console.log(v);
v.id = getUUID();
if (v.type === 'CSV') {
v.delimiter = ",";