На ГГД добавлена кнопка экспорта, IEB исправлены колбеки

This commit is contained in:
Александр Сироткин 2022-03-17 18:05:50 +05:00
parent a55d0c9b42
commit d1998ec2f6
2 changed files with 19 additions and 4 deletions

View File

@ -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)

View File

@ -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 (
<div className={'container tvd-page'}>
<div className={'tvd-top'}>
@ -277,6 +286,12 @@ export const Tvd = memo(({ idWell, title }) => {
onChange={(checked) => setXLabel(checked ? 'date' : 'day')}
style={{ marginRight: '20px' }}
/>
<Button
icon={<ExportOutlined />}
loading={isFileExporting}
onClick={onExport}
style={{ marginRight: '5px' }}
>Экспорт</Button>
<Button
icon={tableVisible ? <DoubleLeftOutlined /> : <DoubleRightOutlined />}
onClick={toogleTable}