This commit is contained in:
KharchenkoVV 2021-09-01 16:24:25 +05:00
commit bb84c348fc
3 changed files with 45 additions and 7 deletions

View File

@ -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, headerChild, 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)
@ -179,6 +181,8 @@ export default function DocumentsTemplate({ idCategory, idWell, accept }) {
onUploadStart={() => setShowLoader(true)}
onUploadComplete={handleUploadComplete}/>
</div>
&nbsp;&nbsp;
{headerChild}
</div>
<EditableTable

View File

@ -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,42 @@ export default function DrillingProgram({idWell}) {
setShowLoader,
"Не удалось загрузить программу бурения")
const filesUpdated = (files) =>{
if(!files || files.length === 0){
setTooltip('Нет файлов для формирования программы')
selDownloadButtonEnabled(false)
return
}
if(files.every(fileInfo => fileInfo?.name.toLowerCase().endsWith('.xlsx'))){
setTooltip('Программа доступна для скачивания')
selDownloadButtonEnabled(true)
}
else{
setTooltip('Список файлов содержит недопустимые типы файлов')
}
}
const downloadButton = <div>
<span>Программа бурения</span>
<div>
<Tooltip title={tooltip}>
<Button
type="primary"
onClick={downloadProgram}
disabled={!downloadButtonEnabled}>
Сформировать и скачать
</Button>
</Tooltip>
</div>
</div>
return(<LoaderPortal show={showLoader}>
<Button onClick={downloadProgram}>Сформировать программу бурения</Button>
<DocumentsTemplate
idWell={idWell}
idCategory={idFileCategoryDrillingProgramItems}
accept='.xlsx'/>
accept='.xlsx'
headerChild={downloadButton}
onChange={filesUpdated} />
</LoaderPortal>)
}

View File

@ -5,6 +5,7 @@ import {
AlertOutlined,
FilePdfOutlined,
DatabaseOutlined,
ExperimentOutlined,
} from "@ant-design/icons";
import { Link, Redirect, Route, Switch, useParams } from "react-router-dom";
import TelemetryView from "./TelemetryView";
@ -64,7 +65,7 @@ export default function Well() {
>
{makeMenuItems(rootPath)}
</SubMenu>
<Menu.Item key="measure" icon={<FolderOutlined />}>
<Menu.Item key="measure" icon={<ExperimentOutlined />}>
<Link to={`${rootPath}/measure`}>Измерения</Link>
</Menu.Item>
<Menu.Item key="drillingProgram" icon={<FolderOutlined />}>