From 854825ff6c9ccde6e878a1d1e7145ad06efb41d9 Mon Sep 17 00:00:00 2001 From: chenjianxing Date: Wed, 27 Apr 2022 20:08:10 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E6=B5=8B=E8=AF=95=E8=AE=A1=E5=88=92?= =?UTF-8?q?=E5=8A=9F=E8=83=BD=E7=94=A8=E4=BE=8B=E9=A1=B5=E9=9D=A2=E5=86=85?= =?UTF-8?q?=E5=AD=98=E6=BA=A2=E5=87=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mapper/ext/ExtTestPlanTestCaseMapper.xml | 2 +- .../track/service/TestCaseIssueService.java | 7 +- .../track/plan/view/TestPlanView.vue | 14 ++-- .../functional/FunctionalTestCaseList.vue | 68 +++++++++---------- .../functional/TestPlanCaseIssueItem.vue | 45 ++++++++++++ 5 files changed, 89 insertions(+), 47 deletions(-) create mode 100644 frontend/src/business/components/track/plan/view/comonents/functional/TestPlanCaseIssueItem.vue diff --git a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtTestPlanTestCaseMapper.xml b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtTestPlanTestCaseMapper.xml index 61d6c4f39a..aeec0311c8 100644 --- a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtTestPlanTestCaseMapper.xml +++ b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtTestPlanTestCaseMapper.xml @@ -246,7 +246,7 @@ test_case.custom_num) as customNum, test_plan_test_case.executor, test_plan_test_case.status, test_plan_test_case.actual_result, test_plan_test_case.update_time, test_plan_test_case.create_time,test_case_node.name as model, project.name as - projectName,test_plan_test_case.issues as issues,test_plan_test_case.issues_count as issuesCount, + projectName, test_plan_test_case.issues_count as issuesCount, test_plan_test_case.plan_id as planId,test_case.version_id as versionId, project_version.name as versionName from test_plan_test_case diff --git a/backend/src/main/java/io/metersphere/track/service/TestCaseIssueService.java b/backend/src/main/java/io/metersphere/track/service/TestCaseIssueService.java index e472bf803a..3bdfdfeaa2 100644 --- a/backend/src/main/java/io/metersphere/track/service/TestCaseIssueService.java +++ b/backend/src/main/java/io/metersphere/track/service/TestCaseIssueService.java @@ -1,7 +1,6 @@ package io.metersphere.track.service; import com.alibaba.fastjson.JSON; -import com.alibaba.fastjson.JSONObject; import io.metersphere.base.domain.*; import io.metersphere.base.mapper.IssuesMapper; import io.metersphere.base.mapper.TestCaseIssuesMapper; @@ -106,15 +105,11 @@ public class TestCaseIssueService { } public void updateIssuesCount(String resourceId) { - List issues = issuesService.getIssues(resourceId, IssueRefType.PLAN_FUNCTIONAL.name()); - int issuesCount = issues.size(); + int issuesCount = issuesService.getIssues(resourceId, IssueRefType.PLAN_FUNCTIONAL.name()).size(); TestPlanTestCaseExample example = new TestPlanTestCaseExample(); example.createCriteria().andIdEqualTo(resourceId); TestPlanTestCaseWithBLOBs testPlanTestCase = new TestPlanTestCaseWithBLOBs(); testPlanTestCase.setIssuesCount(issuesCount); - if (!CollectionUtils.isEmpty(issues)) { - testPlanTestCase.setIssues(JSONObject.toJSONString(issues)); - } testPlanTestCaseMapper.updateByExampleSelective(testPlanTestCase, example); } diff --git a/frontend/src/business/components/track/plan/view/TestPlanView.vue b/frontend/src/business/components/track/plan/view/TestPlanView.vue index 1c02736ba7..fd06a740b7 100644 --- a/frontend/src/business/components/track/plan/view/TestPlanView.vue +++ b/frontend/src/business/components/track/plan/view/TestPlanView.vue @@ -102,14 +102,13 @@ export default { } }, created() { - this.$EventBus.$on('projectChange', () => { - if (this.$route.name === 'planView') { - this.$router.push('/track/plan/all'); - } - }); + this.$EventBus.$on('projectChange', this.handleProjectChange); this.projectId = getCurrentProjectID(); this.checkVersionEnable(); }, + destroyed () { + this.$EventBus.$off('projectChange', this.handleProjectChange); + }, mounted() { this.getTestPlans(); }, @@ -117,6 +116,11 @@ export default { this.genRedirectParam(); }, methods: { + handleProjectChange() { + if (this.$route.name === 'planView') { + this.$router.push('/track/plan/all'); + } + }, genRedirectParam() { this.redirectCharType = this.$route.params.charType; this.clickType = this.$route.params.clickType; diff --git a/frontend/src/business/components/track/plan/view/comonents/functional/FunctionalTestCaseList.vue b/frontend/src/business/components/track/plan/view/comonents/functional/FunctionalTestCaseList.vue index bccde42b48..4c2731db83 100644 --- a/frontend/src/business/components/track/plan/view/comonents/functional/FunctionalTestCaseList.vue +++ b/frontend/src/business/components/track/plan/view/comonents/functional/FunctionalTestCaseList.vue @@ -29,14 +29,14 @@ :operators="operators" :screen-height="screenHeight" :batch-operators="buttons" - @handlePageChange="initTableData" - @handleRowClick="handleEdit" :fields.sync="fields" :remember-order="true" - @refresh="initTableData" :row-order-group-id="planId" :row-order-func="editTestPlanTestCaseOrder" :enable-order-drag="enableOrderDrag" + @refresh="initTableData" + @handlePageChange="initTableData" + @handleRowClick="handleEdit" row-key="id" ref="table"> @@ -132,24 +132,16 @@ placement="right" width="400" trigger="hover"> - - - - - - - - {{ scope.row.issuesSize }} + + + + {{ scope.row.issuesSize }} + + @@ -288,7 +280,6 @@ import MsTableOperator from "../../../../../common/components/MsTableOperator"; import MsTableOperatorButton from "../../../../../common/components/MsTableOperatorButton"; import {TEST_PLAN_TEST_CASE_CONFIGS} from "../../../../../common/components/search/search-components"; import BatchEdit from "../../../../case/components/BatchEdit"; -import ClassicEditor from "@ckeditor/ckeditor5-build-classic"; import MsTag from "@/business/components/common/components/MsTag"; import { buildBatchParam, @@ -303,10 +294,12 @@ import {getTestTemplate} from "@/network/custom-field-template"; import {editTestPlanTestCaseOrder} from "@/network/test-plan"; import {SYSTEM_FIELD_NAME_MAP} from "@/common/js/table-constants"; import {getTestPlanTestCase} from "@/network/testCase"; +import TestPlanCaseIssueItem from "@/business/components/track/plan/view/comonents/functional/TestPlanCaseIssueItem"; export default { name: "FunctionalTestCaseList", components: { + TestPlanCaseIssueItem, MsTableColumn, MsTable, FunctionalTestCaseEdit, @@ -401,11 +394,6 @@ export default { {name: this.$t('test_track.plan_view.skip'), id: 'Skip'} ] }, - editor: ClassicEditor, - editorConfig: { - // 'increaseIndent','decreaseIndent' - toolbar: [], - }, selectDataRange: "all", testCaseTemplate: {}, versionFilters: [] @@ -455,21 +443,30 @@ export default { }, mounted() { this.$emit('setCondition', this.condition); - this.$EventBus.$on("openFailureTestCase", row => { - this.isReadOnly = true; - this.condition.status = 'Failure'; - this.$refs.testPlanTestCaseEdit.openTestCaseEdit(row, this.tableData); - }); + this.$EventBus.$on("openFailureTestCase", this.handleOpenFailureTestCase); this.refreshTableAndPlan(); this.hasEditPermission = hasPermission('PROJECT_TRACK_PLAN:READ+EDIT'); this.getMaintainerOptions(); this.getTemplateField(); this.getVersionOptions(); }, - beforeDestroy() { - this.$EventBus.$off("openFailureTestCase"); + destroyed() { + this.$EventBus.$off("openFailureTestCase", this.handleOpenFailureTestCase); }, methods: { + loadIssue(row) { + if(row.issuesSize && !row.hasLoadIssue) { + this.$get("/issues/get/case/PLAN_FUNCTIONAL/" + row.id).then(response => { + this.$set(row, "issuesContent", response.data.data); + this.$set(row, "hasLoadIssue", true); + }); + } + }, + handleOpenFailureTestCase(row) { + this.isReadOnly = true; + this.condition.status = 'Failure'; + this.$refs.testPlanTestCaseEdit.openTestCaseEdit(row, this.tableData); + }, nextPage() { this.currentPage++; this.initTableData(() => { @@ -534,7 +531,8 @@ export default { } this.$set(this.tableData[i], "showTags", JSON.parse(this.tableData[i].tags)); this.$set(this.tableData[i], "issuesSize", this.tableData[i].issuesCount); - this.$set(this.tableData[i], "issuesContent", JSON.parse(this.tableData[i].issues)); + this.$set(this.tableData[i], "hasLoadIssue", false); + this.$set(this.tableData[i], "issuesContent", []); } } diff --git a/frontend/src/business/components/track/plan/view/comonents/functional/TestPlanCaseIssueItem.vue b/frontend/src/business/components/track/plan/view/comonents/functional/TestPlanCaseIssueItem.vue new file mode 100644 index 0000000000..d4188e309f --- /dev/null +++ b/frontend/src/business/components/track/plan/view/comonents/functional/TestPlanCaseIssueItem.vue @@ -0,0 +1,45 @@ + + + + +