diff --git a/frontend/src/business/components/api/automation/ApiAutomation.vue b/frontend/src/business/components/api/automation/ApiAutomation.vue index 11dc10b0f9..556fa95b77 100644 --- a/frontend/src/business/components/api/automation/ApiAutomation.vue +++ b/frontend/src/business/components/api/automation/ApiAutomation.vue @@ -190,7 +190,7 @@ this.activeName = name; let currentScenario = { status: "Underway", principal: getCurrentUser().id, - apiScenarioModuleId: "root", id: getUUID(), + apiScenarioModuleId: "default-module", id: getUUID(), modulePath: "/" + this.$t("commons.module_title") }; if (this.nodeTree && this.nodeTree.length > 0) { diff --git a/frontend/src/business/components/api/automation/scenario/AddBasisScenario.vue b/frontend/src/business/components/api/automation/scenario/AddBasisScenario.vue index ae28794b28..43a3b5d57b 100644 --- a/frontend/src/business/components/api/automation/scenario/AddBasisScenario.vue +++ b/frontend/src/business/components/api/automation/scenario/AddBasisScenario.vue @@ -117,6 +117,9 @@ if (this.currentModule && this.currentModule.id != "root") { this.scenarioForm.modulePath = this.currentModule.method !== undefined ? this.currentModule.method : null; this.scenarioForm.apiScenarioModuleId = this.currentModule.id; + }else{ + this.scenarioForm.modulePath = this.$t("commons.module_title"); + this.scenarioForm.apiScenarioModuleId = "default-module"; } }, getMaintainerOptions() { diff --git a/frontend/src/business/components/api/automation/scenario/ApiScenarioModule.vue b/frontend/src/business/components/api/automation/scenario/ApiScenarioModule.vue index fc3266b5bc..eeec636123 100644 --- a/frontend/src/business/components/api/automation/scenario/ApiScenarioModule.vue +++ b/frontend/src/business/components/api/automation/scenario/ApiScenarioModule.vue @@ -29,7 +29,7 @@ @refresh="refresh" ref="basisScenario"/> - + @@ -82,9 +82,7 @@ trashEnable: false }, data: [], - extendTreeNodes: [], currentModule: undefined, - moduleOptions: [], operators: [ { label: this.$t('api_test.automation.add_scenario'), @@ -141,11 +139,16 @@ this.result = this.$get("/api/automation/module/list/" + this.projectId, response => { if (response.data != undefined && response.data != null) { this.data = response.data; - let moduleOptions = []; - this.data.forEach(node => { - buildNodePath(node, {path: ''}, moduleOptions); + this.data.unshift({ + "id": "default-module", + "name": this.$t('commons.module_title'), + "level": 0, + "path": "/" + this.$t('commons.module_title'), + "children": [], + }); + this.data.forEach(node => { + buildTree(node, {path: ''}); }); - this.moduleOptions = moduleOptions } }); this.$refs.apiImport.open(this.currentModule); @@ -163,11 +166,16 @@ this.result = this.$get("/api/automation/module/list/" + this.projectId, response => { if (response.data != undefined && response.data != null) { this.data = response.data; - let moduleOptions = []; - this.data.forEach(node => { - buildNodePath(node, {path: ''}, moduleOptions); + this.data.unshift({ + "id": "default-module", + "name": this.$t('commons.module_title'), + "level": 0, + "path": "/" + this.$t('commons.module_title'), + "children": [], + }); + this.data.forEach(node => { + buildTree(node, {path: ''}); }); - this.moduleOptions = moduleOptions } }); this.$refs.apiImport.open(this.currentModule); @@ -188,17 +196,17 @@ this.result = this.$get(url, response => { if (response.data != undefined && response.data != null) { this.data = response.data; - this.extendTreeNodes = []; - this.extendTreeNodes.unshift({ - "id": "root", + this.data.unshift({ + "id": "default-module", "name": this.$t('commons.module_title'), "level": 0, - "children": this.data, + "path": "/" + this.$t('commons.module_title'), + "children": [], }); - this.extendTreeNodes.forEach(node => { + this.data.forEach(node => { buildTree(node, {path: ''}); }); - this.$emit('setModuleOptions', this.extendTreeNodes); + this.$emit('setModuleOptions', this.data); this.$emit('setNodeTree', this.data); if (this.$refs.nodeTree) { this.$refs.nodeTree.filter(this.condition.filterText); diff --git a/frontend/src/business/components/api/automation/scenario/api/AddBasisApi.vue b/frontend/src/business/components/api/automation/scenario/api/AddBasisApi.vue index 31f10c7792..0189f7db60 100644 --- a/frontend/src/business/components/api/automation/scenario/api/AddBasisApi.vue +++ b/frontend/src/business/components/api/automation/scenario/api/AddBasisApi.vue @@ -84,7 +84,7 @@ callback(); }; return { - httpForm: {environmentId: "", moduleId: "root"}, + httpForm: {environmentId: "", moduleId: "default-module"}, moduleOptions: [], httpVisible: false, currentModule: {}, @@ -251,13 +251,13 @@ let url = "/api/module/list/" + getCurrentProjectID() + "/" + data.protocol; this.result = this.$get(url, response => { if (response.data != undefined && response.data != null) { - let data = response.data; - this.moduleOptions = []; + this.moduleOptions = response.data; this.moduleOptions.unshift({ - "id": "root", + "id": "default-module", "name": this.$t('commons.module_title'), "level": 0, - "children": data, + "path": "/" + this.$t('commons.module_title'), + "children": [], }); this.moduleOptions.forEach(node => { buildTree(node, {path: ''}); @@ -282,7 +282,7 @@ data.protocol = "DUBBO"; } data.id = getUUID(); - this.httpForm = {id: data.id, name: data.name, protocol: data.protocol, path: data.path, method: api.method, userId: getCurrentUser().id, request: data, moduleId: "root"}; + this.httpForm = {id: data.id, name: data.name, protocol: data.protocol, path: data.path, method: api.method, userId: getCurrentUser().id, request: data, moduleId: "default-module"}; this.getMaintainerOptions(); this.list(data); this.httpVisible = true; diff --git a/frontend/src/business/components/api/automation/scenario/common/ApiBaseComponent.vue b/frontend/src/business/components/api/automation/scenario/common/ApiBaseComponent.vue index 2cff5e9ca6..706f6e2cb3 100644 --- a/frontend/src/business/components/api/automation/scenario/common/ApiBaseComponent.vue +++ b/frontend/src/business/components/api/automation/scenario/common/ApiBaseComponent.vue @@ -32,7 +32,7 @@ - + diff --git a/frontend/src/business/components/api/definition/components/basis/AddBasisApi.vue b/frontend/src/business/components/api/definition/components/basis/AddBasisApi.vue index 7bd6e6124a..055a927db7 100644 --- a/frontend/src/business/components/api/definition/components/basis/AddBasisApi.vue +++ b/frontend/src/business/components/api/definition/components/basis/AddBasisApi.vue @@ -154,6 +154,9 @@ if (this.currentModule != null) { this.httpForm.modulePath = this.currentModule.method != undefined ? this.currentModule.method : null; this.httpForm.moduleId = this.currentModule.id; + } else { + this.httpForm.modulePath = this.$t("commons.module_title"); + this.httpForm.moduleId = "default-module"; } }, diff --git a/frontend/src/business/components/track/case/components/TestCaseCreate.vue b/frontend/src/business/components/track/case/components/TestCaseCreate.vue index 98d5bbec1e..31b6d3d606 100644 --- a/frontend/src/business/components/track/case/components/TestCaseCreate.vue +++ b/frontend/src/business/components/track/case/components/TestCaseCreate.vue @@ -114,8 +114,8 @@ export default { this.testCaseForm.nodePath = this.currentModule.path; this.testCaseForm.nodeId = this.currentModule.id; } else { - this.testCaseForm.nodePath = "/全部用例" - this.testCaseForm.nodeId = "root" + this.testCaseForm.nodePath = "/默认模块" + this.testCaseForm.nodeId = "default-module" } this.result = this.$post(path, this.testCaseForm, response => { this.testCaseForm.id = response.data.id diff --git a/frontend/src/business/components/track/case/components/TestCaseEdit.vue b/frontend/src/business/components/track/case/components/TestCaseEdit.vue index 5ed25a3951..03571723a0 100644 --- a/frontend/src/business/components/track/case/components/TestCaseEdit.vue +++ b/frontend/src/business/components/track/case/components/TestCaseEdit.vue @@ -35,7 +35,7 @@ - @@ -314,7 +314,7 @@ export default { dialogFormVisible: false, form: { name: '', - module: 'root', + module: 'default-module', nodePath:'', maintainer: getCurrentUser().id, priority: 'P0', @@ -416,10 +416,6 @@ export default { }; }); }, 1000); - if(this.selectNode && this.selectNode.data){ - this.form.module = this.selectNode.data.id; - this.form.nodePath = this.selectNode.data.path; - } }, watch: { treeNodes() { @@ -432,7 +428,14 @@ export default { created() { this.loadOptions(); this.addListener(); // 添加 ctrl s 监听 - + if(this.selectNode && this.selectNode.data && this.form.id){ + this.form.module = this.selectNode.data.id; + this.form.nodePath = this.selectNode.data.path; + } + if (this.type === 'edit' || this.type === 'copy') { + this.form.module = this.currentTestCaseInfo.nodeId; + this.form.nodePath = this.currentTestCaseInfo.nodePath; + } }, methods: { setModule(id,data) { @@ -836,16 +839,11 @@ export default { this.getTestOptions() }, getModuleOptions() { - this.moduleOptions = []; - this.moduleOptions.unshift({ - "id": "root", - "name": this.$t('commons.module_title'), - "level": 0, - "children": this.treeNodes, - }); - this.moduleOptions.forEach(node => { - buildTree(node, {path: ''}); + let moduleOptions = []; + this.treeNodes.forEach(node => { + buildNodePath(node, {path: ''}, moduleOptions); }); + this.moduleOptions = moduleOptions; }, getMaintainerOptions() { let workspaceId = localStorage.getItem(WORKSPACE_ID); diff --git a/frontend/src/business/components/track/common/NodeTree.vue b/frontend/src/business/components/track/common/NodeTree.vue index 80a9ea0aba..4792327081 100644 --- a/frontend/src/business/components/track/common/NodeTree.vue +++ b/frontend/src/business/components/track/common/NodeTree.vue @@ -32,7 +32,7 @@ { this.treeNodes = response.data; + this.treeNodes.unshift({ + "id": "default-module", + "name": this.$t('commons.module_title'), + "level": 0, + "path": "/" + this.$t('commons.module_title'), + "children": [], + }); + this.treeNodes.forEach(node => { + buildTree(node, {path: ''}); + }); if (this.$refs.nodeTree) { this.$refs.nodeTree.filter(); }