fix(测试跟踪): 测试计划和评审同时选中模块用例和步骤添加标签时,标签显示重叠

--bug=1025886 --user=陈建星 【测试跟踪】脑图评审框选到用例步骤点击通过/不通过会将步骤打上用例标签 https://www.tapd.cn/55049933/s/1369897
This commit is contained in:
chenjianxing 2023-05-08 16:34:35 +08:00 committed by jianxing
parent d315868c0c
commit d06b05b152
4 changed files with 110 additions and 27 deletions

View File

@ -59,7 +59,7 @@
"vue-float-action-button": "^0.6.6", "vue-float-action-button": "^0.6.6",
"vue-i18n": "^8.15.3", "vue-i18n": "^8.15.3",
"vue-jsonpath-picker": "^1.1.5", "vue-jsonpath-picker": "^1.1.5",
"vue-minder-editor-plus": "1.1.2", "vue-minder-editor-plus": "1.1.7",
"vue-papa-parse": "^2.0.0", "vue-papa-parse": "^2.0.0",
"vue-router": "^3.1.3", "vue-router": "^3.1.3",
"vue-virtual-scroll-list": "^2.3.3", "vue-virtual-scroll-list": "^2.3.3",

View File

@ -9,7 +9,7 @@
:tag-enable="true" :tag-enable="true"
:disabled="disableMinder" :disabled="disableMinder"
:select-node="selectNode" :select-node="selectNode"
:distinct-tags="[...tags, this.$t('test_track.plan.plan_status_prepare')]" :distinct-tags="distinctTags"
:ignore-num="true" :ignore-num="true"
@afterMount="handleAfterMount" @afterMount="handleAfterMount"
@save="save" @save="save"
@ -37,8 +37,17 @@
import {setPriorityView} from "vue-minder-editor-plus/src/script/tool/utils"; import {setPriorityView} from "vue-minder-editor-plus/src/script/tool/utils";
import { import {
handleExpandToLevel, listenBeforeExecCommand, listenNodeSelected, loadSelectNodes, handleExpandToLevel,
tagBatch, getSelectedNodeData, handleIssueAdd, handleIssueBatch, listenDblclick, handleMinderIssueDelete listenBeforeExecCommand,
listenNodeSelected,
loadSelectNodes,
tagBatch,
getSelectedNodeData,
handleIssueAdd,
handleIssueBatch,
listenDblclick,
handleMinderIssueDelete,
saveTagBeforeBatchTag, clearOtherTagAfterBatchTag
} from "@/business/common/minder/minderUtils"; } from "@/business/common/minder/minderUtils";
import {getPlanCasesForMinder} from "@/api/testCase"; import {getPlanCasesForMinder} from "@/api/testCase";
import IssueRelateList from "@/business/case/components/IssueRelateList"; import IssueRelateList from "@/business/case/components/IssueRelateList";
@ -92,6 +101,9 @@ export default {
} else { } else {
return false return false
} }
},
distinctTags() {
return [...this.tags, this.$t('test_track.plan.plan_status_prepare')];
} }
}, },
mounted() { mounted() {
@ -127,8 +139,14 @@ export default {
if (handleMinderIssueDelete(even.commandName, true)) return; // if (handleMinderIssueDelete(even.commandName, true)) return; //
if (even.commandName.toLocaleLowerCase() === 'resource') { if (even.commandName.toLocaleLowerCase() === 'resource') {
saveTagBeforeBatchTag();
// afterExecCommand setTimeout
setTimeout(() => {
clearOtherTagAfterBatchTag(this.tags, this.distinctTags);
// //
setTimeout(() => setPriorityView(true, 'P'), 100); setPriorityView(true, 'P');
}, 100);
this.setIsChange(true); this.setIsChange(true);
} }
}); });
@ -144,7 +162,7 @@ export default {
} }
}); });
tagBatch([...this.tags, this.$t('test_track.plan.plan_status_prepare')], { tagBatch(this.distinctTags, {
param: this.getParam(), param: this.getParam(),
getCaseFuc: getPlanCasesForMinder, getCaseFuc: getPlanCasesForMinder,
setParamCallback: this.setParamCallback setParamCallback: this.setParamCallback

View File

@ -18,10 +18,11 @@
<script> <script>
import { import {
clearOtherTagAfterBatchTag,
handleExpandToLevel, handleExpandToLevel,
listenBeforeExecCommand, listenBeforeExecCommand,
listenNodeSelected, listenNodeSelected,
loadSelectNodes, loadSelectNodes, saveTagBeforeBatchTag,
tagBatch tagBatch
} from "@/business/common/minder/minderUtils"; } from "@/business/common/minder/minderUtils";
import {getReviewCasesForMinder} from "@/api/testCase"; import {getReviewCasesForMinder} from "@/api/testCase";
@ -31,6 +32,7 @@ import {useStore} from "@/store";
import {mapState} from "pinia"; import {mapState} from "pinia";
import {testReviewCaseMinderEdit} from "@/api/remote/plan/test-review-case"; import {testReviewCaseMinderEdit} from "@/api/remote/plan/test-review-case";
import {hasPermission} from "@/business/utils/sdk-utils"; import {hasPermission} from "@/business/utils/sdk-utils";
import i18n from "@/i18n";
export default { export default {
name: "TestReviewMinder", name: "TestReviewMinder",
@ -99,11 +101,17 @@ export default {
} }
if (even.commandName.toLocaleLowerCase() === 'resource') { if (even.commandName.toLocaleLowerCase() === 'resource') {
saveTagBeforeBatchTag();
// afterExecCommand setTimeout
setTimeout(() => {
clearOtherTagAfterBatchTag(this.tags, this.distinctTags);
// //
setTimeout(() => setPriorityView(true, 'P'), 100); setPriorityView(true, 'P');
}, 100);
this.setIsChange(true); this.setIsChange(true);
} }
}); });
tagBatch(this.distinctTags, { tagBatch(this.distinctTags, {
param: this.getParam(), param: this.getParam(),
getCaseFuc: getReviewCasesForMinder, getCaseFuc: getReviewCasesForMinder,

View File

@ -202,7 +202,24 @@ export async function tagChildren(node, resourceName, distinctTags, loadNodePara
for (const item of children) { for (const item of children) {
let isCaseNode = item.data.resource && item.data.resource.indexOf(i18n.t('api_test.definition.request.case')) > -1; let isCaseNode = item.data.resource && item.data.resource.indexOf(i18n.t('api_test.definition.request.case')) > -1;
if (item.data.type === 'node' || isCaseNode) { if (item.data.type === 'node' || isCaseNode) {
let origin = item.data.resource; item.data.resource = getResourceAfterDistinct(item.data.resource, resourceName, distinctTags);
if (isCaseNode) {
item.data.changed = true;
}
await tagChildren(item, resourceName, distinctTags, loadNodeParam);
}
}
return;
}
/**
* 打标签并去掉互斥的标签
* @param origin
* @param resourceName
* @param distinctTags
* @returns {*[]}
*/
function getResourceAfterDistinct(origin, resourceName, distinctTags) {
if (!origin) { if (!origin) {
origin = []; origin = [];
} }
@ -218,17 +235,9 @@ export async function tagChildren(node, resourceName, distinctTags, loadNodePara
if (origin.indexOf(resourceName) < 0) { if (origin.indexOf(resourceName) < 0) {
origin.push(resourceName); origin.push(resourceName);
} }
item.data.resource = origin; return origin;
if (isCaseNode) {
item.data.changed = true;
}
await tagChildren(item, resourceName, distinctTags, loadNodeParam);
}
}
return;
} }
function modifyParentNodeTag(node, resourceName) { function modifyParentNodeTag(node, resourceName) {
let topNode = null; let topNode = null;
while (node.parent) { while (node.parent) {
@ -733,3 +742,51 @@ export function saveMinderConfirm(vueObj, isSave) {
} }
}); });
} }
/**
* 解决测试计划和评审选中多个节点批量打标签时显示所有标签的问题
* @param tags
* @param distinctTags
*/
export function clearOtherTagAfterBatchTag(tags, distinctTags) {
let selectNodes = minder.getSelectedNodes();
if (selectNodes.length <= 1) {
// 批量才处理
return;
}
selectNodes.forEach(node => {
if (!isModuleNode(node) && node.data.type !== 'case') {
// 如果不是模块和用例,直接重置标签
if (node.data.originResource) {
node.data.resource = node.data.originResource;
node.render();
}
} else {
let newResource = node.data.resource;
if (newResource) {
// 先重置标签,再重新打标签
node.data.resource = node.data.originResource;
let addResource = newResource.filter(item => tags.indexOf(item) > -1);
addResource.forEach((resourceName) => {
getResourceAfterDistinct(node.data.resource, resourceName, distinctTags);
});
node.render();
}
}
});
minder.layout(200);
}
/**
* 记录当前的标签
*/
export function saveTagBeforeBatchTag() {
let selectNodes = minder.getSelectedNodes();
if (selectNodes.length <= 1) {
// 批量才处理
return;
}
selectNodes.forEach(node => {
node.data.originResource = node.data.resource;
});
}