From 1acb119ddff826a97f588b11cbdfa306c679e0ed Mon Sep 17 00:00:00 2001 From: AnAngle <1323481023@qq.com> Date: Wed, 7 Sep 2022 11:26:56 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E6=B5=8B=E8=AF=95=E8=B7=9F=E8=B8=AA):=20?= =?UTF-8?q?=E6=B5=8B=E8=AF=95=E8=AE=A1=E5=88=92=E5=8A=9F=E8=83=BD=E7=94=A8?= =?UTF-8?q?=E4=BE=8B=E4=B8=8D=E5=B1=95=E7=A4=BA=E8=87=AA=E5=AE=9A=E4=B9=89?= =?UTF-8?q?=E5=AD=97=E6=AE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --bug=1016573 --user=陈建星 【测试跟踪】github #17657,功能用例自定义字段已经输入值并保存,在任务计划中关联用例后自定义字段值消失 https://www.tapd.cn/55049933/s/1239713 --- .../java/io/metersphere/track/dto/TestPlanCaseDTO.java | 2 ++ .../io/metersphere/track/service/TestCaseService.java | 9 +++++++-- .../track/service/TestPlanTestCaseService.java | 3 +++ .../view/comonents/functional/FunctionalTestCaseEdit.vue | 7 +++++++ 4 files changed, 19 insertions(+), 2 deletions(-) diff --git a/backend/src/main/java/io/metersphere/track/dto/TestPlanCaseDTO.java b/backend/src/main/java/io/metersphere/track/dto/TestPlanCaseDTO.java index 446cbe6a0f..8d2469c63f 100644 --- a/backend/src/main/java/io/metersphere/track/dto/TestPlanCaseDTO.java +++ b/backend/src/main/java/io/metersphere/track/dto/TestPlanCaseDTO.java @@ -2,6 +2,7 @@ package io.metersphere.track.dto; import io.metersphere.base.domain.IssuesDao; import io.metersphere.base.domain.TestCaseWithBLOBs; +import io.metersphere.dto.CustomFieldDao; import lombok.Getter; import lombok.Setter; import java.util.List; @@ -28,4 +29,5 @@ public class TestPlanCaseDTO extends TestCaseWithBLOBs { private List list; private List issueList; + private List fields; } 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 aac32eadbc..b30b0429f5 100644 --- a/backend/src/main/java/io/metersphere/track/service/TestCaseService.java +++ b/backend/src/main/java/io/metersphere/track/service/TestCaseService.java @@ -754,8 +754,13 @@ public class TestCaseService { } private void buildCustomField(TestCaseDTO data) { + List fields = getCustomFiledById(data.getId()); + data.setFields(fields); + } + + public List getCustomFiledById(String id) { CustomFieldTestCaseExample example = new CustomFieldTestCaseExample(); - example.createCriteria().andResourceIdEqualTo(data.getId()); + example.createCriteria().andResourceIdEqualTo(id); List customFieldTestCases = customFieldTestCaseMapper.selectByExampleWithBLOBs(example); List fields = new ArrayList<>(); customFieldTestCases.forEach(i -> { @@ -765,7 +770,7 @@ public class TestCaseService { customFieldDao.setTextValue(i.getTextValue()); fields.add(customFieldDao); }); - data.setFields(fields); + return fields; } private void buildProjectInfoWidthoutProject(List resList) { diff --git a/backend/src/main/java/io/metersphere/track/service/TestPlanTestCaseService.java b/backend/src/main/java/io/metersphere/track/service/TestPlanTestCaseService.java index 768ac801eb..04475be5cf 100644 --- a/backend/src/main/java/io/metersphere/track/service/TestPlanTestCaseService.java +++ b/backend/src/main/java/io/metersphere/track/service/TestPlanTestCaseService.java @@ -14,6 +14,7 @@ import io.metersphere.commons.utils.*; import io.metersphere.controller.request.OrderRequest; import io.metersphere.controller.request.ResetOrderRequest; import io.metersphere.controller.request.member.QueryMemberRequest; +import io.metersphere.dto.CustomFieldDao; import io.metersphere.dto.ProjectConfig; import io.metersphere.log.vo.DetailColumn; import io.metersphere.log.vo.OperatingLogDetails; @@ -275,6 +276,8 @@ public class TestPlanTestCaseService { testCaseTestDTOS.forEach(dto -> { setTestName(dto); }); + List fields = testCaseService.getCustomFiledById(testPlanCaseDTO.getCaseId()); + testPlanCaseDTO.setFields(fields); testPlanCaseDTO.setList(testCaseTestDTOS); return testPlanCaseDTO; } diff --git a/frontend/src/business/components/track/plan/view/comonents/functional/FunctionalTestCaseEdit.vue b/frontend/src/business/components/track/plan/view/comonents/functional/FunctionalTestCaseEdit.vue index 08b3d9578a..41741b2cff 100644 --- a/frontend/src/business/components/track/plan/view/comonents/functional/FunctionalTestCaseEdit.vue +++ b/frontend/src/business/components/track/plan/view/comonents/functional/FunctionalTestCaseEdit.vue @@ -417,6 +417,13 @@ export default { this.testCase = item; this.originalStatus = this.testCase.status; parseCustomField(this.testCase, this.testCaseTemplate, null, buildTestCaseOldFields(this.testCase)); + this.testCaseTemplate.customFields.forEach(item => { + try { + item.defaultValue = JSON.parse(item.defaultValue); + } catch (e) { + // nothing + } + }); this.isCustomFiledActive = true; if (!this.testCase.actualResult) { // 如果没值,使用模板的默认值