forked from ddrilling/asb_cloud_front
Merge branch 'master' of https://bitbucket.org/frolovng/asb_cloud_front_react
This commit is contained in:
commit
bb84c348fc
@ -17,7 +17,7 @@ const pageSize = 12
|
|||||||
const { RangePicker } = DatePicker
|
const { RangePicker } = DatePicker
|
||||||
const { Search } = Input
|
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 [page, setPage] = useState(1)
|
||||||
const [filterDataRange, setFilterDataRange] = useState([])
|
const [filterDataRange, setFilterDataRange] = useState([])
|
||||||
const [filterCompanyName, setFilterCompanyName] = useState([])
|
const [filterCompanyName, setFilterCompanyName] = useState([])
|
||||||
@ -116,9 +116,7 @@ export default function DocumentsTemplate({ idCategory, idWell, accept }) {
|
|||||||
return
|
return
|
||||||
|
|
||||||
const filesInfos = paginatedFiles.items??[]
|
const filesInfos = paginatedFiles.items??[]
|
||||||
|
|
||||||
setFiles(filesInfos)
|
setFiles(filesInfos)
|
||||||
|
|
||||||
const newPagination = makePaginationObject(paginatedFiles)
|
const newPagination = makePaginationObject(paginatedFiles)
|
||||||
setPagination(newPagination)
|
setPagination(newPagination)
|
||||||
},
|
},
|
||||||
@ -128,6 +126,10 @@ export default function DocumentsTemplate({ idCategory, idWell, accept }) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
useEffect(update, [idWell, idCategory, page, filterDataRange, filterCompanyName, filterFileName])
|
useEffect(update, [idWell, idCategory, page, filterDataRange, filterCompanyName, filterFileName])
|
||||||
|
useEffect(()=>{
|
||||||
|
if(onChange)
|
||||||
|
onChange(files)
|
||||||
|
}, [files, onChange])
|
||||||
|
|
||||||
const companies = [...new Set(files.map(file=>file.company))]
|
const companies = [...new Set(files.map(file=>file.company))]
|
||||||
.filter(company=>company)
|
.filter(company=>company)
|
||||||
@ -179,6 +181,8 @@ export default function DocumentsTemplate({ idCategory, idWell, accept }) {
|
|||||||
onUploadStart={() => setShowLoader(true)}
|
onUploadStart={() => setShowLoader(true)}
|
||||||
onUploadComplete={handleUploadComplete}/>
|
onUploadComplete={handleUploadComplete}/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
{headerChild}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<EditableTable
|
<EditableTable
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import {Button} from 'antd'
|
import {Button, Tooltip} from 'antd'
|
||||||
import { useState } from "react"
|
import { useState } from "react"
|
||||||
import {invokeWebApiWrapperAsync, download} from '../../components/factory'
|
import {invokeWebApiWrapperAsync, download} from '../../components/factory'
|
||||||
import DocumentsTemplate from './DocumentsTemplate'
|
import DocumentsTemplate from './DocumentsTemplate'
|
||||||
@ -7,7 +7,9 @@ import LoaderPortal from '../../components/LoaderPortal'
|
|||||||
const idFileCategoryDrillingProgramItems = 13;
|
const idFileCategoryDrillingProgramItems = 13;
|
||||||
|
|
||||||
export default function DrillingProgram({idWell}) {
|
export default function DrillingProgram({idWell}) {
|
||||||
|
const [downloadButtonEnabled, selDownloadButtonEnabled] = useState(false)
|
||||||
const [showLoader, setShowLoader] = useState(false)
|
const [showLoader, setShowLoader] = useState(false)
|
||||||
|
const [tooltip, setTooltip] = useState('нет файлов для формирования')
|
||||||
|
|
||||||
const urlDownloadProgram =`/api/well/${idWell}/drillingProgram`
|
const urlDownloadProgram =`/api/well/${idWell}/drillingProgram`
|
||||||
|
|
||||||
@ -17,11 +19,42 @@ export default function DrillingProgram({idWell}) {
|
|||||||
setShowLoader,
|
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}>
|
return(<LoaderPortal show={showLoader}>
|
||||||
<Button onClick={downloadProgram}>Сформировать программу бурения</Button>
|
|
||||||
<DocumentsTemplate
|
<DocumentsTemplate
|
||||||
idWell={idWell}
|
idWell={idWell}
|
||||||
idCategory={idFileCategoryDrillingProgramItems}
|
idCategory={idFileCategoryDrillingProgramItems}
|
||||||
accept='.xlsx'/>
|
accept='.xlsx'
|
||||||
|
headerChild={downloadButton}
|
||||||
|
onChange={filesUpdated} />
|
||||||
</LoaderPortal>)
|
</LoaderPortal>)
|
||||||
}
|
}
|
@ -5,6 +5,7 @@ import {
|
|||||||
AlertOutlined,
|
AlertOutlined,
|
||||||
FilePdfOutlined,
|
FilePdfOutlined,
|
||||||
DatabaseOutlined,
|
DatabaseOutlined,
|
||||||
|
ExperimentOutlined,
|
||||||
} from "@ant-design/icons";
|
} from "@ant-design/icons";
|
||||||
import { Link, Redirect, Route, Switch, useParams } from "react-router-dom";
|
import { Link, Redirect, Route, Switch, useParams } from "react-router-dom";
|
||||||
import TelemetryView from "./TelemetryView";
|
import TelemetryView from "./TelemetryView";
|
||||||
@ -64,7 +65,7 @@ export default function Well() {
|
|||||||
>
|
>
|
||||||
{makeMenuItems(rootPath)}
|
{makeMenuItems(rootPath)}
|
||||||
</SubMenu>
|
</SubMenu>
|
||||||
<Menu.Item key="measure" icon={<FolderOutlined />}>
|
<Menu.Item key="measure" icon={<ExperimentOutlined />}>
|
||||||
<Link to={`${rootPath}/measure`}>Измерения</Link>
|
<Link to={`${rootPath}/measure`}>Измерения</Link>
|
||||||
</Menu.Item>
|
</Menu.Item>
|
||||||
<Menu.Item key="drillingProgram" icon={<FolderOutlined />}>
|
<Menu.Item key="drillingProgram" icon={<FolderOutlined />}>
|
||||||
|
Loading…
Reference in New Issue
Block a user