forked from ddrilling/asb_cloud_front
Импорт/экспорт на план/факт перенесён справа от крошек
This commit is contained in:
parent
2072ac2072
commit
dcd37177a1
@ -3,7 +3,7 @@ import { Input } from 'antd'
|
|||||||
import { useLocation } from 'react-router-dom'
|
import { useLocation } from 'react-router-dom'
|
||||||
import { useState, useEffect, memo, useMemo, useCallback } from 'react'
|
import { useState, useEffect, memo, useMemo, useCallback } from 'react'
|
||||||
|
|
||||||
import { useWell } from '@asb/context'
|
import { useTopRightBlock, useWell } from '@asb/context'
|
||||||
import {
|
import {
|
||||||
EditableTable,
|
EditableTable,
|
||||||
makeColumn,
|
makeColumn,
|
||||||
@ -15,7 +15,6 @@ import {
|
|||||||
makeNumericSorter,
|
makeNumericSorter,
|
||||||
makeTextColumn,
|
makeTextColumn,
|
||||||
} from '@components/Table'
|
} from '@components/Table'
|
||||||
import { Flex } from '@components/Grid'
|
|
||||||
import LoaderPortal from '@components/LoaderPortal'
|
import LoaderPortal from '@components/LoaderPortal'
|
||||||
import { invokeWebApiWrapperAsync } from '@components/factory'
|
import { invokeWebApiWrapperAsync } from '@components/factory'
|
||||||
import { arrayOrDefault } from '@utils'
|
import { arrayOrDefault } from '@utils'
|
||||||
@ -61,6 +60,7 @@ export const WellOperationsEditor = memo(({ idType, showNpt, ...other }) => {
|
|||||||
const [showLoader, setShowLoader] = useState(false)
|
const [showLoader, setShowLoader] = useState(false)
|
||||||
|
|
||||||
const [well] = useWell()
|
const [well] = useWell()
|
||||||
|
const setTopRightBlock = useTopRightBlock()
|
||||||
|
|
||||||
const [categories, setCategories] = useState([])
|
const [categories, setCategories] = useState([])
|
||||||
const [sectionTypes, setSectionTypes] = useState([])
|
const [sectionTypes, setSectionTypes] = useState([])
|
||||||
@ -73,21 +73,6 @@ export const WellOperationsEditor = memo(({ idType, showNpt, ...other }) => {
|
|||||||
return arrayOrDefault(query.get('selectedId')?.split(',')?.map(parseInt))
|
return arrayOrDefault(query.get('selectedId')?.split(',')?.map(parseInt))
|
||||||
}, [location])
|
}, [location])
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
invokeWebApiWrapperAsync(
|
|
||||||
async () => {
|
|
||||||
const categories = arrayOrDefault(await WellOperationService.getCategories(well.id))
|
|
||||||
setCategories(categories.map((item) => ({ value: item.id, label: item.name })))
|
|
||||||
|
|
||||||
const sectionTypes = Object.entries(await WellOperationService.getSectionTypes(well.id) ?? {})
|
|
||||||
setSectionTypes(sectionTypes.map(([id, label]) => ({ value: parseInt(id), label })))
|
|
||||||
},
|
|
||||||
setShowLoader,
|
|
||||||
`Не удалось загрузить список операций`,
|
|
||||||
{ actionName: 'Получение списка операций по скважине', well }
|
|
||||||
)
|
|
||||||
}, [well])
|
|
||||||
|
|
||||||
const updateOperations = useCallback(() => invokeWebApiWrapperAsync(
|
const updateOperations = useCallback(() => invokeWebApiWrapperAsync(
|
||||||
async () => {
|
async () => {
|
||||||
const skip = ((pageNumAndPageSize.current - 1) * pageNumAndPageSize.pageSize) || 0
|
const skip = ((pageNumAndPageSize.current - 1) * pageNumAndPageSize.pageSize) || 0
|
||||||
@ -105,10 +90,6 @@ export const WellOperationsEditor = memo(({ idType, showNpt, ...other }) => {
|
|||||||
{ actionName: 'Получение списка операций', well }
|
{ actionName: 'Получение списка операций', well }
|
||||||
), [well, idType, pageNumAndPageSize])
|
), [well, idType, pageNumAndPageSize])
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
updateOperations()
|
|
||||||
}, [updateOperations])
|
|
||||||
|
|
||||||
const onRow = useCallback((record) => {
|
const onRow = useCallback((record) => {
|
||||||
if (selectedIds?.includes(record.id))
|
if (selectedIds?.includes(record.id))
|
||||||
return { style: { background: '#BF0000A0' } }
|
return { style: { background: '#BF0000A0' } }
|
||||||
@ -138,11 +119,33 @@ export const WellOperationsEditor = memo(({ idType, showNpt, ...other }) => {
|
|||||||
}
|
}
|
||||||
}, [updateOperations, well.id, recordParser])
|
}, [updateOperations, well.id, recordParser])
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
updateOperations()
|
||||||
|
}, [updateOperations])
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
invokeWebApiWrapperAsync(
|
||||||
|
async () => {
|
||||||
|
const categories = arrayOrDefault(await WellOperationService.getCategories(well.id))
|
||||||
|
setCategories(categories.map((item) => ({ value: item.id, label: item.name })))
|
||||||
|
|
||||||
|
const sectionTypes = Object.entries(await WellOperationService.getSectionTypes(well.id) ?? {})
|
||||||
|
setSectionTypes(sectionTypes.map(([id, label]) => ({ value: parseInt(id), label })))
|
||||||
|
},
|
||||||
|
setShowLoader,
|
||||||
|
`Не удалось загрузить список операций`,
|
||||||
|
{ actionName: 'Получение списка операций по скважине', well }
|
||||||
|
)
|
||||||
|
}, [well])
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
setTopRightBlock(
|
||||||
|
<ImportExportBar onImported={updateOperations} />
|
||||||
|
)
|
||||||
|
}, [well, setTopRightBlock, updateOperations])
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<LoaderPortal show={showLoader}>
|
<LoaderPortal show={showLoader}>
|
||||||
<Flex style={{ width: '100%' }}>
|
|
||||||
<ImportExportBar onImported={updateOperations}/>
|
|
||||||
</Flex>
|
|
||||||
<EditableTable
|
<EditableTable
|
||||||
{...other}
|
{...other}
|
||||||
bordered
|
bordered
|
||||||
|
Loading…
Reference in New Issue
Block a user