Удалены старые меню

This commit is contained in:
goodmice 2022-10-13 13:45:32 +05:00
parent 411b79ee60
commit 9c2b0ecd26
No known key found for this signature in database
GPG Key ID: 63EA771203189CF1
8 changed files with 68 additions and 190 deletions

View File

@ -1,9 +1,7 @@
import { Layout } from 'antd'
import { memo, useMemo } from 'react' import { memo, useMemo } from 'react'
import { Navigate, Route, Routes } from 'react-router-dom' import { Navigate, Route, Routes } from 'react-router-dom'
import { RootPathContext, useRootPath } from '@asb/context' import { RootPathContext, useRootPath } from '@asb/context'
import { PrivateMenu } from '@components/Private'
import { NoAccessComponent, wrapPrivateComponent } from '@utils' import { NoAccessComponent, wrapPrivateComponent } from '@utils'
import TelemetryViewer from './TelemetryViewer' import TelemetryViewer from './TelemetryViewer'
@ -15,23 +13,12 @@ const Telemetry = memo(() => {
return ( return (
<RootPathContext.Provider value={rootPath}> <RootPathContext.Provider value={rootPath}>
<Layout> <Routes>
<PrivateMenu> <Route index element={<Navigate to={TelemetryViewer.route} replace />} />
<PrivateMenu.Link content={TelemetryViewer} /> <Route path={'*'} element={<NoAccessComponent />} />
<PrivateMenu.Link content={TelemetryMerger} /> <Route path={TelemetryViewer.route} element={<TelemetryViewer />} />
</PrivateMenu> <Route path={TelemetryMerger.route} element={<TelemetryMerger />} />
</Routes>
<Layout>
<Layout.Content className={'site-layout-background'}>
<Routes>
<Route index element={<Navigate to={TelemetryViewer.route} replace />} />
<Route path={'*'} element={<NoAccessComponent />} />
<Route path={TelemetryViewer.route} element={<TelemetryViewer />} />
<Route path={TelemetryMerger.route} element={<TelemetryMerger />} />
</Routes>
</Layout.Content>
</Layout>
</Layout>
</RootPathContext.Provider> </RootPathContext.Provider>
) )
}) })

View File

