diff --git a/backend/src/main/java/io/metersphere/track/service/TestCaseService.java b/backend/src/main/java/io/metersphere/track/service/TestCaseService.java index 5f2ff02b86..81b2a89d2b 100644 --- a/backend/src/main/java/io/metersphere/track/service/TestCaseService.java +++ b/backend/src/main/java/io/metersphere/track/service/TestCaseService.java @@ -966,9 +966,7 @@ public class TestCaseService { } public String save(EditTestCaseRequest request, List files) { - if (files == null) { - throw new IllegalArgumentException(Translator.get("file_cannot_be_null")); - } + final TestCaseWithBLOBs testCaseWithBLOBs = addTestCase(request); //插入测试与用例关系表 @@ -996,14 +994,16 @@ public class TestCaseService { }); } + if (files != null) { + files.forEach(file -> { + final FileMetadata fileMetadata = fileService.saveFile(file, testCaseWithBLOBs.getProjectId()); + TestCaseFile testCaseFile = new TestCaseFile(); + testCaseFile.setCaseId(testCaseWithBLOBs.getId()); + testCaseFile.setFileId(fileMetadata.getId()); + testCaseFileMapper.insert(testCaseFile); + }); + } - files.forEach(file -> { - final FileMetadata fileMetadata = fileService.saveFile(file, testCaseWithBLOBs.getProjectId()); - TestCaseFile testCaseFile = new TestCaseFile(); - testCaseFile.setCaseId(testCaseWithBLOBs.getId()); - testCaseFile.setFileId(fileMetadata.getId()); - testCaseFileMapper.insert(testCaseFile); - }); return testCaseWithBLOBs.getId(); } diff --git a/frontend/src/business/components/track/case/components/TestCaseEdit.vue b/frontend/src/business/components/track/case/components/TestCaseEdit.vue index 9cd61f7e00..32ff29d9e5 100644 --- a/frontend/src/business/components/track/case/components/TestCaseEdit.vue +++ b/frontend/src/business/components/track/case/components/TestCaseEdit.vue @@ -6,7 +6,7 @@
{{$t('operating_log.change_history')}} - { + if (typeof (index) == "undefined") { + id = this.currentTestCaseInfo.id; + + } else { + id = testCase.id; + } + this.result = this.$get('/test/case/get/' + id, response => { + if (response.data) { + this.path = "/test/case/edit"; + if (this.currentTestCaseInfo.isCopy) { + this.path = "/test/case/add"; + } + } else { + this.path = "/test/case/add"; + } let testCase = response.data; this.setFormData(testCase); this.setTestCaseExtInfo(testCase); this.getSelectOptions(); this.reload(); this.$nextTick(() => { - this.showInputTag = true + this.showInputTag = true; }); + }); }, async setFormData(testCase) { @@ -578,12 +595,14 @@ let option = this.getOption(param); this.result = this.$request(option, (response) => { this.$success(this.$t('commons.save_success')); - this.operationType = "edit" + this.path = "/test/case/edit"; + // this.operationType = "edit" this.form.id = response.id; - this.$emit("refreshTestCase",) - this.tableType = 'edit'; + this.$emit("refreshTestCase",); + //this.tableType = 'edit'; this.$emit("refresh", this.form); - this.form.id = response.data + this.form.id = response.data; + if (this.type === 'add' || this.type === 'copy') { param.id = response.data; this.$emit("caseCreate", param); @@ -599,15 +618,16 @@ buildParam() { let param = {}; Object.assign(param, this.form); + console.log(param); param.steps = JSON.stringify(this.form.steps); param.nodeId = this.form.module; param.nodePath = getNodePath(this.form.module, this.moduleOptions); if (this.projectId) { param.projectId = this.projectId; } - if (this.type === 'copy') { - param.num = ""; - } + /* if (this.type === 'copy') { + param.num = ""; + }*/ param.name = param.name.trim(); if (this.form.tags instanceof Array) { @@ -638,17 +658,17 @@ } }, getOption(param) { - let type = {} - if (this.tableType === 'edit') { - type = 'edit' - } else if (this.type === 'copy') { - type = 'add' - } else { - type = this.type - } + /* let type = {} + if (this.tableType === 'edit') { + type = 'edit' + } else if (this.type === 'copy') { + type = 'add' + } else { + type = this.type + }*/ let formData = new FormData(); - let url = '/test/case/' + type; - + //let url = '/test/case/' + type; + console.log(this.$refs.otherInfo); if (this.$refs.otherInfo && this.$refs.otherInfo.uploadList) { this.$refs.otherInfo.uploadList.forEach(f => { formData.append("file", f); @@ -673,10 +693,9 @@ formData.append('request', new Blob([requestJson], { type: "application/json" })); - return { method: 'POST', - url: url, + url: this.path, data: formData, headers: { 'Content-Type': undefined