From ef718900231c248b4c740ca5cf18744514729f2b Mon Sep 17 00:00:00 2001 From: goodmice Date: Tue, 12 Oct 2021 11:10:33 +0500 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=D0=B0=20=D1=81=D1=82=D1=80=D0=B0=D0=BD=D0=B8=D1=86=D0=B0?= =?UTF-8?q?=20=D1=81=20=D1=80=D0=B5=D0=B6=D0=B8=D0=BC=D0=B0=D0=BC=D0=B8=20?= =?UTF-8?q?=D0=B1=D1=83=D1=80=D0=B5=D0=BD=D0=B8=D1=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/Table/index.ts | 25 ++++- .../WellOperations/WellOpeationsModes.jsx | 94 +++++++++++++++++++ src/pages/WellOperations/index.jsx | 7 ++ 3 files changed, 121 insertions(+), 5 deletions(-) create mode 100644 src/pages/WellOperations/WellOpeationsModes.jsx diff --git a/src/components/Table/index.ts b/src/components/Table/index.ts index a4363a5..8575a03 100644 --- a/src/components/Table/index.ts +++ b/src/components/Table/index.ts @@ -148,7 +148,7 @@ export const defaultNumericRender = (value: any, row: object) => { export const makeNumericColumn = (title: string, dataIndex: string, filters: object[], filterDelegate: (key: string | number) => any, - renderDelegate: (_: any, row: object) => any, width: string) => ({ + renderDelegate: (_: any, row: object) => any, width: string, other?: columnPropsOther) => ({ title: title, dataIndex: dataIndex, key: dataIndex, @@ -157,7 +157,8 @@ export const makeNumericColumn = (title: string, dataIndex: string, sorter: makeNumericSorter(dataIndex), width: width, render: renderDelegate??defaultNumericRender, - align: 'right' + align: 'right', + ...other }) export const makeNumericColumnPlanFact = (title: string, dataIndex: string, filters: object[], @@ -167,17 +168,31 @@ export const makeNumericColumnPlanFact = (title: string, dataIndex: string, filt makeNumericColumn('ф', dataIndex + 'Fact', filters, filterDelegate, renderDelegate, width), ]) +export const makeNumericStartEnd = ( + title: string, + dataIndex: string, + editable: boolean, + filters: object[], + filterDelegate: (key: string | number) => any, + renderDelegate: (_: any, row: object) => any, + width: string, +) => makeGroupColumn( title, [ + makeNumericColumn('старт', dataIndex + '_start', filters, filterDelegate, renderDelegate, width, {editable}), + makeNumericColumn('конец', dataIndex + '_end', filters, filterDelegate, renderDelegate, width, {editable}) +]) + export const makeNumericAvgRange = ( title: string, dataIndex: string, + editable: boolean, filters: object[], filterDelegate: (key: string | number) => any, renderDelegate: (_: any, row: object) => any, width: string ) => makeGroupColumn( title, [ - makeNumericColumn('мин', dataIndex + 'Min', filters, filterDelegate, renderDelegate, width), - makeNumericColumn('макс', dataIndex + 'Max', filters, filterDelegate, renderDelegate, width), - makeNumericColumn('сред', dataIndex + 'Avg', filters, filterDelegate, renderDelegate, width) + makeNumericColumn('мин', dataIndex + '_min', filters, filterDelegate, renderDelegate, width, {editable}), + makeNumericColumn('сред', dataIndex + '_avg', filters, filterDelegate, renderDelegate, width, {editable}), + makeNumericColumn('макс', dataIndex + '_max', filters, filterDelegate, renderDelegate, width, {editable}) ]) type PaginationContainer = { diff --git a/src/pages/WellOperations/WellOpeationsModes.jsx b/src/pages/WellOperations/WellOpeationsModes.jsx new file mode 100644 index 0000000..42850df --- /dev/null +++ b/src/pages/WellOperations/WellOpeationsModes.jsx @@ -0,0 +1,94 @@ +import { useState, useEffect } from 'react' + +import { + makeColumn, + makeNumericAvgRange, + makeNumericStartEnd +} from '../../components/Table' +import LoaderPortal from '../../components/LoaderPortal' +import { invokeWebApiWrapperAsync } from '../../components/factory' +import { EditableTable, SelectFromDictionary } from '../../components/Table' +import { DrillingParamsService } from '../../services/api' +import { dictionarySectionType, getByKeyOrReturnKey } from './dictionary' + +const basePageSize = 160; + + +export const WellOpeationsModes = ({idWell}) => { + const [pageNumAndPageSize, setPageNumAndPageSize] = useState({current:1, pageSize:basePageSize}) + const [paginationTotal, setPaginationTotal] = useState(0) + const [params, setParams] = useState([]) + const [showLoader, setShowLoader] = useState(false) + + const updatePrograms = () => invokeWebApiWrapperAsync( + async () => { + const skip = ((pageNumAndPageSize.current - 1) * pageNumAndPageSize.pageSize) || 0 + const take = pageNumAndPageSize.pageSize + const paginatedParams = await DrillingParamsService.getParams(idWell, skip, take) + const params = paginatedParams?.items ?? [] + setParams(params) + const total = paginatedParams.count?? paginatedParams.items?.length ?? 0 + setPaginationTotal(total) + }, + setShowLoader, + 'Не удалось загрузить список режимов бурения скважины' + ) + + useEffect(updatePrograms, [idWell, pageNumAndPageSize]) + + const columns = [ + makeColumn('Конструкция секции','id_wellsection_type', { + editable:true, + input:, + width:160, + render:(_, record)=>getByKeyOrReturnKey(dictionarySectionType, record.idWellSectionType) + }), + makeNumericStartEnd('Глубина', 'depth', true), + makeNumericAvgRange('Нагрузка', 'axial_load', true), + makeNumericAvgRange('Давление', 'pressure', true), + makeNumericAvgRange('Момент на ВПС', 'rotor_torque', true), + makeNumericAvgRange('Обороты на ВПС', 'rotor_speed', true), + makeNumericAvgRange('Расход', 'flow', true) + ] + + const onAdd = async (param) => { + if (!param.id) return + // TODO: Add row + await DrillingParamsService.insertRange(idWell, [param]) + updatePrograms() + } + + const onEdit = async (param) => { + if (!param.id) return + // TODO: Edit row + await DrillingParamsService.update(idWell, param.id, param) + updatePrograms() + } + + const onDelete = async (param) => { + if (!param.id) return + await DrillingParamsService.delete(idWell, param.id) + updatePrograms() + } + + return ( + + setPageNumAndPageSize({current: page, pageSize: pageSize}) + }} + /> + + ) +} diff --git a/src/pages/WellOperations/index.jsx b/src/pages/WellOperations/index.jsx index ba226e9..e3f5ac3 100644 --- a/src/pages/WellOperations/index.jsx +++ b/src/pages/WellOperations/index.jsx @@ -4,6 +4,7 @@ import { FolderOutlined } from "@ant-design/icons"; import { WellOperationsEditor } from './WellOperationsEditor' import { WellSectionsStat } from './WellSectionsStat' import { Tvd } from './Tvd' +import { WellOpeationsModes } from './WellOpeationsModes' const { Content } = Layout @@ -29,6 +30,9 @@ export default function WellOperations({idWell}) { }> Факт + }> + Режимы + @@ -45,6 +49,9 @@ export default function WellOperations({idWell}) { + + +