From a89c5200d7d9c1835603056160f06a18d26bd80c Mon Sep 17 00:00:00 2001 From: KharchenkoVV Date: Mon, 7 Jun 2021 18:12:21 +0500 Subject: [PATCH] =?UTF-8?q?CF2-8:=20HotFix.=20=D0=98=D1=81=D0=BF=D1=80?= =?UTF-8?q?=D0=B0=D0=B2=D0=BB=D0=B5=D0=BD=D0=BE=20=D0=BF=D1=80=D0=B5=D0=BE?= =?UTF-8?q?=D0=B1=D1=80=D0=B0=D0=B7=D0=BE=D0=B2=D0=B0=D0=BD=D0=B8=D0=B5=20?= =?UTF-8?q?=D0=BF=D0=BE=D0=BB=D1=83=D1=87=D0=B5=D0=BD=D0=BD=D0=BE=D0=B3?= =?UTF-8?q?=D0=BE=20=D0=BC=D0=B0=D1=81=D1=81=D0=B8=D0=B2=D0=B0=20=D0=B1?= =?UTF-8?q?=D0=B0=D0=B9=D1=82=D0=BE=D0=B2=20=D0=B2=20=D1=84=D0=B0=D0=B9?= =?UTF-8?q?=D0=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/Report.jsx | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/pages/Report.jsx b/src/pages/Report.jsx index dd5d287..c97151e 100644 --- a/src/pages/Report.jsx +++ b/src/pages/Report.jsx @@ -37,6 +37,11 @@ const imgPaths = { '.las': '/images/las.png' } +const contentTypes = { + '.pdf': 'application/pdf', + '.las': 'application/octet-stream' +} + // Экспорт рендера export default function Report(props) { @@ -80,8 +85,8 @@ export default function Report(props) {
{ progressData.operation }
- {getReportFile(event, progressData.reportName)}} - download={progressData.reportName}> + getReportFile(event, progressData.reportName)} + download> { progressData.reportName } @@ -91,8 +96,9 @@ export default function Report(props) { const getReportFile = async (event, reportFileName) => { try { const element = event.target - let reportFile = await ReportService.getReport(wellId, reportFileName) - let reportUrl = URL.createObjectURL(reportFile) + let bytesArray = await ReportService.getReport(wellId, reportFileName) + const contentType = contentTypes[reportFileName.slice(-4)] + let reportUrl = URL.createObjectURL(new File(bytesArray, {type: contentType})) element.href = reportUrl } catch (error) { notify(`Не удалось скачать отчет по скважине (${wellId}) c @@ -120,7 +126,7 @@ export default function Report(props) { duration: 0 }); - if (progressData.reportName.length) + if (progressData.reportName?.length) unSubscribeReportHub() } }