From 449a7566b6c8feaed5d76a2c004e35cae30b6b6a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A4=D1=80=D0=BE=D0=BB=D0=BE=D0=B2?= Date: Wed, 1 Sep 2021 12:29:44 +0500 Subject: [PATCH] =?UTF-8?q?CF2-61=20DrillingProgram=20=D0=BA=D0=BD=D0=BE?= =?UTF-8?q?=D0=BF=D0=BA=D0=B0=20=D0=B7=D0=B0=D0=B3=D1=80=D1=83=D0=B7=D0=BA?= =?UTF-8?q?=D0=B8=20=D0=B4=D0=BE=D1=81=D1=82=D1=83=D0=BF=D0=BD=D0=B0=20?= =?UTF-8?q?=D1=82=D0=BE=D0=BB=D1=8C=D0=BA=D0=BE=20=D0=BF=D1=80=D0=B8=20?= =?UTF-8?q?=D0=BD=D0=B0=D0=BB=D0=B8=D1=87=D0=B8=D0=B8=20excel=20=D1=84?= =?UTF-8?q?=D0=B0=D0=B9=D0=BB=D0=BE=D0=B2=20=D0=B2=20DocumentsTemplate?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/Documents/DocumentsTemplate.jsx | 8 +++--- src/pages/Documents/DrillingProgram.jsx | 31 ++++++++++++++++++++--- 2 files changed, 33 insertions(+), 6 deletions(-) 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