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)); } }); },