From 422aaf55b1fbd585b69c333dfa7a3717ddac2526 Mon Sep 17 00:00:00 2001 From: wenyann Date: Fri, 9 Jul 2021 11:34:50 +0800 Subject: [PATCH] =?UTF-8?q?fix:=E3=80=90github=E3=80=91=E6=B5=8B=E8=AF=95?= =?UTF-8?q?=E8=B7=9F=E8=B8=AA=20=E6=96=B0=E5=BB=BA=E7=94=A8=E4=BE=8B?= =?UTF-8?q?=E5=85=B3=E8=81=94=E6=8E=A5=E5=8F=A3=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../track/service/TestCaseService.java | 4 +- .../track/service/TestPlanService.java | 29 +++++----- .../case/components/TestCaseEditOtherInfo.vue | 56 ++++++++++++++++--- 3 files changed, 66 insertions(+), 23 deletions(-) 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 3839db3470..1af5e8186a 100644 --- a/backend/src/main/java/io/metersphere/track/service/TestCaseService.java +++ b/backend/src/main/java/io/metersphere/track/service/TestCaseService.java @@ -1066,7 +1066,7 @@ public class TestCaseService { TestCaseTest test = new TestCaseTest(); selecteds.forEach(id -> { test.setTestType(id.get(0)); - test.setTestId(id.get(1)); + test.setTestId(id.get(id.size() - 1)); test.setTestCaseId(request.getId()); test.setCreateTime(System.currentTimeMillis()); test.setUpdateTime(System.currentTimeMillis()); @@ -1113,7 +1113,7 @@ public class TestCaseService { TestCaseTest test = new TestCaseTest(); selecteds.forEach(id -> { test.setTestType(id.get(0)); - test.setTestId(id.get(1)); + test.setTestId(id.get(id.size() - 1)); test.setCreateTime(System.currentTimeMillis()); test.setUpdateTime(System.currentTimeMillis()); test.setTestCaseId(request.getId()); diff --git a/backend/src/main/java/io/metersphere/track/service/TestPlanService.java b/backend/src/main/java/io/metersphere/track/service/TestPlanService.java index 033efa482b..f449e5a2eb 100644 --- a/backend/src/main/java/io/metersphere/track/service/TestPlanService.java +++ b/backend/src/main/java/io/metersphere/track/service/TestPlanService.java @@ -524,20 +524,23 @@ public class TestPlanService { if (StringUtils.equals(l.getTestType(), TestCaseStatus.automation.name())) { TestPlanApiScenario t = new TestPlanApiScenario(); ApiScenarioWithBLOBs testPlanApiScenario = apiScenarioMapper.selectByPrimaryKey(l.getTestId()); - t.setId(UUID.randomUUID().toString()); - t.setTestPlanId(request.getPlanId()); - t.setApiScenarioId(l.getTestId()); - t.setLastResult(testPlanApiScenario.getLastResult()); - t.setPassRate(testPlanApiScenario.getPassRate()); - t.setReportId(testPlanApiScenario.getReportId()); - t.setStatus(testPlanApiScenario.getStatus()); - t.setCreateTime(System.currentTimeMillis()); - t.setUpdateTime(System.currentTimeMillis()); - TestPlanApiScenarioExample example = new TestPlanApiScenarioExample(); - example.createCriteria().andTestPlanIdEqualTo(request.getPlanId()).andApiScenarioIdEqualTo(t.getApiScenarioId()); - if (testPlanApiScenarioMapper.countByExample(example) <= 0) { - testPlanApiScenarioMapper.insert(t); + if (testPlanApiScenario != null) { + t.setId(UUID.randomUUID().toString()); + t.setTestPlanId(request.getPlanId()); + t.setApiScenarioId(l.getTestId()); + t.setLastResult(testPlanApiScenario.getLastResult()); + t.setPassRate(testPlanApiScenario.getPassRate()); + t.setReportId(testPlanApiScenario.getReportId()); + t.setStatus(testPlanApiScenario.getStatus()); + t.setCreateTime(System.currentTimeMillis()); + t.setUpdateTime(System.currentTimeMillis()); + TestPlanApiScenarioExample example = new TestPlanApiScenarioExample(); + example.createCriteria().andTestPlanIdEqualTo(request.getPlanId()).andApiScenarioIdEqualTo(t.getApiScenarioId()); + if (testPlanApiScenarioMapper.countByExample(example) <= 0) { + testPlanApiScenarioMapper.insert(t); + } } + } }); }); diff --git a/frontend/src/business/components/track/case/components/TestCaseEditOtherInfo.vue b/frontend/src/business/components/track/case/components/TestCaseEditOtherInfo.vue index 93d0c2681d..f39edadcd9 100644 --- a/frontend/src/business/components/track/case/components/TestCaseEditOtherInfo.vue +++ b/frontend/src/business/components/track/case/components/TestCaseEditOtherInfo.vue @@ -15,11 +15,12 @@ - - + + ref="cascade"> @@ -293,14 +294,48 @@ export default { this.form.type = val; this.testOptions = []; let url = ''; - if (this.form.type === 'testcase' || this.form.type === 'automation') { + if (this.form.type === 'testcase') { url = '/api/' + this.form.type + '/list/' + this.projectId; + if (!url) { + return; + } + this.buildValue(url); } else if (this.form.type === 'performance' || this.form.type === 'api') { url = '/' + this.form.type + '/list/' + this.projectId; + if (!url) { + return; + } + this.buildValue(url); + } else if (this.form.type === 'automation') { + //url = '/api/' + this.form.type + '/list/' + this.projectId; + url = '/api/automation/module/list/' + this.projectId; + if (!url) { + return; + } + this.result.loading = true; + return new Promise((resolve, reject) => { + this.$get("/api/automation/module/list/" + this.projectId, response => { + if (response.data != undefined && response.data != null) { + this.buildTreeValue(response.data); + } + this.result.loading = false; + resolve(response.data); + }); + }); } - if (!url) { - return; - } + }, + + buildTreeValue(list) { + list.forEach(item => { + item.value = item.id, + item.label = item.name, + item.leaf = true; + if (item.children) { + this.buildTreeValue(item.children); + } + }); + }, + buildValue(url) { this.result.loading = true; return new Promise((resolve, reject) => { this.$get(url).then(res => { @@ -315,7 +350,7 @@ export default { reject(err); }); }); - }, + } } }; @@ -333,4 +368,9 @@ export default { .remark-item { padding: 0px 15px; } + +.el-cascader >>> .el-input { + cursor: pointer; + width: 300px; +}