forked from ddrilling/asb_cloud_front
WellSelector применено к композитной скважине
This commit is contained in:
parent
929fc50b35
commit
21149754c7
@ -1,15 +1,14 @@
|
|||||||
import { useState, useEffect, memo } from 'react'
|
import { useState, useEffect, memo } from 'react'
|
||||||
import { Switch, useParams } from 'react-router-dom'
|
import { Switch, useParams } from 'react-router-dom'
|
||||||
import { Col, Layout, Menu, Row, Tag, TreeSelect } from 'antd'
|
import { Col, Layout, Menu, Row } from 'antd'
|
||||||
|
|
||||||
import {
|
import {
|
||||||
DepositService,
|
|
||||||
OperationStatService,
|
OperationStatService,
|
||||||
WellCompositeService,
|
WellCompositeService,
|
||||||
} from '@api'
|
} from '@api'
|
||||||
import { arrayOrDefault } from '@utils'
|
import { arrayOrDefault } from '@utils'
|
||||||
import { hasPermission } from '@utils/permissions'
|
|
||||||
import LoaderPortal from '@components/LoaderPortal'
|
import LoaderPortal from '@components/LoaderPortal'
|
||||||
|
import WellSelector from '@components/WellSelector'
|
||||||
import { invokeWebApiWrapperAsync } from '@components/factory'
|
import { invokeWebApiWrapperAsync } from '@components/factory'
|
||||||
import { PrivateDefaultRoute, PrivateMenuItemLink, PrivateRoute } from '@components/Private'
|
import { PrivateDefaultRoute, PrivateMenuItemLink, PrivateRoute } from '@components/Private'
|
||||||
|
|
||||||
@ -21,41 +20,14 @@ const { Content } = Layout
|
|||||||
export const WellCompositeEditor = memo(({ idWell, rootPath }) => {
|
export const WellCompositeEditor = memo(({ idWell, rootPath }) => {
|
||||||
const { tab } = useParams()
|
const { tab } = useParams()
|
||||||
|
|
||||||
const [wellsTree, setWellsTree] = useState([])
|
|
||||||
const [wellLabels, setWellLabels] = useState([])
|
|
||||||
const [statsWells, setStatsWells] = 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 [selectedSections, setSelectedSections] = useState([])
|
const [selectedSections, setSelectedSections] = useState([])
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => invokeWebApiWrapperAsync(
|
||||||
invokeWebApiWrapperAsync(
|
|
||||||
async () => {
|
async () => {
|
||||||
const deposits = await DepositService.getDeposits()
|
|
||||||
const labels = {}
|
|
||||||
const wellsTree = deposits.map((deposit, dIdx) => ({
|
|
||||||
title: deposit.caption,
|
|
||||||
key: `0-${dIdx}`,
|
|
||||||
value: `0-${dIdx}`,
|
|
||||||
children: deposit.clusters.map((cluster, cIdx) => ({
|
|
||||||
title: cluster.caption,
|
|
||||||
key: `0-${dIdx}-${cIdx}`,
|
|
||||||
value: `0-${dIdx}-${cIdx}`,
|
|
||||||
children: cluster.wells.map(well => {
|
|
||||||
labels[well.id] = `${deposit.caption}.${cluster.caption}.${well.caption}`
|
|
||||||
|
|
||||||
return ({
|
|
||||||
title: well.caption,
|
|
||||||
key: well.id,
|
|
||||||
value: well.id,
|
|
||||||
})
|
|
||||||
}),
|
|
||||||
})),
|
|
||||||
}))
|
|
||||||
setWellsTree(wellsTree)
|
|
||||||
setWellLabels(labels)
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const selected = await WellCompositeService.get(idWell)
|
const selected = await WellCompositeService.get(idWell)
|
||||||
setSelectedSections(arrayOrDefault(selected))
|
setSelectedSections(arrayOrDefault(selected))
|
||||||
@ -66,8 +38,7 @@ export const WellCompositeEditor = memo(({ idWell, rootPath }) => {
|
|||||||
setShowLoader,
|
setShowLoader,
|
||||||
'Не удалось загрузить список скважин',
|
'Не удалось загрузить список скважин',
|
||||||
'Получение списка скважин'
|
'Получение списка скважин'
|
||||||
)
|
), [idWell])
|
||||||
}, [idWell])
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const wellIds = selectedSections.map((value) => value.idWellSrc)
|
const wellIds = selectedSections.map((value) => value.idWellSrc)
|
||||||
@ -88,22 +59,10 @@ export const WellCompositeEditor = memo(({ idWell, rootPath }) => {
|
|||||||
<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}>
|
<Col span={18}>
|
||||||
<TreeSelect
|
<WellSelector
|
||||||
multiple
|
idWell={idWell}
|
||||||
treeCheckable
|
onChange={setSelectedIdWells}
|
||||||
showCheckedStrategy={TreeSelect.SHOW_CHILD}
|
|
||||||
treeDefaultExpandAll
|
|
||||||
treeData={wellsTree}
|
|
||||||
treeLine={{ showLeafIcon: false }}
|
|
||||||
onChange={(value) => setSelectedIdWells(value)}
|
|
||||||
size={'middle'}
|
|
||||||
style={{ width: '100%' }}
|
|
||||||
value={selectedIdWells}
|
value={selectedIdWells}
|
||||||
placeholder={'Выберите скважины'}
|
|
||||||
tagRender={(props) => (
|
|
||||||
<Tag {...props}>{wellLabels[props.value] ?? props.label}</Tag>
|
|
||||||
)}
|
|
||||||
disabled={!hasPermission('WellOperation.edit')}
|
|
||||||
/>
|
/>
|
||||||
</Col>
|
</Col>
|
||||||
<Col span={6}>
|
<Col span={6}>
|
||||||
|
Loading…
Reference in New Issue
Block a user