forked from ddrilling/asb_cloud_front
Сохранение выбранных секций добавлено
This commit is contained in:
parent
58707c1665
commit
2f6a776eb9
@ -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(() => {
|
||||
const selected = rows.filter((row) => selectedSections.some(section => (
|
||||
section.idWellSrc === row.id && section.idWellSectionType === row.sectionId
|
||||
)))
|
||||
|
||||
}, [selectedSections])
|
||||
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) => {
|
||||
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(
|
||||
|
@ -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) => <Tag {...props}>{wellLabels[props.value] ?? props.label}</Tag>
|
||||
|
||||
return (
|
||||
<LoaderPortal show={showLoader}>
|
||||
<Row align={'middle'} justify={'space-between'} wrap={false}>
|
||||
@ -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) => (
|
||||
<Tag {...props}>{wellLabels[props.value] ?? props.label}</Tag>
|
||||
)}
|
||||
/>
|
||||
</Col>
|
||||
<Col span={6}>
|
||||
|
@ -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()
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user