forked from ddrilling/asb_cloud_front
Удалена пагинация
This commit is contained in:
parent
279b375ea9
commit
a60b73d408
@ -2,8 +2,7 @@ import { useState, useEffect } from 'react'
|
|||||||
|
|
||||||
import {
|
import {
|
||||||
makeColumn,
|
makeColumn,
|
||||||
makeNumericAvgRange,
|
makeNumericAvgRange
|
||||||
makeNumericStartEnd
|
|
||||||
} from '../../components/Table'
|
} from '../../components/Table'
|
||||||
import LoaderPortal from '../../components/LoaderPortal'
|
import LoaderPortal from '../../components/LoaderPortal'
|
||||||
import { invokeWebApiWrapperAsync } from '../../components/factory'
|
import { invokeWebApiWrapperAsync } from '../../components/factory'
|
||||||
@ -11,33 +10,24 @@ import { EditableTable, SelectFromDictionary } from '../../components/Table'
|
|||||||
import { DrillParamsService } from '../../services/api'
|
import { DrillParamsService } from '../../services/api'
|
||||||
import { dictionarySectionType, getByKeyOrReturnKey } from './dictionary'
|
import { dictionarySectionType, getByKeyOrReturnKey } from './dictionary'
|
||||||
|
|
||||||
const basePageSize = 160;
|
|
||||||
|
|
||||||
|
|
||||||
export const WellDrillParams = ({idWell}) => {
|
export const WellDrillParams = ({idWell}) => {
|
||||||
const [pageNumAndPageSize, setPageNumAndPageSize] = useState({current:1, pageSize:basePageSize})
|
|
||||||
const [paginationTotal, setPaginationTotal] = useState(0)
|
|
||||||
const [params, setParams] = useState([])
|
const [params, setParams] = useState([])
|
||||||
const [showLoader, setShowLoader] = useState(false)
|
const [showLoader, setShowLoader] = useState(false)
|
||||||
|
|
||||||
const updatePrograms = () => invokeWebApiWrapperAsync(
|
const updateParams = () => invokeWebApiWrapperAsync(
|
||||||
async () => {
|
async () => {
|
||||||
const skip = ((pageNumAndPageSize.current - 1) * pageNumAndPageSize.pageSize) || 0
|
const params = await DrillParamsService.getAll(idWell)
|
||||||
const take = pageNumAndPageSize.pageSize
|
|
||||||
const paginatedParams = await DrillParamsService.getParams(idWell, skip, take)
|
|
||||||
const params = paginatedParams?.items ?? []
|
|
||||||
setParams(params)
|
setParams(params)
|
||||||
const total = paginatedParams.count?? paginatedParams.items?.length ?? 0
|
|
||||||
setPaginationTotal(total)
|
|
||||||
},
|
},
|
||||||
setShowLoader,
|
setShowLoader,
|
||||||
'Не удалось загрузить список режимов бурения скважины'
|
'Не удалось загрузить список режимов бурения скважины'
|
||||||
)
|
)
|
||||||
|
|
||||||
useEffect(updatePrograms, [idWell, pageNumAndPageSize])
|
useEffect(updateParams, [idWell])
|
||||||
|
|
||||||
const columns = [
|
const columns = [
|
||||||
makeColumn('Конструкция секции','id_wellsection_type', {
|
makeColumn('Конструкция секции','idWellSectionType', {
|
||||||
editable:true,
|
editable:true,
|
||||||
input:<SelectFromDictionary dictionary={dictionarySectionType}/>,
|
input:<SelectFromDictionary dictionary={dictionarySectionType}/>,
|
||||||
width:160,
|
width:160,
|
||||||
@ -46,29 +36,28 @@ export const WellDrillParams = ({idWell}) => {
|
|||||||
// makeNumericStartEnd('Глубина', 'depth'),
|
// makeNumericStartEnd('Глубина', 'depth'),
|
||||||
makeNumericAvgRange('Нагрузка', 'axialLoad'),
|
makeNumericAvgRange('Нагрузка', 'axialLoad'),
|
||||||
makeNumericAvgRange('Давление', 'pressure'),
|
makeNumericAvgRange('Давление', 'pressure'),
|
||||||
makeNumericAvgRange('Момент на ВПС', 'topDriveTorque'),
|
makeNumericAvgRange('Момент на ВПС', 'rotorTorque'),
|
||||||
makeNumericAvgRange('Обороты на ВПС', 'topDriveSpeed'),
|
makeNumericAvgRange('Обороты на ВПС', 'rotorSpeed'),
|
||||||
makeNumericAvgRange('Расход', 'flow')
|
makeNumericAvgRange('Расход', 'flow')
|
||||||
]
|
]
|
||||||
|
|
||||||
const onAdd = async (param) => {
|
const onAdd = async (param) => {
|
||||||
if (!param.id) return
|
param.idWell = idWell
|
||||||
// TODO: Add row
|
await DrillParamsService.save(idWell, param)
|
||||||
await DrillParamsService.saveDrillParams(idWell, param)
|
updateParams()
|
||||||
updatePrograms()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const onEdit = async (param) => {
|
const onEdit = async (param) => {
|
||||||
if (!param.id) return
|
if (!param.id) return
|
||||||
// TODO: Edit row
|
param.idWell = idWell
|
||||||
await DrillParamsService.update(idWell, param.id, param)
|
await DrillParamsService.update(idWell, param)
|
||||||
updatePrograms()
|
updateParams()
|
||||||
}
|
}
|
||||||
|
|
||||||
const onDelete = async (param) => {
|
const onDelete = async (param) => {
|
||||||
if (!param.id) return
|
if (!param.id) return
|
||||||
await DrillParamsService.delete(idWell, param.id)
|
await DrillParamsService.delete(idWell, param.id)
|
||||||
updatePrograms()
|
updateParams()
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@ -78,16 +67,9 @@ export const WellDrillParams = ({idWell}) => {
|
|||||||
bordered
|
bordered
|
||||||
columns={columns}
|
columns={columns}
|
||||||
dataSource={params}
|
dataSource={params}
|
||||||
//onRowAdd={onAdd}
|
onRowAdd={onAdd}
|
||||||
onRowEdit={onEdit}
|
onRowEdit={onEdit}
|
||||||
onRowDelete={onDelete}
|
onRowDelete={onDelete}
|
||||||
pagination={{
|
|
||||||
current: pageNumAndPageSize.current,
|
|
||||||
pageSize: pageNumAndPageSize.pageSize,
|
|
||||||
showSizeChanger: false,
|
|
||||||
total: paginationTotal,
|
|
||||||
onChange: (page, pageSize) => setPageNumAndPageSize({current: page, pageSize: pageSize})
|
|
||||||
}}
|
|
||||||
/>
|
/>
|
||||||
</LoaderPortal>
|
</LoaderPortal>
|
||||||
)
|
)
|
||||||
|
Loading…
Reference in New Issue
Block a user