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()
}