diff --git a/src/pages/Documents/DocumentsTemplate.jsx b/src/pages/Documents/DocumentsTemplate.jsx index 4a998a1..4656628 100644 --- a/src/pages/Documents/DocumentsTemplate.jsx +++ b/src/pages/Documents/DocumentsTemplate.jsx @@ -17,7 +17,7 @@ const pageSize = 12 const { RangePicker } = DatePicker const { Search } = Input -export default function DocumentsTemplate({ idCategory, idWell, accept }) { +export default function DocumentsTemplate({ idCategory, idWell, accept, onChange }) { const [page, setPage] = useState(1) const [filterDataRange, setFilterDataRange] = useState([]) const [filterCompanyName, setFilterCompanyName] = useState([]) @@ -116,9 +116,7 @@ export default function DocumentsTemplate({ idCategory, idWell, accept }) { return const filesInfos = paginatedFiles.items??[] - setFiles(filesInfos) - const newPagination = makePaginationObject(paginatedFiles) setPagination(newPagination) }, @@ -128,6 +126,10 @@ export default function DocumentsTemplate({ idCategory, idWell, accept }) { } useEffect(update, [idWell, idCategory, page, filterDataRange, filterCompanyName, filterFileName]) + useEffect(()=>{ + if(onChange) + onChange(files) + }, [files, onChange]) const companies = [...new Set(files.map(file=>file.company))] .filter(company=>company) diff --git a/src/pages/Documents/DrillingProgram.jsx b/src/pages/Documents/DrillingProgram.jsx index 1a43a23..1d7b714 100644 --- a/src/pages/Documents/DrillingProgram.jsx +++ b/src/pages/Documents/DrillingProgram.jsx @@ -1,4 +1,4 @@ -import {Button} from 'antd' +import {Button, Tooltip} from 'antd' import { useState } from "react" import {invokeWebApiWrapperAsync, download} from '../../components/factory' import DocumentsTemplate from './DocumentsTemplate' @@ -7,7 +7,9 @@ import LoaderPortal from '../../components/LoaderPortal' const idFileCategoryDrillingProgramItems = 13; export default function DrillingProgram({idWell}) { + const [downloadButtonEnabled, selDownloadButtonEnabled] = useState(false) const [showLoader, setShowLoader] = useState(false) + const [tooltip, setTooltip] = useState('нет файлов для формирования') const urlDownloadProgram =`/api/well/${idWell}/drillingProgram` @@ -17,11 +19,34 @@ export default function DrillingProgram({idWell}) { setShowLoader, "Не удалось загрузить программу бурения") + const filesUpdated = (files) =>{ + if(!files || files.length === 0){ + setTooltip('Нет файлов для формирования программы') + selDownloadButtonEnabled(false) + return + } + + if(files.every(fileInfo => fileInfo?.name.endsWith('.xlsx'))){ + setTooltip('Программа доступна для скачивания') + selDownloadButtonEnabled(true) + } + else{ + setTooltip('Список файлов содержит недопустимые типы файлов') + } + } + return( - + + + + accept='.xlsx' + onChange={filesUpdated}/> ) } \ No newline at end of file