fix(接口测试): 修复接口附件tab切换后丢失问题

--bug=1020743 --user=赵勇 【接口测试】GET接口请求体中上传文件后改成POST接口执行,提示找不到文件 https://www.tapd.cn/55049933/s/1314213
This commit is contained in:
fit2-zhao 2022-12-08 14:01:24 +08:00 committed by fit2-zhao
parent e0309cbe2d
commit 684a432e61
1 changed files with 15 additions and 1 deletions

View File

@ -453,13 +453,24 @@ export default {
this.runLoading = false;
this.checkVersionEnable();
},
margeFiles(targetFiles, sourceFiles) {
targetFiles.forEach((target) => {
sourceFiles.forEach((source) => {
if (target.uuid === source.uuid) {
source.file = target.file;
}
});
});
},
initLocalFile() {
if (this.apiData.request && this.apiData.request.body) {
if (this.apiData.request.body.binary && this.apiData.request.body.binary.length > 0) {
this.apiData.request.body.binary.forEach((item) => {
this.api.request.body.binary.forEach((api) => {
if (item.uuid && api.uuid && item.uuid === api.uuid) {
api = item;
api.files = item.files;
} else if (item.files && api.files) {
this.margeFiles(item.files, api.files);
}
});
});
@ -469,6 +480,8 @@ export default {
this.api.request.body.kvs.forEach((api) => {
if (item.uuid && api.uuid && item.uuid === api.uuid && item.files && api.files) {
api.files = item.files;
} else if (item.files && api.files) {
this.margeFiles(item.files, api.files);
}
});
});
@ -476,6 +489,7 @@ export default {
}
},
},
created() {
this.init();
},