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 1/3] =?UTF-8?q?CF2-61=20DrillingProgram=20=D0=BA=D0=BD?= =?UTF-8?q?=D0=BE=D0=BF=D0=BA=D0=B0=20=D0=B7=D0=B0=D0=B3=D1=80=D1=83=D0=B7?= =?UTF-8?q?=D0=BA=D0=B8=20=D0=B4=D0=BE=D1=81=D1=82=D1=83=D0=BF=D0=BD=D0=B0?= =?UTF-8?q?=20=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 From e42b9069fec8cac62a6f060b810840fc54671687 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 13:43:14 +0500 Subject: [PATCH 2/3] Move drillingProgramButton into documentTemplate header --- src/pages/Documents/DocumentsTemplate.jsx | 4 +++- src/pages/Documents/DrillingProgram.jsx | 23 +++++++++++++++-------- 2 files changed, 18 insertions(+), 9 deletions(-) diff --git a/src/pages/Documents/DocumentsTemplate.jsx b/src/pages/Documents/DocumentsTemplate.jsx index 4656628..b156cf9 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, onChange }) { +export default function DocumentsTemplate({ idCategory, idWell, accept, headerChild, onChange }) { const [page, setPage] = useState(1) const [filterDataRange, setFilterDataRange] = useState([]) const [filterCompanyName, setFilterCompanyName] = useState([]) @@ -181,6 +181,8 @@ export default function DocumentsTemplate({ idCategory, idWell, accept, onChange onUploadStart={() => setShowLoader(true)} onUploadComplete={handleUploadComplete}/> +    + {headerChild} + Программа бурения +
+ + + +
+ + return( - - - + headerChild={downloadButton} + onChange={filesUpdated} /> ) } \ No newline at end of file From 4ad91d861f610ae96f7d02abf7d1f2e2f1c7f48c 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 15:55:23 +0500 Subject: [PATCH 3/3] design --- src/pages/Documents/DrillingProgram.jsx | 3 ++- src/pages/Well.jsx | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/pages/Documents/DrillingProgram.jsx b/src/pages/Documents/DrillingProgram.jsx index a0839ba..b05e212 100644 --- a/src/pages/Documents/DrillingProgram.jsx +++ b/src/pages/Documents/DrillingProgram.jsx @@ -26,7 +26,7 @@ export default function DrillingProgram({idWell}) { return } - if(files.every(fileInfo => fileInfo?.name.endsWith('.xlsx'))){ + if(files.every(fileInfo => fileInfo?.name.toLowerCase().endsWith('.xlsx'))){ setTooltip('Программа доступна для скачивания') selDownloadButtonEnabled(true) } @@ -40,6 +40,7 @@ export default function DrillingProgram({idWell}) {