Исправлено скачивание программы бурения

Исправлена работа спиннера выгрузки файла
This commit is contained in:
Александр Сироткин 2022-02-25 18:02:41 +05:00
parent e84cc40f09
commit 9ee3e89bd1
2 changed files with 21 additions and 4 deletions

View File

@ -74,6 +74,16 @@ export const CategoryRender = memo(({ idWell, partData, onUpdate, onEdit, onHist
`Удаление категории "${title}" скважины "${idWell}"`
), [idWell, idFileCategory, onUpdate, title])
const onUploadComplete = useCallback(() => {
onUpdate?.(idFileCategory)
setIsUploading(false)
}, [onUpdate, idFileCategory])
const onUploadError = useCallback((e) => {
notify(e?.message ?? 'Ошибка загрузки файла', 'error')
setIsUploading(false)
})
return (
<LoaderPortal show={isUploading}>
<div className={'drilling_category'} {...other}>
@ -111,8 +121,8 @@ export const CategoryRender = memo(({ idWell, partData, onUpdate, onEdit, onHist
url={uploadUrl}
style={{ margin: '5px 0 10px 0' }}
onUploadStart={() => setIsUploading(true)}
onUploadComplete={() => onUpdate?.(idFileCategory)}
onUploadError={(e) => notify(e?.message ?? 'Ошибка загрузки файла', 'error')}
onUploadComplete={onUploadComplete}
onUploadError={onUploadError}
/>
)}
<Button

View File

@ -10,7 +10,7 @@ import {
import { memo, useCallback, useEffect, useState } from 'react'
import LoaderPortal from '@components/LoaderPortal'
import { invokeWebApiWrapperAsync } from '@components/factory'
import { downloadFile, invokeWebApiWrapperAsync } from '@components/factory'
import { arrayOrDefault, formatDate } from '@utils'
import { DrillingProgramService } from '@api'
@ -109,7 +109,14 @@ export const DrillingProgram = memo(({ idWell }) => {
<div className={'program_content'}>
{stateId === idStateReady ? (
<>
<Button type={'link'} icon={<FileWordOutlined />} style={{ marginLeft: '10px' }}>{program?.name}</Button>
<Button
type={'link'}
icon={<FileWordOutlined />}
style={{ marginLeft: '10px' }}
onClick={() => downloadFile(program)}
>
{program?.name}
</Button>
<div className={'m-10'}>Размер: {program?.size}</div>
<div className={'m-10'}>Загружен: {formatDate(program?.uploadDate)}</div>
</>