@ -1,9 +1,8 @@
import { useState, useEffect, memo, useMemo } from 'react'
import { Navigate, Route, Routes } from 'react-router-dom' import { Navigate, Route, Routes } from 'react-router-dom'
import { Col, Layout, Row } from 'antd' import { useState, useEffect, memo } from 'react'
import { Row } from 'antd'
import { useWell, useRootPath } from '@asb/context' import { useWell } from '@asb/context'
import { PrivateMenu } from '@components/Private'
import LoaderPortal from '@components/LoaderPortal' import LoaderPortal from '@components/LoaderPortal'
import WellSelector from '@components/selectors/WellSelector' import WellSelector from '@components/selectors/WellSelector'
import { invokeWebApiWrapperAsync } from '@components/factory' import { invokeWebApiWrapperAsync } from '@components/factory'
@ -13,8 +12,6 @@ import { OperationStatService, WellCompositeService } from '@api'
import ClusterWells from '@pages/Cluster/ClusterWells' import ClusterWells from '@pages/Cluster/ClusterWells'
import WellCompositeSections from './WellCompositeSections' import WellCompositeSections from './WellCompositeSections'
const { Content } = Layout
const properties = { const properties = {
requirements: ['OperationStat.get', 'WellComposite.get'], requirements: ['OperationStat.get', 'WellComposite.get'],
title: 'Композитная скважина', title: 'Композитная скважина',
@ -24,12 +21,9 @@ const properties = {
const WellCompositeEditor = memo(() => { const WellCompositeEditor = memo(() => {
const [well] = useWell() const [well] = useWell()
const root = useRootPath()
const rootPath = useMemo(() => `${root}/${properties.key}`, [root])
const [statsWells, setStatsWells] = useState([]) const [statsWells, setStatsWells] = useState([])
const [showLoader, setShowLoader] = useState(false) const [showLoader, setShowLoader] = useState(false)
const [showTabLoader, setShowTabLoader] = useState(false)
const [selectedIdWells, setSelectedIdWells] = useState([]) const [selectedIdWells, setSelectedIdWells] = useState([])
const [selectedSections, setSelectedSections] = useState([]) const [selectedSections, setSelectedSections] = useState([])
@ -61,7 +55,7 @@ const WellCompositeEditor = memo(() => {
const stats = arrayOrDefault(await OperationStatService.getWellsStat(selectedIdWells)) const stats = arrayOrDefault(await OperationStatService.getWellsStat(selectedIdWells))
setStatsWells(stats) setStatsWells(stats)
}, },
setShowTabLoader, setShowLoader,
'Не удалось загрузить статистику по скважинам/секциям', 'Не удалось загрузить статистику по скважинам/секциям',
{ actionName: 'Получение статистики по скважинам/секциям' } { actionName: 'Получение статистики по скважинам/секциям' }
) )
@ -70,29 +64,15 @@ const WellCompositeEditor = memo(() => {
return ( return (
<LoaderPortal show={showLoader}> <LoaderPortal show={showLoader}>
<Row align={'middle'} justify={'space-between'} wrap={false} style={{ backgroundColor: 'white' }}> <Row align={'middle'} justify={'space-between'} wrap={false} style={{ backgroundColor: 'white' }}>
<Col span={18}> <WellSelector onChange={setSelectedIdWells} value={selectedIdWells} />
<WellSelector onChange={setSelectedIdWells} value={selectedIdWells} />
</Col>
<Col span={6}>
<PrivateMenu root={rootPath} className={'well_menu'}>
<PrivateMenu.Link content={ClusterWells} />
<PrivateMenu.Link content={WellCompositeSections} />
</PrivateMenu>
</Col>
</Row> </Row>
<Layout> <Routes>
<Content className={'site-layout-background'}> <Route index element={<Navigate to={ClusterWells.route} replace/>} />
<LoaderPortal show={showTabLoader}> <Route path={'*'} element={<NoAccessComponent />} />
<Routes>
<Route index element={<Navigate to={ClusterWells.route} replace/>} />
<Route path={'*'} element={<NoAccessComponent />} />
<Route path={ClusterWells.route} element={<ClusterWells statsWells={statsWells} />} /> <Route path={ClusterWells.route} element={<ClusterWells statsWells={statsWells} />} />
<Route path={WellCompositeSections.route} element={<WellCompositeSections statsWells={statsWells} selectedSections={selectedSections} />} /> <Route path={WellCompositeSections.route} element={<WellCompositeSections statsWells={statsWells} selectedSections={selectedSections} />} />
</Routes> </Routes>
</LoaderPortal>
</Content>
</Layout>
</LoaderPortal> </LoaderPortal>
) )
}) })

View File

@ -1,9 +1,7 @@
import { memo, useMemo } from 'react' import { memo, useMemo } from 'react'
import { Navigate, Route, Routes } from 'react-router-dom' import { Navigate, Route, Routes } from 'react-router-dom'
import { Layout } from 'antd'
import { RootPathContext, useRootPath } from '@asb/context' import { RootPathContext, useRootPath } from '@asb/context'
import { PrivateMenu } from '@components/Private'
import { NoAccessComponent, wrapPrivateComponent } from '@utils' import { NoAccessComponent, wrapPrivateComponent } from '@utils'
import Statistics from './Statistics' import Statistics from './Statistics'
@ -15,23 +13,13 @@ const Analytics = memo(() => {
return ( return (
<RootPathContext.Provider value={rootPath}> <RootPathContext.Provider value={rootPath}>
<Layout> <Routes>
<PrivateMenu className={'well_menu'}> <Route index element={<Navigate to={WellCompositeEditor.getKey()} replace />} />
<PrivateMenu.Link content={WellCompositeEditor} /> <Route path={'*'} element={<NoAccessComponent />} />
<PrivateMenu.Link key={'statistics'} title={'Оценка по ЦБ'} content={Statistics} />
</PrivateMenu>
<Layout>
<Layout.Content className={'site-layout-background'}>
<Routes>
<Route index element={<Navigate to={WellCompositeEditor.getKey()} replace />} />
<Route path={'*'} element={<NoAccessComponent />} />
<Route path={WellCompositeEditor.route} element={<WellCompositeEditor />} /> <Route path={WellCompositeEditor.route} element={<WellCompositeEditor />} />
<Route path={Statistics.route} element={<Statistics />} /> <Route path={Statistics.route} element={<Statistics />} />
</Routes> </Routes>
</Layout.Content>
</Layout>
</Layout>
</RootPathContext.Provider> </RootPathContext.Provider>
) )
}) })

View File

@ -1,4 +1,4 @@
import React, { memo, useMemo } from 'react' import { memo, useMemo } from 'react'
import { BankOutlined } from '@ant-design/icons' import { BankOutlined } from '@ant-design/icons'
import { makeTextColumn, Table } from '@components/Table' import { makeTextColumn, Table } from '@components/Table'
@ -9,7 +9,7 @@ const columns = [
makeTextColumn('Тип компании', 'companyTypeCaption'), makeTextColumn('Тип компании', 'companyTypeCaption'),
] ]
const CompaniesTable = memo(({companies}) => { const CompaniesTable = memo(({ companies }) => {
const dataCompanies = useMemo(() => companies?.map((company) => ({ const dataCompanies = useMemo(() => companies?.map((company) => ({
key: company.id, key: company.id,
logo: company?.logo ? <img src={company.logo}/> : <BankOutlined/>, logo: company?.logo ? <img src={company.logo}/> : <BankOutlined/>,
@ -30,4 +30,4 @@ const CompaniesTable = memo(({companies}) => {
) )
}) })
export default CompaniesTable export default CompaniesTable

View File

@ -1,16 +1,11 @@
import { Navigate, Route, Routes } from 'react-router-dom' import { Navigate, Route, Routes } from 'react-router-dom'
import { memo, useMemo } from 'react' import { memo, useMemo } from 'react'
import { FolderOutlined } from '@ant-design/icons'
import { Layout } from 'antd'
import { RootPathContext, useRootPath } from '@asb/context' import { RootPathContext, useRootPath } from '@asb/context'
import { PrivateMenu } from '@components/Private' import { wrapPrivateComponent, NoAccessComponent, hasPermission } from '@utils'
import { getTabname, wrapPrivateComponent, NoAccessComponent, hasPermission } from '@utils'
import DocumentsTemplate from './DocumentsTemplate' import DocumentsTemplate from './DocumentsTemplate'
const { Content } = Layout
const makeDocCat = (id, key, title, permissions = ['File.get']) => ({ id, key, title, permissions }) const makeDocCat = (id, key, title, permissions = ['File.get']) => ({ id, key, title, permissions })
export const documentCategories = [ export const documentCategories = [
@ -27,7 +22,6 @@ export const documentCategories = [
] ]
const MenuDocuments = memo(() => { const MenuDocuments = memo(() => {
const category = getTabname()
const root = useRootPath() const root = useRootPath()
const rootPath = useMemo(() => `${root}/document`, [root]) const rootPath = useMemo(() => `${root}/document`, [root])
@ -35,34 +29,21 @@ const MenuDocuments = memo(() => {
return ( return (
<RootPathContext.Provider value={rootPath}> <RootPathContext.Provider value={rootPath}>
<PrivateMenu mode={'horizontal'} selectable={true} className={'well_menu'} selectedKeys={[category]}> <Routes>
{categories.map(category => ( {categories.length > 0 && (
<PrivateMenu.Link <Route index element={<Navigate to={categories[0].key} replace />} />
key={`${category.key}`} )}
icon={<FolderOutlined/>} <Route path={'*'} element={<NoAccessComponent />} />
title={category.title}
/>
))}
</PrivateMenu>
<Layout>
<Content className={'site-layout-background'}>
<Routes>
{categories.length > 0 && (
<Route index element={<Navigate to={categories[0].key} replace />} />
)}
<Route path={'*'} element={<NoAccessComponent />} />
{categories.map(category => ( {categories.map(category => (
<Route key={category.key} path={category.key} element={( <Route key={category.key} path={category.key} element={(
<DocumentsTemplate <DocumentsTemplate
idCategory={category.id} idCategory={category.id}
tableName={`documents_${category.key}`} tableName={`documents_${category.key}`}
/> />
)} /> )} />
))} ))}
</Routes> </Routes>
</Content>
</Layout>
</RootPathContext.Provider> </RootPathContext.Provider>
) )
}) })

View File

@ -1,41 +1,25 @@
import { Navigate, Route, Routes } from 'react-router-dom' import { Navigate, Route, Routes } from 'react-router-dom'
import { memo, useMemo } from 'react' import { memo, useMemo } from 'react'
import { FilePdfOutlined } from '@ant-design/icons'
import { Layout } from 'antd'
import { RootPathContext, useRootPath } from '@asb/context' import { RootPathContext, useRootPath } from '@asb/context'
import { PrivateMenu } from '@components/Private'
import { NoAccessComponent, wrapPrivateComponent } from '@utils' import { NoAccessComponent, wrapPrivateComponent } from '@utils'
import DailyReport from './DailyReport' import DailyReport from './DailyReport'
import DiagramReport from './DiagramReport' import DiagramReport from './DiagramReport'
const { Content } = Layout
const Reports = memo(() => { const Reports = memo(() => {
const root = useRootPath() const root = useRootPath()
const rootPath = useMemo(() => `${root}/reports`, [root]) const rootPath = useMemo(() => `${root}/reports`, [root])
return ( return (
<RootPathContext.Provider value={rootPath}> <RootPathContext.Provider value={rootPath}>
<Layout> <Routes>
<PrivateMenu className={'well_menu'}> <Route index element={<Navigate to={'diagram_report'} replace />} />
<PrivateMenu.Link content={DiagramReport} icon={<FilePdfOutlined />} /> <Route path={'*'} element={<NoAccessComponent />} />
<PrivateMenu.Link content={DailyReport} />
</PrivateMenu>
<Layout> <Route path={DiagramReport.route} element={<DiagramReport />} />
<Content className={'site-layout-background'}> <Route path={DailyReport.route} element={<DailyReport />} />
<Routes> </Routes>
<Route index element={<Navigate to={'diagram_report'} replace />} />
<Route path={'*'} element={<NoAccessComponent />} />
<Route path={DiagramReport.route} element={<DiagramReport />} />
<Route path={DailyReport.route} element={<DailyReport />} />
</Routes>
</Content>
</Layout>
</Layout>
</RootPathContext.Provider> </RootPathContext.Provider>
) )
}) })

View File

@ -1,10 +1,8 @@
import { Navigate, Route, Routes } from 'react-router-dom' import { Navigate, Route, Routes } from 'react-router-dom'
import { memo, useMemo } from 'react' import { memo, useMemo } from 'react'
import { Layout } from 'antd' import { FundViewOutlined } from '@ant-design/icons'
import { AlertOutlined, FundViewOutlined, DatabaseOutlined } from '@ant-design/icons'
import { RootPathContext, useRootPath } from '@asb/context' import { RootPathContext, useRootPath } from '@asb/context'
import { PrivateMenu } from '@components/Private'
import { NoAccessComponent, wrapPrivateComponent } from '@utils' import { NoAccessComponent, wrapPrivateComponent } from '@utils'
import Archive from './Archive' import Archive from './Archive'
@ -16,40 +14,23 @@ import OperationTime from './OperationTime'
import '@styles/index.css' import '@styles/index.css'
const { Content } = Layout
const Telemetry = memo(() => { const Telemetry = memo(() => {
const root = useRootPath() const root = useRootPath()
const rootPath = useMemo(() => `${root}/telemetry`, [root]) const rootPath = useMemo(() => `${root}/telemetry`, [root])
return ( return (
<RootPathContext.Provider value={rootPath}> <RootPathContext.Provider value={rootPath}>
<Layout> <Routes>
<PrivateMenu className={'well_menu'}> <Route index element={<Navigate to={TelemetryView.route} replace />} />
<PrivateMenu.Link content={TelemetryView} icon={<FundViewOutlined />} /> <Route path={'*'} element={<NoAccessComponent />} />
<PrivateMenu.Link content={Messages} icon={<AlertOutlined/>} />
<PrivateMenu.Link content={Archive} icon={<DatabaseOutlined />} />
<PrivateMenu.Link content={DashboardNNB} />
<PrivateMenu.Link content={Operations} />
<PrivateMenu.Link content={OperationTime} />
</PrivateMenu>
<Layout> <Route path={TelemetryView.route} element={<TelemetryView />} />
<Content className={'site-layout-background'}> <Route path={Messages.route} element={<Messages />} />
<Routes> <Route path={Archive.route} element={<Archive />} />
<Route index element={<Navigate to={TelemetryView.route} replace />} /> <Route path={DashboardNNB.route} element={<DashboardNNB />} />
<Route path={'*'} element={<NoAccessComponent />} /> <Route path={Operations.route} element={<Operations />} />
<Route path={OperationTime.route} element={<OperationTime />} />
<Route path={TelemetryView.route} element={<TelemetryView />} /> </Routes>
<Route path={Messages.route} element={<Messages />} />
<Route path={Archive.route} element={<Archive />} />
<Route path={DashboardNNB.route} element={<DashboardNNB />} />
<Route path={Operations.route} element={<Operations />} />
<Route path={OperationTime.route} element={<OperationTime />} />
</Routes>
</Content>
</Layout>
</Layout>
</RootPathContext.Provider> </RootPathContext.Provider>
) )
}) })

View File

@ -1,17 +1,8 @@
import { useNavigate, useLocation, Route, Routes, Navigate } from 'react-router-dom' import { useNavigate, useLocation, Route, Routes, Navigate } from 'react-router-dom'
import { memo, useCallback, useMemo } from 'react' import { memo, useCallback, useMemo } from 'react'
import { Layout } from 'antd'
import {
BarChartOutlined,
BuildOutlined,
ControlOutlined,
LineChartOutlined,
TableOutlined,
} from '@ant-design/icons'
import { RootPathContext, useRootPath } from '@asb/context' import { RootPathContext, useRootPath } from '@asb/context'
import { Flex } from '@components/Grid' import { Flex } from '@components/Grid'
import { PrivateMenu } from '@components/Private'
import { getTabname, NoAccessComponent, wrapPrivateComponent } from '@utils' import { getTabname, NoAccessComponent, wrapPrivateComponent } from '@utils'
import Tvd from './Tvd' import Tvd from './Tvd'
@ -21,8 +12,6 @@ import { DrillProcessFlow } from './DrillProcessFlow'
import { WellSectionsStat } from './WellSectionsStat' import { WellSectionsStat } from './WellSectionsStat'
import { WellOperationsEditorPlan, WellOperationsEditorFact } from './WellOperationsEditor' import { WellOperationsEditorPlan, WellOperationsEditorFact } from './WellOperationsEditor'
const { Content } = Layout
const properties = { const properties = {
requirements: [], requirements: [],
title: 'Операции по скважине', title: 'Операции по скважине',
@ -46,31 +35,19 @@ const WellOperations = memo(() => {
return( return(
<RootPathContext.Provider value={rootPath}> <RootPathContext.Provider value={rootPath}>
<Flex style={{ width: '100%' }}> <Flex style={{ width: '100%' }}>
<PrivateMenu className={'well_menu'} style={{ flex: 1 }}>
<PrivateMenu.Link content={Tvd} icon={<LineChartOutlined />} />
<PrivateMenu.Link content={WellSectionsStat} icon={<BuildOutlined />} key={'sections'} title={'Секции'} />
<PrivateMenu.Link content={WellOperationsEditorPlan} icon={<TableOutlined />} />
<PrivateMenu.Link content={WellOperationsEditorFact} icon={<TableOutlined />} />
<PrivateMenu.Link content={DrillProcessFlow} icon={<BarChartOutlined />} key={'drillProcessFlow'} title={'РТК'} />
<PrivateMenu.Link content={WellDrillParams} icon={<ControlOutlined />} key={'params'} title={'Режимы'} />
</PrivateMenu>
<ImportExportBar disabled={isIEBarDisabled} onImported={onImported}/> <ImportExportBar disabled={isIEBarDisabled} onImported={onImported}/>
</Flex> </Flex>
<Layout> <Routes>
<Content className={'site-layout-background'}> <Route index element={<Navigate to={Tvd.getKey()} replace />} />
<Routes> <Route path={'*'} element={<NoAccessComponent />} />
<Route index element={<Navigate to={Tvd.getKey()} replace />} />
<Route path={'*'} element={<NoAccessComponent />} />
<Route path={Tvd.route} element={<Tvd />} /> <Route path={Tvd.route} element={<Tvd />} />
<Route path={'sections'} element={<WellSectionsStat />} /> <Route path={'sections'} element={<WellSectionsStat />} />
<Route path={WellOperationsEditorPlan.route} element={<WellOperationsEditorPlan />} /> <Route path={WellOperationsEditorPlan.route} element={<WellOperationsEditorPlan />} />
<Route path={WellOperationsEditorFact.route} element={<WellOperationsEditorFact />} /> <Route path={WellOperationsEditorFact.route} element={<WellOperationsEditorFact />} />
<Route path={'drillProcessFlow'} element={<DrillProcessFlow />} /> <Route path={'drillProcessFlow'} element={<DrillProcessFlow />} />
<Route path={'params'} element={<WellDrillParams />} /> <Route path={'params'} element={<WellDrillParams />} />
</Routes> </Routes>
</Content>
</Layout>
</RootPathContext.Provider> </RootPathContext.Provider>
) )
}) })