From 2f6a776eb994c2fabea3bd9d49f50a10d7a6188d Mon Sep 17 00:00:00 2001 From: goodmice Date: Thu, 14 Oct 2021 16:56:29 +0500 Subject: [PATCH] =?UTF-8?q?=D0=A1=D0=BE=D1=85=D1=80=D0=B0=D0=BD=D0=B5?= =?UTF-8?q?=D0=BD=D0=B8=D0=B5=20=D0=B2=D1=8B=D0=B1=D1=80=D0=B0=D0=BD=D0=BD?= =?UTF-8?q?=D1=8B=D1=85=20=D1=81=D0=B5=D0=BA=D1=86=D0=B8=D0=B9=20=D0=B4?= =?UTF-8?q?=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5=D0=BD=D0=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../WellCompositeSections.jsx | 27 ++++++++++++++----- .../WellCompositeEditor/index.jsx | 21 +++++++-------- src/pages/WellOperations/WellDrillParams.jsx | 4 +-- 3 files changed, 32 insertions(+), 20 deletions(-) diff --git a/src/pages/WellOperations/WellCompositeEditor/WellCompositeSections.jsx b/src/pages/WellOperations/WellCompositeEditor/WellCompositeSections.jsx index a2582b8..021f842 100644 --- a/src/pages/WellOperations/WellCompositeEditor/WellCompositeSections.jsx +++ b/src/pages/WellOperations/WellCompositeEditor/WellCompositeSections.jsx @@ -15,7 +15,7 @@ import { getOperations } from '../../Cluster/functions' import ChartTvD from '../ChartTvD' -import { DrillParamsService } from '../../../services/api' +import { DrillParamsService, WellCompositeService } from '../../../services/api' import LoaderPortal from '../../../components/LoaderPortal' import WellOperationsTable from '../../Cluster/WellOperationsTable' import { invokeWebApiWrapperAsync } from '../../../components/factory' @@ -73,6 +73,7 @@ export const WellCompositeSections = ({idWell, statsWells, selectedSections}) => let row = { key: well.caption + section.id, id: well.id, + sectionId: section.id, caption: well.caption, sectionType: section.caption, sectionWellDepthPlan: section.plan?.wellDepthEnd, @@ -121,8 +122,13 @@ export const WellCompositeSections = ({idWell, statsWells, selectedSections}) => }, [statsWells]) useEffect(() => { - - }, [selectedSections]) + const selected = rows.filter((row) => selectedSections.some(section => ( + section.idWellSrc === row.id && section.idWellSectionType === row.sectionId + ))) + + setSelectedWells(selected) + setSelectedWellsKeys(selected.map((row) => row.key)) + }, [rows, selectedSections]) const columns = [ makeTextColumn("скв №", "caption", null, null, @@ -178,10 +184,17 @@ export const WellCompositeSections = ({idWell, statsWells, selectedSections}) => const rowSelection = { selectedRowKeys: selectedWellsKeys, - onChange: (keys, items) => { - setSelectedWells(items) - setSelectedWellsKeys(keys) - }, + onChange: (keys, items) => invokeWebApiWrapperAsync( + async () => { + const selectedSections = items.map((row) => ({idWell, idWellSrc: row.id, idWellSectionType: row.sectionId})) + await WellCompositeService.save(idWell, selectedSections) + + setSelectedWells(items) + setSelectedWellsKeys(keys) + }, + setShowLoader, + 'Не удалось сохранить изменения выбранных секций для композитной скважины' + ) } const onParamButtonClick = () => invokeWebApiWrapperAsync( diff --git a/src/pages/WellOperations/WellCompositeEditor/index.jsx b/src/pages/WellOperations/WellCompositeEditor/index.jsx index 2ceae7d..37bb544 100644 --- a/src/pages/WellOperations/WellCompositeEditor/index.jsx +++ b/src/pages/WellOperations/WellCompositeEditor/index.jsx @@ -17,7 +17,6 @@ export const WellCompositeEditor = ({idWell}) => { const [wellsTree, setWellsTree] = useState([]) const [showLoader, setShowLoader] = useState(false) const [showTabLoader, setShowTabLoader] = useState(false) - const [selectedWells, setSelectedWells] = useState([]) const [selectedIdWells, setSelectedIdWells] = useState([]) const [statsWells, setStatsWells] = useState([]) const [selectedSections, setSelectedSections] = useState([]) @@ -62,6 +61,11 @@ export const WellCompositeEditor = ({idWell}) => { ) }, [idWell]) + useEffect(() => { + const wellIds = selectedSections.map((value) => value.idWellSrc) + setSelectedIdWells(wellIds) + }, [selectedSections]) + useEffect(() => invokeWebApiWrapperAsync( async () => { const stats = await WellOperationStatService.getWellsStat(selectedIdWells) @@ -71,13 +75,6 @@ export const WellCompositeEditor = ({idWell}) => { 'Не удалось загрузить статистику по скважинам/секциям' ), [selectedIdWells]) - const onWellChanged = (value) => { - setSelectedWells(value) - setSelectedIdWells(value) - } - - const tagRender = (props) => {wellLabels[props.value] ?? props.label} - return ( @@ -89,12 +86,14 @@ export const WellCompositeEditor = ({idWell}) => { treeDefaultExpandAll treeData={wellsTree} treeLine={{showLeafIcon: false}} - onChange={onWellChanged} + onChange={(value) => setSelectedIdWells(value)} size={'middle'} style={{width: '100%'}} - value={selectedWells} + value={selectedIdWells} placeholder={'Выберите скважины'} - tagRender={tagRender} + tagRender={(props) => ( + {wellLabels[props.value] ?? props.label} + )} /> diff --git a/src/pages/WellOperations/WellDrillParams.jsx b/src/pages/WellOperations/WellDrillParams.jsx index 6fbbc00..a36df85 100644 --- a/src/pages/WellOperations/WellDrillParams.jsx +++ b/src/pages/WellOperations/WellDrillParams.jsx @@ -43,14 +43,14 @@ export const WellDrillParams = ({idWell}) => { const onAdd = async (param) => { param.idWell = idWell - await DrillParamsService.save(idWell, param) + await DrillParamsService.insert(idWell, param) updateParams() } const onEdit = async (param) => { if (!param.id) return param.idWell = idWell - await DrillParamsService.edit(idWell, param) + await DrillParamsService.update(idWell, param.id, param) updateParams() }