Доабвлена блокировка импорта/экспорта для страниц кроме "План" и "Факт"

This commit is contained in:
goodmice 2021-10-15 11:23:19 +05:00
parent 3a9c4331d7
commit 3bcc70e89b
2 changed files with 14 additions and 11 deletions

View File

@ -1,4 +1,4 @@
import { Button, Tooltip, Modal } from "antd"; import { Button, Tooltip, Modal } from 'antd'
import {useState} from 'react' import {useState} from 'react'
import { FileOutlined, ImportOutlined, ExportOutlined } from '@ant-design/icons' import { FileOutlined, ImportOutlined, ExportOutlined } from '@ant-design/icons'
import { download } from '../../components/factory' import { download } from '../../components/factory'
@ -6,7 +6,7 @@ import { ImportOperations } from './ImportOperations'
const style = {margin:4} const style = {margin:4}
export const ImportExportBar = ({idWell, onImported}) =>{ export const ImportExportBar = ({idWell, onImported, disabled}) =>{
const [isImportModalVisible, setIsImportModalVisible] = useState(false) const [isImportModalVisible, setIsImportModalVisible] = useState(false)
const downloadTemplate = async () => download(`/api/well/${idWell}/wellOperations/tamplate`) const downloadTemplate = async () => download(`/api/well/${idWell}/wellOperations/tamplate`)
@ -19,29 +19,32 @@ export const ImportExportBar = ({idWell, onImported}) =>{
} }
return <> return <>
<Tooltip title = "Импорт - загрузить файл с операциями на сервер"> <Tooltip title = 'Импорт - загрузить файл с операциями на сервер'>
<Button <Button
disabled={disabled}
icon={<ImportOutlined/>} icon={<ImportOutlined/>}
style={style} style={style}
onClick={_=>setIsImportModalVisible(true)}/> onClick={_=>setIsImportModalVisible(true)}/>
</Tooltip> </Tooltip>
<Tooltip title = "Экспорт - скачать файл с операциями по скважине"> <Tooltip title = 'Экспорт - скачать файл с операциями по скважине'>
<Button <Button
disabled={disabled}
icon={<ExportOutlined/>} icon={<ExportOutlined/>}
style={style} style={style}
onClick={downloadExport}/> onClick={downloadExport}/>
</Tooltip> </Tooltip>
<Tooltip title = "Скачать шаблон"> <Tooltip title = 'Скачать шаблон для импорта операций'>
<Button <Button
disabled={disabled}
icon={<FileOutlined/>} icon={<FileOutlined/>}
style={style} style={style}
onClick={downloadTemplate}/> onClick={downloadTemplate}/>
</Tooltip> </Tooltip>
<Modal <Modal
title='Импорт' title='Импорт операций'
visible={isImportModalVisible} visible={isImportModalVisible}
onCancel={_=>setIsImportModalVisible(false)} onCancel={_=>setIsImportModalVisible(false)}

View File

@ -13,11 +13,11 @@ const { Content } = Layout
export default function WellOperations({idWell}) { export default function WellOperations({idWell}) {
let {tab} = useParams() let {tab} = useParams()
let history = useHistory() let history = useHistory()
const rootPath = `/well/${idWell}/operations`; const rootPath = `/well/${idWell}/operations`
const onImported = () => { const onImported = () => history.push(`${rootPath}`)
history.push(`${rootPath}`)
} const isIEBarDisabled = !["plan", "fact"].includes(tab)
return(<> return(<>
<Menu <Menu
@ -43,7 +43,7 @@ export default function WellOperations({idWell}) {
<Menu.Item key="composite" icon={<FolderOutlined />}> <Menu.Item key="composite" icon={<FolderOutlined />}>
<Link to={`${rootPath}/composite`}>Композитная скважина</Link> <Link to={`${rootPath}/composite`}>Композитная скважина</Link>
</Menu.Item> </Menu.Item>
<ImportExportBar idWell={idWell} onImported={onImported}/> <ImportExportBar idWell={idWell} disabled={isIEBarDisabled} onImported={onImported}/>
</Menu> </Menu>
<Layout> <Layout>
<Content className="site-layout-background"> <Content className="site-layout-background">