解决循环或轮询编排bug

This commit is contained in:
liangdaliang
2025-03-12 18:22:24 +08:00
parent 2cdc43cd0f
commit 96e1237c20
6 changed files with 88 additions and 12 deletions

View File

@@ -49,11 +49,33 @@ export default {
},
saveStep(list) {
let p = []
let index = 1;
list.forEach((item) => {
item.assertion.pop();
item.assignment.pop();
item.requestHeader.pop();
item.requestParams.pop();
if (item.stepNum) {
item.stepNum = index;
}
index ++;
let childrenList = item.childrenList;
if (childrenList) {
item.childrenList = null;
let cindex = 1;
childrenList.forEach((children) => {
p.push({
...children,
caseId: this.$route.query.id,
stepNum: cindex,
assertion: JSON.stringify(children.assertion),
assignment: JSON.stringify(children.assignment),
requestHeader: JSON.stringify(children.requestHeader),
requestParams: JSON.stringify(children.requestParams)
});
cindex ++;
});
}
p.push({
...item,
caseId: this.$route.query.id,
@@ -63,6 +85,7 @@ export default {
requestParams: JSON.stringify(item.requestParams)
});
})
console.log(p)
addCaseStep({
caseId: this.$route.query.id,
list: p

View File

@@ -179,6 +179,10 @@ export default {
type: Array
}
},
created() {
// 在这里进行数据预处理
this.preProcessFormData();
},
data() {
return {
activeName: "Headers",
@@ -194,6 +198,32 @@ export default {
}
},
methods: {
preProcessFormData() {
if (typeof this.form.requestHeader === 'string') {
try {
this.form.requestHeader = JSON.parse(this.form.requestHeader);
} catch (e) {
}
}
if (typeof this.form.requestParams === 'string') {
try {
this.form.requestParams = JSON.parse(this.form.requestParams);
} catch (e) {
}
}
if (typeof this.form.assignment === 'string') {
try {
this.form.assignment = JSON.parse(this.form.assignment);
} catch (e) {
}
}
if (typeof this.form.assertion === 'string') {
try {
this.form.assertion = JSON.parse(this.form.assertion);
} catch (e) {
}
}
},
folderHandleSelected(id) {
if (id) {
this.queryParams.groupId = id;
@@ -254,26 +284,22 @@ export default {
this.form.apiPort = p.port;
this.form.apiProtocol = p.protocol;
if (p.header) {
this.form.requestHeader = JSON.parse(p.header);
let newHeader = JSON.parse(p.header);
if (newHeader && newHeader.length > 0) {
this.form.requestHeader = newHeader;
} else {
return;
}
this.form.requestHeader.push([{
key: "",
value: "",
}])
} else {
this.form.requestHeader = [{
key: "",
value: "",
}]
}
} else {
this.form.apiHttpId = undefined;
this.form.apiHost = undefined;
this.form.apiPort = undefined;
this.form.apiProtocol = undefined;
this.form.requestHeader = [{
key: "",
value: "",
}]
}
},
handleTableEdit(e, flag, scope) {

View File

@@ -65,6 +65,10 @@ export default {
},
methods: {
handleAdd(type) {
if (!this.form.id) {
this.$modal.msgError("请先保存循环或轮询主步骤再新增子步骤!");
return;
}
this.list.push({
name: "",
parentId: this.form.id,