From dc13c1c6983c86f6819f439d1bcee345b354b47e Mon Sep 17 00:00:00 2001 From: chenjianxing Date: Mon, 22 Nov 2021 17:54:55 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E8=84=91=E5=9B=BE=E7=BC=BA=E9=99=B7?= =?UTF-8?q?=E6=94=AF=E6=8C=81=E5=8F=96=E6=B6=88=E5=85=B3=E8=81=94?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/package.json | 2 +- .../case/components/TestCaseIssueRelate.vue | 6 +-- .../track/common/minder/TestCaseMinder.vue | 7 +++- .../track/common/minder/TestPlanMinder.vue | 6 ++- .../track/common/minder/minderUtils.js | 37 ++++++++++++++++++- frontend/src/network/Issue.js | 6 ++- 6 files changed, 54 insertions(+), 10 deletions(-) diff --git a/frontend/package.json b/frontend/package.json index fa17225c97..4b4a080a6c 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -54,7 +54,7 @@ "vue-float-action-button": "^0.6.6", "vue-i18n": "^8.15.3", "vue-jsonpath-picker": "^1.1.5", - "vue-minder-editor-plus": "1.0.36", + "vue-minder-editor-plus": "1.0.38", "vue-papa-parse": "^2.0.0", "vue-pdf": "^4.2.0", "vue-router": "^3.1.3", diff --git a/frontend/src/business/components/track/case/components/TestCaseIssueRelate.vue b/frontend/src/business/components/track/case/components/TestCaseIssueRelate.vue index 248ec8c533..25fe61b8a6 100644 --- a/frontend/src/business/components/track/case/components/TestCaseIssueRelate.vue +++ b/frontend/src/business/components/track/case/components/TestCaseIssueRelate.vue @@ -97,7 +97,7 @@ import MsTableColumn from "@/business/components/common/components/table/MsTable import IssueDescriptionTableItem from "@/business/components/track/issue/IssueDescriptionTableItem"; import {ISSUE_STATUS_MAP} from "@/common/js/table-constants"; import IssueRelateList from "@/business/components/track/case/components/IssueRelateList"; -import {getIssuesByCaseId} from "@/network/Issue"; +import {deleteIssueRelate, getIssuesByCaseId} from "@/network/Issue"; import {getIssueTemplate} from "@/network/custom-field-template"; import {getCustomFieldValue, getTableHeaderWithCustomFields} from "@/common/js/tableUtils"; export default { @@ -201,10 +201,10 @@ export default { } }, deleteIssue(row) { - this.page.result = this.$post("/issues/delete/relate", {id: row.id, caseId: this.caseId}, () => { + this.page.result = deleteIssueRelate({id: row.id, caseId: this.caseId}, () => { this.getIssues(); this.$success(this.$t('commons.delete_success')); - }) + }); }, } } diff --git a/frontend/src/business/components/track/common/minder/TestCaseMinder.vue b/frontend/src/business/components/track/common/minder/TestCaseMinder.vue index dd468353d3..f2a7b6186f 100644 --- a/frontend/src/business/components/track/common/minder/TestCaseMinder.vue +++ b/frontend/src/business/components/track/common/minder/TestCaseMinder.vue @@ -27,7 +27,7 @@ import MsModuleMinder from "@/business/components/common/components/MsModuleMind import { getChildNodeId, handleAfterSave, - handleExpandToLevel, handleTestCaseAdd, handTestCaeEdit, isModuleNode, isModuleNodeData, + handleExpandToLevel, handleMinderIssueDelete, handleTestCaseAdd, handTestCaeEdit, isModuleNode, isModuleNodeData, listenBeforeExecCommand, listenDblclick, listenNodeSelected, loadSelectNodes, @@ -130,7 +130,10 @@ name: "TestCaseMinder", let level = Number.parseInt(even.commandArgs); handleExpandToLevel(level, even.minder.getRoot(), this.getParam(), getTestCasesForMinder); } - if (['priority', 'resource', 'removenode', 'appendchildnode', 'appendparentnode', 'appendsiblingnode'].indexOf(even.commandName) > 0) { + + if (handleMinderIssueDelete(even.commandName)) return; // 删除缺陷不算有编辑脑图信息 + + if (['priority', 'resource', 'removenode', 'appendchildnode', 'appendparentnode', 'appendsiblingnode'].indexOf(even.commandName) > -1) { // 这些情况则脑图有改变 this.setIsChange(true); } diff --git a/frontend/src/business/components/track/common/minder/TestPlanMinder.vue b/frontend/src/business/components/track/common/minder/TestPlanMinder.vue index 289e1149fa..c9cf5e1571 100644 --- a/frontend/src/business/components/track/common/minder/TestPlanMinder.vue +++ b/frontend/src/business/components/track/common/minder/TestPlanMinder.vue @@ -23,7 +23,7 @@ import MsModuleMinder from "@/business/components/common/components/MsModuleMinder"; import { handleExpandToLevel, listenBeforeExecCommand, listenNodeSelected, loadSelectNodes, - tagBatch, getSelectedNodeData, handleIssueAdd, handleIssueBatch, listenDblclick + tagBatch, getSelectedNodeData, handleIssueAdd, handleIssueBatch, listenDblclick, handleMinderIssueDelete } from "@/business/components/track/common/minder/minderUtils"; import {getPlanCasesForMinder} from "@/network/testCase"; import IssueRelateList from "@/business/components/track/case/components/IssueRelateList"; @@ -86,6 +86,9 @@ name: "TestPlanMinder", let level = Number.parseInt(even.commandArgs); handleExpandToLevel(level, even.minder.getRoot(), this.getParam(), getPlanCasesForMinder, this.setParamCallback); } + + if (handleMinderIssueDelete(even.commandName, true)) return; // 删除缺陷不算有编辑脑图信息 + }); listenDblclick(() => { @@ -173,6 +176,7 @@ name: "TestPlanMinder", }, refreshRelateIssue(issues) { handleIssueBatch(issues); + this.$success('关联成功'); } } } diff --git a/frontend/src/business/components/track/common/minder/minderUtils.js b/frontend/src/business/components/track/common/minder/minderUtils.js index c9fe53e308..8b302844d5 100644 --- a/frontend/src/business/components/track/common/minder/minderUtils.js +++ b/frontend/src/business/components/track/common/minder/minderUtils.js @@ -1,6 +1,7 @@ import i18n from "@/i18n/i18n"; import {getCurrentProjectID} from "../../../../../common/js/utils"; -import {warning} from "../../../../../common/js/message"; +import {success, warning} from "../../../../../common/js/message"; +import {deleteIssueRelate} from "@/network/Issue"; export function listenNodeSelected(callback) { let minder = window.minder; @@ -38,6 +39,10 @@ export function listenBeforeExecCommand(callback) { }); } +export function getSelectedNodes() { + return window.minder.getSelectedNodes(); +} + /** * 加载模块下的用例 * @param projectId @@ -111,6 +116,7 @@ export function handleTestCaseAdd(pid, data) { export function appendIssueChildNode(pNode, issue) { let data = getNodeData('缺陷ID:' + issue.num, null, true, 'issue'); data.id = issue.id; + data.allowDelete = true; appendChildNode(pNode, data); } @@ -517,3 +523,32 @@ export function addIssueHotBox(vueObj) { } }); } + +export function handleMinderIssueDelete(commandName, isPlan) { + if (commandName.toLocaleLowerCase() === 'removenode') { + let nodes = getSelectedNodes(); + if (nodes && nodes.length > 0) { + let isAllIssue = true; + let promises = []; + nodes.forEach(node => { + let data = node.data; + if (data.type === 'issue') { + let caseId = isPlan ? node.parent.data.caseId : node.parent.data.id + let p = new Promise((resolve) => { + deleteIssueRelate({id: data.id, caseId: caseId}, () => { + resolve(); + }); + }); + promises.push(p); + } else { + isAllIssue = false; + } + }); + Promise.all(promises).then(() => { + success('取消缺陷关联成功'); + }); + return isAllIssue; + } + } + return false; +} diff --git a/frontend/src/network/Issue.js b/frontend/src/network/Issue.js index ba82a8f14a..afa802d984 100644 --- a/frontend/src/network/Issue.js +++ b/frontend/src/network/Issue.js @@ -1,7 +1,7 @@ import {post, get} from "@/common/js/ajax"; import {getPageDate} from "@/common/js/tableUtils"; import {getCurrentProjectID, hasLicense} from "@/common/js/utils"; -import {baseGet} from "@/network/base-network"; +import {baseGet, basePost} from "@/network/base-network"; export function buildIssues(page) { let data = page.data; @@ -89,4 +89,6 @@ export function syncIssues(success) { }); } - +export function deleteIssueRelate(param, callback) { + return basePost('/issues/delete/relate', param, callback); +}