From d1998ec2f690f42f20fac5092e9266c68ff6a66b Mon Sep 17 00:00:00 2001 From: goodm2ice Date: Thu, 17 Mar 2022 18:05:50 +0500 Subject: [PATCH] =?UTF-8?q?=D0=9D=D0=B0=20=D0=93=D0=93=D0=94=20=D0=B4?= =?UTF-8?q?=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5=D0=BD=D0=B0=20=D0=BA=D0=BD?= =?UTF-8?q?=D0=BE=D0=BF=D0=BA=D0=B0=20=D1=8D=D0=BA=D1=81=D0=BF=D0=BE=D1=80?= =?UTF-8?q?=D1=82=D0=B0,=20IEB=20=D0=B8=D1=81=D0=BF=D1=80=D0=B0=D0=B2?= =?UTF-8?q?=D0=BB=D0=B5=D0=BD=D1=8B=20=D0=BA=D0=BE=D0=BB=D0=B1=D0=B5=D0=BA?= =?UTF-8?q?=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/WellOperations/ImportExportBar.jsx | 4 ++-- src/pages/WellOperations/Tvd.jsx | 19 +++++++++++++++++-- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/src/pages/WellOperations/ImportExportBar.jsx b/src/pages/WellOperations/ImportExportBar.jsx index 34fe7d8..4e44ff7 100644 --- a/src/pages/WellOperations/ImportExportBar.jsx +++ b/src/pages/WellOperations/ImportExportBar.jsx @@ -12,8 +12,8 @@ const style = { margin: 4 } export const ImportExportBar = memo(({ idWell, onImported, disabled }) => { const [isImportModalVisible, setIsImportModalVisible] = useState(false) - const downloadTemplate = async () => download(`/api/well/${idWell}/wellOperations/template`) - const downloadExport = async () => download(`/api/well/${idWell}/wellOperations/export`) + const downloadTemplate = async () => await download(`/api/well/${idWell}/wellOperations/template`) + const downloadExport = async () => await download(`/api/well/${idWell}/wellOperations/export`) const onDone = () => { setIsImportModalVisible(false) diff --git a/src/pages/WellOperations/Tvd.jsx b/src/pages/WellOperations/Tvd.jsx index 49279e4..ae54cb8 100644 --- a/src/pages/WellOperations/Tvd.jsx +++ b/src/pages/WellOperations/Tvd.jsx @@ -1,7 +1,7 @@ import { useHistory } from 'react-router-dom' import { memo, useState, useRef, useEffect, useCallback } from 'react' import { Switch, Button, InputNumber, Descriptions } from 'antd' -import { DoubleLeftOutlined, DoubleRightOutlined, FilterOutlined } from '@ant-design/icons' +import { DoubleLeftOutlined, DoubleRightOutlined, ExportOutlined, FilterOutlined } from '@ant-design/icons' import { Chart, @@ -17,7 +17,7 @@ import zoomPlugin from 'chartjs-plugin-zoom' import ChartDataLabels from 'chartjs-plugin-datalabels' import LoaderPortal from '@components/LoaderPortal' -import { invokeWebApiWrapperAsync } from '@components/factory' +import { download, invokeWebApiWrapperAsync } from '@components/factory' import { makeDateColumn, makeNumericColumn, makeTextColumn, Table } from '@components/Table' import { formatDate, fractionalSum } from '@utils/datetime' import { getOperations } from '@utils/functions' @@ -154,6 +154,7 @@ export const Tvd = memo(({ idWell, title }) => { const [operations, setOperations] = useState({}) const [isLoading, setIsLoading] = useState(false) const [isTableLoading, setIsTableLoading] = useState(false) + const [isFileExporting, setIsFileExporting] = useState(false) const [xLabel, setXLabel] = useState('day') const [chart, setChart] = useState() const [npt, setNPT] = useState([]) @@ -265,6 +266,14 @@ export const Tvd = memo(({ idWell, title }) => { setTableVisible((pre) => !pre) }, []) + const onExport = useCallback(() => invokeWebApiWrapperAsync( + async () => { + await download(`/api/well/${idWell}/wellOperations/scheduleReport`) + }, + setIsFileExporting, + 'Не удалось загрузить файл' + ), [idWell]) + return (
@@ -277,6 +286,12 @@ export const Tvd = memo(({ idWell, title }) => { onChange={(checked) => setXLabel(checked ? 'date' : 'day')} style={{ marginRight: '20px' }} /> +