From 027d450fbf82cac338e3af2b97fc5d5c7e426c63 Mon Sep 17 00:00:00 2001 From: cpf <1105965053@qq.com> Date: Thu, 2 Jun 2022 11:36:59 +0800 Subject: [PATCH] =?UTF-8?q?=E6=95=B0=E5=AD=97=E6=B2=B9=E7=AB=99=E5=AF=BC?= =?UTF-8?q?=E5=87=BA=E5=9F=BA=E6=9C=AC=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../left-domain/left-domain.component.html | 2 +- .../left-domain/left-domain.component.ts | 26 ++++++++++++++++--- 2 files changed, 23 insertions(+), 5 deletions(-) diff --git a/src/app/pages/left-domain/left-domain.component.html b/src/app/pages/left-domain/left-domain.component.html index 80a3e8a..0b71f22 100644 --- a/src/app/pages/left-domain/left-domain.component.html +++ b/src/app/pages/left-domain/left-domain.component.html @@ -298,7 +298,7 @@
- +
diff --git a/src/app/pages/left-domain/left-domain.component.ts b/src/app/pages/left-domain/left-domain.component.ts index 6aa4a68..224006b 100644 --- a/src/app/pages/left-domain/left-domain.component.ts +++ b/src/app/pages/left-domain/left-domain.component.ts @@ -509,10 +509,28 @@ export class LeftDomainComponent implements OnInit { //导出Excel deriveExcel() { - this.originalData = sessionStorage.getItem('userdata') - let userdata = { organization: PlanComponent.instance.companyData, hideCloseBtn: true } - sessionStorage.setItem('userdata', JSON.stringify(userdata)) - this.isShowBaseDialog = true + // this.originalData = sessionStorage.getItem('userdata') + // let userdata = { organization: PlanComponent.instance.companyData, hideCloseBtn: true } + // sessionStorage.setItem('userdata', JSON.stringify(userdata)) + // this.isShowBaseDialog = true + let threeData = JSON.parse(sessionStorage.getItem('3dSceneData')); + const httpOptions = { + responseType: 'blob' as 'json' + }; + this.http.get(`/api/services/app/GasStation/ExportExcelFile?gasStationId=${threeData.id}`, httpOptions).subscribe((data: any) => { + // 文件名中有中文 则对文件名进行转码 + const link = document.createElement('a'); + const blob = new Blob([data], { type: 'application/vnd.ms-excel' }); + link.setAttribute('href', window.URL.createObjectURL(blob)); + link.setAttribute('download', threeData.stationName + '基本信息' + '.xls'); + link.style.visibility = 'hidden'; + document.body.appendChild(link); + link.click(); + document.body.removeChild(link); + this.message.create('success', '导出成功!'); + }, err => { + this.message.create('error', '导出失败!'); + }) } //关闭 编辑信息/导出Excel 弹窗