From d81cb28bfbada8dfacd7b85fa6dcd1800fdc24c9 Mon Sep 17 00:00:00 2001 From: song-tianyang Date: Fri, 2 Jul 2021 14:18:51 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E6=8E=A5=E5=8F=A3=E5=AE=9A=E4=B9=89?= =?UTF-8?q?=E3=80=81=E6=8E=A5=E5=8F=A3=E8=87=AA=E5=8A=A8=E5=8C=96):=20?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=8E=A5=E5=8F=A3=E5=AE=9A=E4=B9=89=E3=80=81?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3=E8=87=AA=E5=8A=A8=E5=8C=96=E5=AF=BC=E5=87=BA?= =?UTF-8?q?=E6=96=87=E4=BB=B6=E4=B8=AD=E9=A1=B9=E7=9B=AE=E5=90=8D=E4=B8=BA?= =?UTF-8?q?null=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 修复接口定义、接口自动化导出文件中项目名为null的问题 --- .../api/automation/scenario/ApiScenarioList.vue | 14 +++++++++++++- .../api/definition/components/list/ApiList.vue | 16 ++++++++++++++-- 2 files changed, 27 insertions(+), 3 deletions(-) diff --git a/frontend/src/business/components/api/automation/scenario/ApiScenarioList.vue b/frontend/src/business/components/api/automation/scenario/ApiScenarioList.vue index 165370c2a8..6fad8a3747 100644 --- a/frontend/src/business/components/api/automation/scenario/ApiScenarioList.vue +++ b/frontend/src/business/components/api/automation/scenario/ApiScenarioList.vue @@ -286,6 +286,7 @@ export default { }, data() { return { + projectName:"", result: {}, tableHeaderKey:"API_SCENARIO", type: API_SCENARIO_LIST, @@ -436,6 +437,9 @@ export default { }; }, created() { + if(!this.projectName || this.projectName === ""){ + this.getProjectName(); + } this.operators = this.unTrashOperators; this.buttons = this.unTrashButtons; this.condition.filters = {status: ["Prepare", "Underway", "Completed"]}; @@ -481,6 +485,14 @@ export default { }, }, methods: { + getProjectName (){ + this.$get('project/get/' + this.projectId, response => { + let project = response.data; + if(project){ + this.projectName = project.name; + } + }); + }, selectByParam() { this.changeSelectDataRangeAll(); this.search(); @@ -811,7 +823,7 @@ export default { this.result.loading = false; let obj = response.data; this.buildApiPath(obj.data); - downloadFile("Metersphere_Scenario_" + localStorage.getItem(PROJECT_NAME) + ".json", JSON.stringify(obj)); + downloadFile("Metersphere_Scenario_" + this.projectName + ".json", JSON.stringify(obj)); }); }, exportJmx() { diff --git a/frontend/src/business/components/api/definition/components/list/ApiList.vue b/frontend/src/business/components/api/definition/components/list/ApiList.vue index f0856aa02b..bf083e9639 100644 --- a/frontend/src/business/components/api/definition/components/list/ApiList.vue +++ b/frontend/src/business/components/api/definition/components/list/ApiList.vue @@ -361,6 +361,7 @@ export default { screenHeight: 'calc(100vh - 250px)',//屏幕高度, environmentId: undefined, selectDataCounts: 0, + projectName:"", }; }, props: { @@ -411,6 +412,9 @@ export default { } }, created: function () { + if(!this.projectName || this.projectName === ""){ + this.getProjectName(); + } if (this.trashEnable) { this.tableOperatorButtons = this.tableTrashOperatorButtons; this.condition.filters = {status: ["Trash"]}; @@ -455,6 +459,14 @@ export default { } }, methods: { + getProjectName (){ + this.$get('project/get/' + this.projectId, response => { + let project = response.data; + if(project){ + this.projectName = project.name; + } + }); + }, handleBatchMove() { this.$refs.testCaseBatchMove.open(this.moduleTree, [], this.moduleOptions); }, @@ -773,9 +785,9 @@ export default { if (type == 'MS') { obj.protocol = this.currentProtocol; this.buildApiPath(obj.data); - downloadFile("Metersphere_Api_" + localStorage.getItem(PROJECT_NAME) + ".json", JSON.stringify(obj)); + downloadFile("Metersphere_Api_" + this.projectName + ".json", JSON.stringify(obj)); } else { - downloadFile("Swagger_Api_" + localStorage.getItem(PROJECT_NAME) + ".json", JSON.stringify(obj)); + downloadFile("Swagger_Api_" + this.projectName+ ".json", JSON.stringify(obj)); } }); },