fix(接口定义): 修复接口定义添加body文件切换到test文件丢失的缺陷 (#18175)

--bug=1017015 --user=王孝刚 【接口测试】接口定义-请求体上传文件-切换到TEST-更新接口-文件没了
https://www.tapd.cn/55049933/s/1249705

Co-authored-by: wxg0103 <727495428@qq.com>
This commit is contained in:
MeterSphere Bot 2022-09-22 11:26:42 +08:00 committed by GitHub
parent d4c8450632
commit 0e0f6d9811
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 23 additions and 0 deletions

View File

@ -394,6 +394,7 @@ export default {
init() { init() {
// //
this.api = JSON.parse(JSON.stringify(this.apiData)); this.api = JSON.parse(JSON.stringify(this.apiData));
this.initLocalFile();
this.api.protocol = this.currentProtocol; this.api.protocol = this.currentProtocol;
this.currentRequest = this.api.request; this.currentRequest = this.api.request;
if (!this.api.environmentId && this.$store.state.useEnvironment) { if (!this.api.environmentId && this.$store.state.useEnvironment) {
@ -401,6 +402,28 @@ export default {
} }
this.runLoading = false; this.runLoading = false;
this.checkVersionEnable(); this.checkVersionEnable();
},
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;
}
})
})
}
if (this.apiData.request.body.kvs && this.apiData.request.body.kvs.length > 0) {
this.apiData.request.body.kvs.forEach(item => {
this.api.request.body.kvs.forEach(api => {
if (item.uuid && api.uuid && item.uuid === api.uuid && item.files && api.files) {
api.files = item.files;
}
})
})
}
}
} }
}, },
created() { created() {