From db73275ccd8b55e8c23913122272a3c22cfba5b4 Mon Sep 17 00:00:00 2001 From: chenjianxing Date: Mon, 24 Jan 2022 22:35:04 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20=E5=8A=9F=E8=83=BD=E7=94=A8?= =?UTF-8?q?=E4=BE=8B=E9=A1=B5=E9=9D=A2=E6=80=A7=E8=83=BD=E4=BC=98=E5=8C=96?= =?UTF-8?q?=20--bug=3D1009823=20--user=3D=E9=99=88=E5=BB=BA=E6=98=9F=20?= =?UTF-8?q?=E3=80=90=E6=B5=8B=E8=AF=95=E8=B7=9F=E8=B8=AA=E3=80=91github#96?= =?UTF-8?q?51=EF=BC=8C=E5=8A=9F=E8=83=BD=E6=B5=8B=E8=AF=95=E7=94=A8?= =?UTF-8?q?=E4=BE=8B=E7=82=B9=E5=87=BB=E7=BC=96=E8=BE=91=E7=BB=8F=E5=B8=B8?= =?UTF-8?q?=E5=8A=A0=E8=BD=BD=E6=85=A2=E4=B9=8B=E5=90=8E=E9=A1=B5=E9=9D=A2?= =?UTF-8?q?=E5=A5=94=E6=BA=83=20https://www.tapd.cn/55049933/s/10970588?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../track/controller/TestCaseController.java | 5 -- .../track/service/TestCaseService.java | 9 --- .../components/MsPreviousNextButton.vue | 39 +++++++-- .../track/case/components/TestCaseEdit.vue | 38 +-------- .../case/components/TestCaseEditShow.vue | 38 +-------- .../functional/FunctionalTestCaseEdit.vue | 81 +++++++++++++------ .../functional/FunctionalTestCaseList.vue | 37 ++++++--- 7 files changed, 122 insertions(+), 125 deletions(-) diff --git a/backend/src/main/java/io/metersphere/track/controller/TestCaseController.java b/backend/src/main/java/io/metersphere/track/controller/TestCaseController.java index 21ad3259e5..4ac5fa54a1 100644 --- a/backend/src/main/java/io/metersphere/track/controller/TestCaseController.java +++ b/backend/src/main/java/io/metersphere/track/controller/TestCaseController.java @@ -100,11 +100,6 @@ public class TestCaseController { return testCaseService.listTestCaseMthod(request); } - @PostMapping("/list/ids") - public List getTestPlanCaseIds(@RequestBody QueryTestCaseRequest request) { - return testCaseService.listTestCaseIds(request); - } - @GetMapping("/relationship/case/{id}/{relationshipType}") public List getRelationshipCase(@PathVariable("id") String id, @PathVariable("relationshipType") String relationshipType) { return testCaseService.getRelationshipCase(id, relationshipType); 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 ad32d767a5..c060a2d882 100644 --- a/backend/src/main/java/io/metersphere/track/service/TestCaseService.java +++ b/backend/src/main/java/io/metersphere/track/service/TestCaseService.java @@ -1772,15 +1772,6 @@ public class TestCaseService { return request.getId(); } - public List listTestCaseIds(QueryTestCaseRequest request) { - setDefaultOrder(request); - List selectFields = new ArrayList<>(); - selectFields.add("test_case.id"); - selectFields.add("test_case.name"); - request.setSelectFields(selectFields); - return extTestCaseMapper.listIds(request); - } - public void minderEdit(TestCaseMinderEditRequest request) { deleteToGcBatch(request.getIds()); diff --git a/frontend/src/business/components/common/components/MsPreviousNextButton.vue b/frontend/src/business/components/common/components/MsPreviousNextButton.vue index ae2a31ad71..75b3f3c46e 100644 --- a/frontend/src/business/components/common/components/MsPreviousNextButton.vue +++ b/frontend/src/business/components/common/components/MsPreviousNextButton.vue @@ -1,17 +1,17 @@ @@ -35,6 +35,35 @@ default() { return 0 } + }, + pageTotal: { + type: Number, + default() { + return 0 + } + }, + total: { + type: Number, + default() { + return 0 + } + }, + pageNum: { + type: Number, + default() { + return 0 + } + }, + pageSize: { + type: Number, + default() { + return 0 + } + } + }, + computed: { + countNum() { + return this.pageSize * (this.pageNum - 1) + this.index + 1; } }, methods: { diff --git a/frontend/src/business/components/track/case/components/TestCaseEdit.vue b/frontend/src/business/components/track/case/components/TestCaseEdit.vue index 514a6af703..4d831e9291 100644 --- a/frontend/src/business/components/track/case/components/TestCaseEdit.vue +++ b/frontend/src/business/components/track/case/components/TestCaseEdit.vue @@ -299,8 +299,6 @@ export default { {value: 'manual', label: this.$t('test_track.case.manual')} ], testCase: {}, - testCases: [], - index: 0, showInputTag: true, tableType: "", stepFilter: new STEP, @@ -602,7 +600,7 @@ export default { this.customFieldForm = parseCustomField(this.form, this.testCaseTemplate, this.customFieldRules, buildTestCaseOldFields(this.form)); this.reload(); } else { - this.initTestCases(testCase); + this.getTestCase(testCase.id); } } else { if (this.selectNode.data) { @@ -629,40 +627,10 @@ export default { this.getComments(this.currentTestCaseInfo); } }, - handlePre() { - this.index--; - this.getTestCase(this.index) - }, - handleNext() { - this.index++; - this.getTestCase(this.index); - }, - initTestCases(testCase) { - if (this.publicEnable) { - this.selectCondition.projectId = null; - } else { - this.selectCondition.workspaceId = null; - } - this.selectCondition.versionId = testCase.versionId - this.result = this.$post('/test/case/list/ids', this.selectCondition, response => { - this.testCases = response.data; - for (let i = 0; i < this.testCases.length; i++) { - if (this.testCases[i].id === testCase.id) { - this.index = i; - this.getTestCase(i); - } - } - }); - }, - getTestCase(index) { - let id = ""; + getTestCase(id) { this.showInputTag = false; - let testCase = this.testCases[index]; - if (typeof (index) == "undefined") { + if (!id) { id = this.currentTestCaseInfo.id; - - } else { - id = testCase.id; } this.result = this.$get('/test/case/get/' + id, response => { if (response.data) { diff --git a/frontend/src/business/components/track/case/components/TestCaseEditShow.vue b/frontend/src/business/components/track/case/components/TestCaseEditShow.vue index fc1bc76db4..1aeb7ea2cb 100644 --- a/frontend/src/business/components/track/case/components/TestCaseEditShow.vue +++ b/frontend/src/business/components/track/case/components/TestCaseEditShow.vue @@ -290,8 +290,6 @@ export default { {value: 'manual', label: this.$t('test_track.case.manual')} ], testCase: {}, - testCases: [], - index: 0, showInputTag: true, tableType: "", stepFilter: new STEP, @@ -561,7 +559,7 @@ export default { this.customFieldForm = parseCustomField(this.form, this.testCaseTemplate, this.customFieldRules, buildTestCaseOldFields(this.form)); this.reload(); } else { - this.initTestCases(testCase); + this.getTestCase(testCase.id); } } else { if (this.selectNode.data) { @@ -585,40 +583,10 @@ export default { callback(); } }, - handlePre() { - this.index--; - this.getTestCase(this.index) - }, - handleNext() { - this.index++; - this.getTestCase(this.index); - }, - initTestCases(testCase) { - if (this.publicEnable) { - this.selectCondition.projectId = null; - } else { - this.selectCondition.workspaceId = null; - } - this.selectCondition.versionId = testCase.versionId - this.result = this.$post('/test/case/list/ids', this.selectCondition, response => { - this.testCases = response.data; - for (let i = 0; i < this.testCases.length; i++) { - if (this.testCases[i].id === testCase.id) { - this.index = i; - this.getTestCase(i); - } - } - }); - }, - getTestCase(index) { - let id = ""; + getTestCase(id) { this.showInputTag = false; - let testCase = this.testCases[index]; - if (typeof (index) == "undefined") { + if (!id) { id = this.currentTestCaseInfo.id; - - } else { - id = testCase.id; } this.result = this.$get('/test/case/get/' + id, response => { if (response.data) { 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 22279e3353..c3a33a14c9 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 @@ -27,7 +27,15 @@ - + {{$t('test_track.save')}} & {{$t('test_track.next')}} @@ -185,7 +193,6 @@ export default { showDialog: false, testCase: {}, index: 0, - testCases: [], editor: ClassicEditor, editorConfig: { toolbar: ['heading', '|', 'bold', 'italic', 'link', 'bulletedList', 'numberedList', 'blockQuote', 'insertTable', '|', 'undo', 'redo'], @@ -207,14 +214,21 @@ export default { isCustomFiledActive: false, otherInfoActive: true, isReadOnly: false, + testCases: [] }; }, props: { total: { - type: Number + type: Number, + }, searchParam: { type: Object + }, + pageNum: Number, + pageSize: { + type: Number, + default: 1 } }, computed: { @@ -226,6 +240,9 @@ export default { }, statusReadOnly() { return !hasPermission('PROJECT_TRACK_PLAN:READ+RUN'); + }, + pageTotal() { + return this.total / this.pageSize; } }, methods: { @@ -290,6 +307,10 @@ export default { }; }, saveCase(next, noTip) { + if (next && this.index === this.testCases.length - 1) {//需要翻页 + this.handleNext(); + return; + } let param = {}; param.id = this.testCase.id; param.status = this.testCase.status; @@ -320,7 +341,7 @@ export default { } this.updateTestCases(param); this.setPlanStatus(this.testCase.planId); - if (next && this.index < this.testCases.length - 1) { + if (next) { this.handleNext(); } }); @@ -337,8 +358,15 @@ export default { } }, handleNext() { + if (this.index === this.testCases.length - 1 && this.pageNum === this.pageTotal) { + this.$warning('已经是最后一页'); + return; + } else if (this.index === this.testCases.length - 1) { + this.$emit('nextPage'); + return; + } this.index++; - this.getTestCase(this.index); + this.getTestCase(this.testCases[this.index].id); this.reloadOtherInfo(); }, reloadOtherInfo() { @@ -348,15 +376,20 @@ export default { }) }, handlePre() { + if (this.index === 0 && this.pageNum === 1) { + this.$warning('已经是第一页'); + return; + } else if (this.index === 0) { + this.$emit('prePage'); + return; + } this.index--; - this.getTestCase(this.index); + this.getTestCase(this.testCases[this.index].id); this.reloadOtherInfo(); }, - getTestCase(index) { - this.testCase = {}; - let testCase = this.testCases[index]; + getTestCase(id) { // id 为 TestPlanTestCase 的 id - this.result = this.$get('/test/plan/case/get/' + testCase.id, response => { + this.result = this.$get('/test/plan/case/get/' + id, response => { let item = {}; Object.assign(item, response.data); if (item.results) { @@ -400,19 +433,30 @@ export default { this.getComments(item); }); }, - openTestCaseEdit(testCase) { + openTestCaseEdit(testCase, tableData) { this.showDialog = true; this.activeTab = 'detail'; this.hasTapdId = false; this.hasZentaoId = false; this.isReadOnly = !hasPermission('PROJECT_TRACK_PLAN:READ+RELEVANCE_OR_CANCEL'); + if (tableData) { + this.testCases = tableData; + for (let i = 0; i < this.testCases.length; i++) { + let item = this.testCases[i]; + if (item.id === testCase.id) { + this.index = i; + break; + } + } + } + listenGoBack(this.handleClose); - let initFuc = this.initData; + let initFuc = this.getTestCase; getTemplate('field/template/case/get/relate/', this) .then((template) => { this.testCaseTemplate = template; - initFuc(testCase); + initFuc(testCase.id); }); if (this.$refs.otherInfo) { this.$refs.otherInfo.reset(); @@ -432,17 +476,6 @@ export default { saveReport(reportId) { this.$post('/test/plan/case/edit', {id: this.testCase.id, reportId: reportId}); }, - initData(testCase) { - this.result = this.$post('/test/plan/case/list/ids', this.searchParam, response => { - this.testCases = response.data; - for (let i = 0; i < this.testCases.length; i++) { - if (this.testCases[i].id === testCase.id) { - this.index = i; - this.getTestCase(i); - } - } - }); - }, openTest(item) { const type = item.testType; const id = item.testId; 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 dc71d04d42..76f1b387c5 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 @@ -248,8 +248,14 @@ { this.isReadOnly = true; this.condition.status = 'Failure'; - this.$refs.testPlanTestCaseEdit.openTestCaseEdit(row); + this.$refs.testPlanTestCaseEdit.openTestCaseEdit(row, this.tableData); }); this.refreshTableAndPlan(); this.hasEditPermission = hasPermission('PROJECT_TRACK_PLAN:READ+EDIT'); @@ -460,6 +466,18 @@ export default { hub.$off("openFailureTestCase"); }, methods: { + nextPage() { + this.currentPage++; + this.initTableData(() => { + this.$refs.testPlanTestCaseEdit.openTestCaseEdit(this.tableData[0], this.tableData); + }); + }, + prePage() { + this.currentPage--; + this.initTableData(() => { + this.$refs.testPlanTestCaseEdit.openTestCaseEdit(this.tableData[this.tableData.length - 1], this.tableData); + }); + }, getTemplateField() { this.result.loading = true; let p1 = getProjectMember((data) => { @@ -478,7 +496,7 @@ export default { getCustomFieldValue(row, field) { return getCustomFieldValue(row, field, this.members); }, - initTableData() { + initTableData(callback) { initCondition(this.condition, this.condition.selectAll); this.enableOrderDrag = this.condition.orders.length > 0 ? false : true; @@ -515,6 +533,9 @@ export default { this.$set(this.tableData[i], "issuesContent", JSON.parse(this.tableData[i].issues)); } } + if (callback) { + callback(); + } }); } }, @@ -527,7 +548,7 @@ export default { }, showDetail(row, event, column) { this.isReadOnly = !this.hasEditPermission; - this.$refs.testPlanTestCaseEdit.openTestCaseEdit(row); + this.$refs.testPlanTestCaseEdit.openTestCaseEdit(row, this.tableData); }, refresh() { this.condition = {components: TEST_PLAN_TEST_CASE_CONFIGS}; @@ -556,7 +577,7 @@ export default { }, handleEdit(testCase, index) { this.isReadOnly = false; - this.$refs.testPlanTestCaseEdit.openTestCaseEdit(testCase); + this.$refs.testPlanTestCaseEdit.openTestCaseEdit(testCase, this.tableData); }, handleDelete(testCase) { this.$alert(this.$t('test_track.plan_view.confirm_cancel_relevance') + ' ' + testCase.name + " ?", '', { @@ -678,14 +699,6 @@ export default { margin-left: 10px; } -/*.ms-table-header >>> .table-title {*/ -/* height: 0px;*/ -/*}*/ - -/*/deep/ .el-table__fixed-body-wrapper {*/ -/* top: 59px !important;*/ -/*}*/ - .ms-table-header { margin-bottom: 10px; }