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) { // 如果没值,使用模板的默认值