refactor(接口测试): 修复接口定义导入报错400的缺陷 (#15538)

--bug=1014651 --user=王孝刚 【接口测试】sql协议选中未规划接口后,再导入jmeter格式文件报错
https://www.tapd.cn/55049933/s/1195602

Co-authored-by: wxg0103 <727495428@qq.com>
This commit is contained in:
MeterSphere Bot 2022-07-06 17:30:02 +08:00 committed by GitHub
parent ca1ae84fcd
commit 572d25d30a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 38 additions and 0 deletions

View File

@ -227,6 +227,9 @@ export default {
}, },
open(module) { open(module) {
this.currentModule = module; this.currentModule = module;
if (localStorage.getItem('scenarioModule')) {
this.formData.moduleId = localStorage.getItem('scenarioModule');
}
this.visible = true; this.visible = true;
listenGoBack(this.close); listenGoBack(this.close);
}, },
@ -252,6 +255,7 @@ export default {
return true; return true;
}, },
save() { save() {
localStorage.setItem('scenarioModule', this.formData.moduleId);
if (!this.formData.file) { if (!this.formData.file) {
this.$warning("请添加一个文件"); this.$warning("请添加一个文件");
return; return;
@ -289,6 +293,9 @@ export default {
}) })
param.modeId = this.formData.modeId param.modeId = this.formData.modeId
} }
if (this.formData.moduleId.length === 0) {
param.moduleId = ''
}
param.projectId = this.projectId; param.projectId = this.projectId;
if (!this.swaggerUrlEable) { if (!this.swaggerUrlEable) {
param.swaggerUrl = undefined; param.swaggerUrl = undefined;
@ -296,6 +303,7 @@ export default {
return param; return param;
}, },
close() { close() {
localStorage.setItem('scenarioModule', this.formData.moduleId);
this.formData = { this.formData = {
file: undefined, file: undefined,
swaggerUrl: '', swaggerUrl: '',

View File

@ -362,9 +362,23 @@ export default {
open(module) { open(module) {
this.currentModule = module; this.currentModule = module;
this.visible = true; this.visible = true;
this.formData.moduleId = this.rememberModuleId();
listenGoBack(this.close); listenGoBack(this.close);
}, },
rememberModuleId() {
if (localStorage.getItem('tcp') || localStorage.getItem('http') || localStorage.getItem('sql') || localStorage.getItem('dubbo')) {
if (this.protocol === 'TCP') {
return localStorage.getItem('tcp');
} else if (this.protocol === 'HTTP') {
return localStorage.getItem('http');
} else if (this.protocol === 'SQL') {
return localStorage.getItem('sql');
} else if (this.protocol === 'DUBBO') {
return localStorage.getItem('dubbo');
}
}
},
upload(file) { upload(file) {
this.formData.file = file.file; this.formData.file = file.file;
}, },
@ -391,7 +405,19 @@ export default {
} }
return true; return true;
}, },
saveModule() {
if (this.protocol === 'TCP') {
localStorage.setItem('tcp', this.formData.moduleId);
} else if (this.protocol === 'HTTP') {
localStorage.setItem('http', this.formData.moduleId);
} else if (this.protocol === 'SQL') {
localStorage.setItem('sql', this.formData.moduleId);
} else if (this.protocol === 'DUBBO') {
localStorage.setItem('dubbo', this.formData.moduleId);
}
},
save() { save() {
this.saveModule();
this.$refs.form.validate(valid => { this.$refs.form.validate(valid => {
if (valid) { if (valid) {
if ((this.selectedPlatformValue != 'Swagger2' || (this.selectedPlatformValue == 'Swagger2' && !this.swaggerUrlEnable)) && !this.formData.file) { if ((this.selectedPlatformValue != 'Swagger2' || (this.selectedPlatformValue == 'Swagger2' && !this.swaggerUrlEnable)) && !this.formData.file) {
@ -440,6 +466,9 @@ export default {
if (this.currentModule) { if (this.currentModule) {
param.modeId = this.formData.modeId param.modeId = this.formData.modeId
} }
if (this.formData.moduleId.length === 0) {
param.moduleId = ''
}
param.projectId = this.projectId; param.projectId = this.projectId;
param.protocol = this.protocol; param.protocol = this.protocol;
if (!this.swaggerUrlEnable) { if (!this.swaggerUrlEnable) {
@ -459,6 +488,7 @@ export default {
return param; return param;
}, },
close() { close() {
this.saveModule();
this.formData = { this.formData = {
file: undefined, file: undefined,
swaggerUrl: '', swaggerUrl: '',