fix(测试跟踪): 选中模块创建用例,保存后显示的未规划模块

--bug=1023998 --user=陈建星 【测试跟踪】github#22413,无法在新的模块下新增功能用例 https://www.tapd.cn/55049933/s/1346501
This commit is contained in:
chenjianxing 2023-03-07 19:55:13 +08:00 committed by jianxing
parent d68ac65a25
commit c7a444f389
2 changed files with 47 additions and 48 deletions

View File

@ -607,9 +607,6 @@ export default {
routeProjectId() {
return this.$route.query.projectId;
},
moduleOptions() {
return store.testCaseModuleOptions;
},
isCustomNum() {
return store.currentProjectIsCustomNum;
},
@ -802,8 +799,11 @@ export default {
this.treeNodes.forEach(node => {
node.name = node.name === '未规划用例' ? this.$t('api_test.unplanned_case') : node.name
buildTree(node, {path: ''});
this.setNodeModule();
});
if (!this.caseId) {
// ID
this.setDefaultModule();
}
});
}
@ -903,19 +903,6 @@ export default {
"TRACK_TEST_CASE",
]);
},
setNodeModule() {
if (this.caseId) {
this.form.module = this.currentTestCaseInfo.nodeId;
this.form.nodePath = this.currentTestCaseInfo.nodePath;
}
if ((!this.form.module ||
this.form.module === "default-module" ||
this.form.module === "root")
&& this.treeNodes.length > 0) {
this.form.module = this.treeNodes[0].id;
this.form.nodePath = this.treeNodes[0].path;
}
},
setDefaultValue() {
if (!this.form.prerequisite) {
this.form.prerequisite = "";
@ -1022,9 +1009,7 @@ export default {
// add
document.title = this.$t('test_track.case.create_case');
if (this.moduleOptions.length > 0) {
this.form.module = this.moduleOptions[0].id;
}
let user = JSON.parse(localStorage.getItem(TokenKey));
this.form.priority = "P3";
this.form.type = "functional";
@ -1045,6 +1030,11 @@ export default {
callback();
}
},
setDefaultModule() {
if (this.$refs.testCaseBaseInfo) {
this.$refs.testCaseBaseInfo.doSetDefaultModule(this.treeNodes);
}
},
async checkCurrentProject() {
if (this.isPublicShow) {
//
@ -1154,7 +1144,10 @@ export default {
this.form.stepModel = "STEP";
}
this.casePublic = tmp.casePublic;
this.form.module = testCase.nodeId;
this.$refs.testCaseBaseInfo.setDefaultModule();
//
this.customFieldForm = parseCustomField(
this.form,

View File

@ -8,7 +8,7 @@
<div class="name title-wrap">ID</div>
<div class="required required-item"></div>
</div>
<div class="side-content">
<div class="side-content">
<base-edit-item-component
:editable="editable"
:auto-save="!readOnly"
@ -113,14 +113,15 @@
<ms-select-tree
:disabled="readOnly"
:data="treeNodes"
:defaultKey="defaultModuleKey"
:obj="moduleObj"
@getValue="(id, data) => setModule(id, data)"
:default-key="defaultModuleKey"
@getValue="setModule"
clearable
checkStrictly
size="small"
@selectClick="onClick"
@clean="onClick"
ref="moduleTree"
/>
</el-form-item>
</div>
@ -447,6 +448,7 @@ export default {
demandOptions: [],
versionFilters: [],
demandList: [],
defaultModuleKey: ''
};
},
props: {
@ -471,36 +473,38 @@ export default {
isCustomNum() {
return useStore().currentProjectIsCustomNum;
},
defaultModuleKey() {
if (this.editable && !this.editableState) {
let defaultNodeKey = '';
if (this.$route.query.createNodeId) {
defaultNodeKey = this.$route.query.createNodeId;
} else {
this.treeNodes.forEach(node => {
if (node.label === '未规划用例') {
defaultNodeKey = node.id;
this.form.module = defaultNodeKey;
this.form.nodePath = node.path;
}
})
}
return defaultNodeKey;
} else {
return this.form.module
}
createNodeId() {
return this.$route.query.createNodeId;
}
},
mounted() {
this.getDemandOptions();
this.getVersionOptions();
if (this.$route.query.createNodeId) {
this.form.module = this.$route.query.createNodeId;
let node = this.findTreeNode(this.treeNodes);
this.form.nodePath = node.path;
}
},
methods: {
setDefaultModule() {
this.doSetDefaultModule(this.treeNodes);
},
doSetDefaultModule(treeNodes) {
if (treeNodes && treeNodes.length > 0) {
if (this.createNodeId) {
//
this.form.module = this.createNodeId;
let node = this.findTreeNode(treeNodes);
this.form.nodePath = node.path;
} else if (this.form.module) {
// nodePath
let node = this.findTreeNode(treeNodes);
this.form.nodePath = node ? node.path : '';
} else {
// ID
this.form.module = treeNodes[0].id;
this.form.nodePath = treeNodes[0].path;
}
this.defaultModuleKey = this.form.module;
this.$refs.moduleTree.setData(this.form.module);
}
},
handleDemandOptionPlatform(data){
if(data.platform){
return data.platform
@ -586,8 +590,10 @@ export default {
}
},
setModule(id, data) {
this.form.module = id;
this.form.nodePath = data.path;
if (data) {
this.form.module = id;
this.form.nodePath = data.path;
}
},
mouseLeaveEvent(refName) {
if (!this.editable && this.$refs[refName]) {