From 21149754c74ddf8b16e840afdc22072ead296d8f Mon Sep 17 00:00:00 2001 From: goodm2ice Date: Sun, 13 Mar 2022 22:20:41 +0500 Subject: [PATCH] =?UTF-8?q?WellSelector=20=D0=BF=D1=80=D0=B8=D0=BC=D0=B5?= =?UTF-8?q?=D0=BD=D0=B5=D0=BD=D0=BE=20=D0=BA=20=D0=BA=D0=BE=D0=BC=D0=BF?= =?UTF-8?q?=D0=BE=D0=B7=D0=B8=D1=82=D0=BD=D0=BE=D0=B9=20=D1=81=D0=BA=D0=B2?= =?UTF-8?q?=D0=B0=D0=B6=D0=B8=D0=BD=D0=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Analytics/WellCompositeEditor/index.jsx | 77 +++++-------------- 1 file changed, 18 insertions(+), 59 deletions(-) diff --git a/src/pages/Analytics/WellCompositeEditor/index.jsx b/src/pages/Analytics/WellCompositeEditor/index.jsx index 0061ccc..4a56869 100644 --- a/src/pages/Analytics/WellCompositeEditor/index.jsx +++ b/src/pages/Analytics/WellCompositeEditor/index.jsx @@ -1,15 +1,14 @@ import { useState, useEffect, memo } from 'react' import { Switch, useParams } from 'react-router-dom' -import { Col, Layout, Menu, Row, Tag, TreeSelect } from 'antd' +import { Col, Layout, Menu, Row } from 'antd' import { - DepositService, OperationStatService, WellCompositeService, } from '@api' import { arrayOrDefault } from '@utils' -import { hasPermission } from '@utils/permissions' import LoaderPortal from '@components/LoaderPortal' +import WellSelector from '@components/WellSelector' import { invokeWebApiWrapperAsync } from '@components/factory' import { PrivateDefaultRoute, PrivateMenuItemLink, PrivateRoute } from '@components/Private' @@ -21,53 +20,25 @@ const { Content } = Layout export const WellCompositeEditor = memo(({ idWell, rootPath }) => { const { tab } = useParams() - const [wellsTree, setWellsTree] = useState([]) - const [wellLabels, setWellLabels] = useState([]) const [statsWells, setStatsWells] = useState([]) const [showLoader, setShowLoader] = useState(false) const [showTabLoader, setShowTabLoader] = useState(false) const [selectedIdWells, setSelectedIdWells] = useState([]) const [selectedSections, setSelectedSections] = useState([]) - useEffect(() => { - invokeWebApiWrapperAsync( - 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 { - const selected = await WellCompositeService.get(idWell) - setSelectedSections(arrayOrDefault(selected)) - } catch(e) { - setSelectedSections([]) - } - }, - setShowLoader, - 'Не удалось загрузить список скважин', - 'Получение списка скважин' - ) - }, [idWell]) + useEffect(() => invokeWebApiWrapperAsync( + async () => { + try { + const selected = await WellCompositeService.get(idWell) + setSelectedSections(arrayOrDefault(selected)) + } catch(e) { + setSelectedSections([]) + } + }, + setShowLoader, + 'Не удалось загрузить список скважин', + 'Получение списка скважин' + ), [idWell]) useEffect(() => { const wellIds = selectedSections.map((value) => value.idWellSrc) @@ -88,22 +59,10 @@ export const WellCompositeEditor = memo(({ idWell, rootPath }) => { - setSelectedIdWells(value)} - size={'middle'} - style={{ width: '100%' }} + ( - {wellLabels[props.value] ?? props.label} - )} - disabled={!hasPermission('WellOperation.edit')} />