forked from ddrilling/asb_cloud_front
Рефакторинг стиля кода
This commit is contained in:
parent
826085bc70
commit
8ea3ff02af
@ -1,25 +0,0 @@
|
|||||||
import { useEffect, useState } from 'react'
|
|
||||||
import { invokeWebApiWrapperAsync } from '../../../components/factory'
|
|
||||||
import LoaderPortal from '../../../components/LoaderPortal'
|
|
||||||
import { OperationStatService } from '../../../services/api'
|
|
||||||
import ClusterWells from '../../Cluster/ClusterWells'
|
|
||||||
|
|
||||||
export const WellCompositeInfo = ({idWell, selectedIdWells}) => {
|
|
||||||
const [showLoader, setShowLoader] = useState(false)
|
|
||||||
const [statsWells, setStatsWells] = useState([])
|
|
||||||
|
|
||||||
useEffect(() => invokeWebApiWrapperAsync(
|
|
||||||
async () => {
|
|
||||||
const operations = await OperationStatService.getWellsStat(selectedIdWells)
|
|
||||||
setStatsWells(operations)
|
|
||||||
},
|
|
||||||
setShowLoader,
|
|
||||||
'Не удалось загрузить список операции по скважинам'
|
|
||||||
), [selectedIdWells])
|
|
||||||
|
|
||||||
return (
|
|
||||||
<LoaderPortal show={showLoader}>
|
|
||||||
<ClusterWells statsWells={statsWells}/>
|
|
||||||
</LoaderPortal>
|
|
||||||
)
|
|
||||||
}
|
|
@ -14,8 +14,8 @@ import {
|
|||||||
makeFilterMinMaxFunction,
|
makeFilterMinMaxFunction,
|
||||||
getOperations
|
getOperations
|
||||||
} from '../../Cluster/functions'
|
} from '../../Cluster/functions'
|
||||||
import { Tvd } from '../Tvd'
|
|
||||||
import WellOperationsTable from '../../Cluster/WellOperationsTable'
|
import WellOperationsTable from '../../Cluster/WellOperationsTable'
|
||||||
|
import { Tvd } from '../Tvd'
|
||||||
import { getColumns } from '../WellDrillParams'
|
import { getColumns } from '../WellDrillParams'
|
||||||
|
|
||||||
|
|
||||||
@ -28,19 +28,18 @@ const filtersSectionsType = []
|
|||||||
const DAY_IN_MS = 1000 * 60 * 60 * 24
|
const DAY_IN_MS = 1000 * 60 * 60 * 24
|
||||||
|
|
||||||
export const WellCompositeSections = ({ idWell, statsWells, selectedSections }) => {
|
export const WellCompositeSections = ({ idWell, statsWells, selectedSections }) => {
|
||||||
|
|
||||||
const [showLoader, setShowLoader] = useState(false)
|
|
||||||
const [showParamsLoader, setShowParamsLoader] = useState(false)
|
|
||||||
const [selectedWellId, setSelectedWellId] = useState(0)
|
|
||||||
const [selectedWells, setSelectedWells] = useState([])
|
|
||||||
const [selectedWellsKeys, setSelectedWellsKeys] = useState([])
|
|
||||||
const [isTVDModalVisible, setIsTVDModalVisible] = useState(false)
|
|
||||||
const [isOpsModalVisible, setIsOpsModalVisible] = useState(false)
|
|
||||||
const [isParamsModalVisible, setIsParamsModalVisible] = useState(false)
|
|
||||||
const [wellOperations, setWellOperations] = useState([])
|
|
||||||
const [rows, setRows] = useState([])
|
const [rows, setRows] = useState([])
|
||||||
const [params, setParams] = useState([])
|
const [params, setParams] = useState([])
|
||||||
const [paramsColumns, setParamsColumns] = useState([])
|
const [paramsColumns, setParamsColumns] = useState([])
|
||||||
|
const [selectedWells, setSelectedWells] = useState([])
|
||||||
|
const [wellOperations, setWellOperations] = useState([])
|
||||||
|
const [selectedWellsKeys, setSelectedWellsKeys] = useState([])
|
||||||
|
const [selectedWellId, setSelectedWellId] = useState(0)
|
||||||
|
const [showLoader, setShowLoader] = useState(false)
|
||||||
|
const [showParamsLoader, setShowParamsLoader] = useState(false)
|
||||||
|
const [isTVDModalVisible, setIsTVDModalVisible] = useState(false)
|
||||||
|
const [isOpsModalVisible, setIsOpsModalVisible] = useState(false)
|
||||||
|
const [isParamsModalVisible, setIsParamsModalVisible] = useState(false)
|
||||||
|
|
||||||
useEffect(() => (async() => setParamsColumns(await getColumns(idWell)))(), [idWell])
|
useEffect(() => (async() => setParamsColumns(await getColumns(idWell)))(), [idWell])
|
||||||
|
|
||||||
@ -63,7 +62,7 @@ export const WellCompositeSections = ({ idWell, statsWells, selectedSections })
|
|||||||
if (!filtersSectionsType.some((el) => el.text === section.caption))
|
if (!filtersSectionsType.some((el) => el.text === section.caption))
|
||||||
filtersSectionsType.push({ text: section.caption, value: section.caption })
|
filtersSectionsType.push({ text: section.caption, value: section.caption })
|
||||||
|
|
||||||
let row = {
|
const row = {
|
||||||
key: well.caption + section.id,
|
key: well.caption + section.id,
|
||||||
id: well.id,
|
id: well.id,
|
||||||
sectionId: section.id,
|
sectionId: section.id,
|
||||||
@ -138,18 +137,26 @@ export const WellCompositeSections = ({ idWell, statsWells, selectedSections })
|
|||||||
makeNumericColumnPlanFact('НПВ, сут', 'nonProductiveTime', filtersMinMax, makeFilterMinMaxFunction, null, '70px'),
|
makeNumericColumnPlanFact('НПВ, сут', 'nonProductiveTime', filtersMinMax, makeFilterMinMaxFunction, null, '70px'),
|
||||||
{
|
{
|
||||||
title: 'TVD',
|
title: 'TVD',
|
||||||
render: (value) => <Button onClick={()=> {
|
render: (value) => (
|
||||||
setSelectedWellId(value.id)
|
<Button onClick={() => {
|
||||||
setIsTVDModalVisible(true)
|
setSelectedWellId(value.id)
|
||||||
}}><LineChartOutlined /></Button>,
|
setIsTVDModalVisible(true)
|
||||||
|
}}>
|
||||||
|
<LineChartOutlined />
|
||||||
|
</Button>
|
||||||
|
),
|
||||||
align: 'center'
|
align: 'center'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: 'Операции',
|
title: 'Операции',
|
||||||
render: (value) => <Button onClick={()=> {
|
render: (value) => (
|
||||||
setSelectedWellId(value.id)
|
<Button onClick={()=> {
|
||||||
setIsOpsModalVisible(true)
|
setSelectedWellId(value.id)
|
||||||
}}><ProfileOutlined /></Button>,
|
setIsOpsModalVisible(true)
|
||||||
|
}}>
|
||||||
|
<ProfileOutlined />
|
||||||
|
</Button>
|
||||||
|
),
|
||||||
align: 'center'
|
align: 'center'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -221,13 +228,17 @@ export const WellCompositeSections = ({ idWell, statsWells, selectedSections })
|
|||||||
scroll={{ x: true }}
|
scroll={{ x: true }}
|
||||||
pagination={false}
|
pagination={false}
|
||||||
/>
|
/>
|
||||||
<Row justify={'end'} style={{margin: '1rem 0'}}><Col>
|
<Row justify={'end'} style={{ margin: '1rem 0' }}>
|
||||||
|
<Col>
|
||||||
<Button
|
<Button
|
||||||
size={'large'}
|
size={'large'}
|
||||||
disabled={selectedWells.length <= 0}
|
disabled={selectedWells.length <= 0}
|
||||||
onClick={onParamButtonClick}
|
onClick={onParamButtonClick}
|
||||||
>Режимы</Button>
|
>
|
||||||
</Col></Row>
|
Режимы
|
||||||
|
</Button>
|
||||||
|
</Col>
|
||||||
|
</Row>
|
||||||
|
|
||||||
<Modal
|
<Modal
|
||||||
title={'TVD'}
|
title={'TVD'}
|
||||||
@ -259,14 +270,11 @@ export const WellCompositeSections = ({ idWell, statsWells, selectedSections })
|
|||||||
visible={isParamsModalVisible}
|
visible={isParamsModalVisible}
|
||||||
onCancel={() => setIsParamsModalVisible(false)}
|
onCancel={() => setIsParamsModalVisible(false)}
|
||||||
width={1700}
|
width={1700}
|
||||||
footer={
|
footer={(
|
||||||
<Popconfirm title='Заменить существующие режимы выбранными?' onConfirm={onParamsAddClick}>
|
<Popconfirm title={'Заменить существующие режимы выбранными?'} onConfirm={onParamsAddClick}>
|
||||||
<Button
|
<Button size={'large'} disabled={params.length <= 0}>Сохранить</Button>
|
||||||
size={'large'}
|
|
||||||
disabled={params.length <= 0}
|
|
||||||
>Сохранить</Button>
|
|
||||||
</Popconfirm>
|
</Popconfirm>
|
||||||
}
|
)}
|
||||||
>
|
>
|
||||||
<LoaderPortal show={showParamsLoader}>
|
<LoaderPortal show={showParamsLoader}>
|
||||||
<Table
|
<Table
|
||||||
|
@ -1,26 +1,32 @@
|
|||||||
import { Col, Layout, Menu, Row, Tag, TreeSelect } from 'antd'
|
|
||||||
import { useState, useEffect } from 'react'
|
import { useState, useEffect } from 'react'
|
||||||
import { Redirect, Route, Switch, Link, useParams } from 'react-router-dom'
|
import { Redirect, Route, Switch, Link, useParams } from 'react-router-dom'
|
||||||
import { DepositService, WellCompositeService } from '../../../services/api'
|
import { Col, Layout, Menu, Row, Tag, TreeSelect } from 'antd'
|
||||||
import { invokeWebApiWrapperAsync } from '../../../components/factory'
|
|
||||||
import LoaderPortal from '../../../components/LoaderPortal'
|
import LoaderPortal from '../../../components/LoaderPortal'
|
||||||
import { WellCompositeSections } from './WellCompositeSections'
|
import { invokeWebApiWrapperAsync } from '../../../components/factory'
|
||||||
import { OperationStatService } from '../../../services/api'
|
import {
|
||||||
|
DepositService,
|
||||||
|
OperationStatService,
|
||||||
|
WellCompositeService,
|
||||||
|
} from '../../../services/api'
|
||||||
|
import { arrayOrDefault } from '../../../utils'
|
||||||
|
|
||||||
import ClusterWells from '../../Cluster/ClusterWells'
|
import ClusterWells from '../../Cluster/ClusterWells'
|
||||||
|
import { WellCompositeSections } from './WellCompositeSections'
|
||||||
|
|
||||||
const { Content } = Layout
|
const { Content } = Layout
|
||||||
|
|
||||||
export const WellCompositeEditor = ({idWell}) => {
|
export const WellCompositeEditor = ({ idWell }) => {
|
||||||
const { tab } = useParams()
|
|
||||||
const rootPath = `/well/${idWell}/operations/composite`
|
const rootPath = `/well/${idWell}/operations/composite`
|
||||||
|
const { tab } = useParams()
|
||||||
|
|
||||||
const [wellsTree, setWellsTree] = useState([])
|
const [wellsTree, setWellsTree] = useState([])
|
||||||
|
const [wellLabels, setWellLabels] = useState([])
|
||||||
|
const [statsWells, setStatsWells] = useState([])
|
||||||
const [showLoader, setShowLoader] = useState(false)
|
const [showLoader, setShowLoader] = useState(false)
|
||||||
const [showTabLoader, setShowTabLoader] = useState(false)
|
const [showTabLoader, setShowTabLoader] = useState(false)
|
||||||
const [selectedIdWells, setSelectedIdWells] = useState([])
|
const [selectedIdWells, setSelectedIdWells] = useState([])
|
||||||
const [statsWells, setStatsWells] = useState([])
|
|
||||||
const [selectedSections, setSelectedSections] = useState([])
|
const [selectedSections, setSelectedSections] = useState([])
|
||||||
const [wellLabels, setWellLabels] = useState([])
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
invokeWebApiWrapperAsync(
|
invokeWebApiWrapperAsync(
|
||||||
@ -44,14 +50,14 @@ export const WellCompositeEditor = ({idWell}) => {
|
|||||||
value: well.id,
|
value: well.id,
|
||||||
})
|
})
|
||||||
}),
|
}),
|
||||||
}))
|
})),
|
||||||
}))
|
}))
|
||||||
setWellsTree(wellsTree)
|
setWellsTree(wellsTree)
|
||||||
setWellLabels(labels)
|
setWellLabels(labels)
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const selected = await WellCompositeService.get(idWell)
|
const selected = await WellCompositeService.get(idWell)
|
||||||
setSelectedSections(Array.isArray(selected) ? selected : [])
|
setSelectedSections(arrayOrDefault(selected))
|
||||||
} catch(e) {
|
} catch(e) {
|
||||||
setSelectedSections([])
|
setSelectedSections([])
|
||||||
}
|
}
|
||||||
@ -69,7 +75,7 @@ export const WellCompositeEditor = ({idWell}) => {
|
|||||||
useEffect(() => invokeWebApiWrapperAsync(
|
useEffect(() => invokeWebApiWrapperAsync(
|
||||||
async () => {
|
async () => {
|
||||||
const stats = await OperationStatService.getWellsStat(selectedIdWells)
|
const stats = await OperationStatService.getWellsStat(selectedIdWells)
|
||||||
setStatsWells(Array.isArray(stats) ? stats : [])
|
setStatsWells(arrayOrDefault(stats))
|
||||||
},
|
},
|
||||||
setShowTabLoader,
|
setShowTabLoader,
|
||||||
'Не удалось загрузить статистику по скважинам/секциям'
|
'Не удалось загрузить статистику по скважинам/секциям'
|
||||||
@ -85,7 +91,7 @@ export const WellCompositeEditor = ({idWell}) => {
|
|||||||
showCheckedStrategy={TreeSelect.SHOW_CHILD}
|
showCheckedStrategy={TreeSelect.SHOW_CHILD}
|
||||||
treeDefaultExpandAll
|
treeDefaultExpandAll
|
||||||
treeData={wellsTree}
|
treeData={wellsTree}
|
||||||
treeLine={{showLeafIcon: false}}
|
treeLine={{ showLeafIcon: false }}
|
||||||
onChange={(value) => setSelectedIdWells(value)}
|
onChange={(value) => setSelectedIdWells(value)}
|
||||||
size={'middle'}
|
size={'middle'}
|
||||||
style={{width: '100%'}}
|
style={{width: '100%'}}
|
||||||
|
Loading…
Reference in New Issue
Block a user