From 76d7ac9949158f737b8925550a509091158d47e9 Mon Sep 17 00:00:00 2001 From: goodm2ice Date: Tue, 29 Mar 2022 17:03:04 +0500 Subject: [PATCH] =?UTF-8?q?=D0=98=D1=81=D0=BF=D1=80=D0=B0=D0=B2=D0=BB?= =?UTF-8?q?=D0=B5=D0=BD=D0=B0=20=D0=BE=D1=88=D0=B8=D0=B1=D0=BA=D0=B0=20?= =?UTF-8?q?=D0=BE=D1=82=D0=BE=D0=B1=D1=80=D0=B0=D0=B6=D0=B5=D0=BD=D0=B8?= =?UTF-8?q?=D1=8F=20=D0=BA=D0=BE=D0=BD=D1=81=D1=82=D1=80=D1=83=D0=BA=D1=86?= =?UTF-8?q?=D0=B8=D0=B8=20=D1=81=D0=B5=D0=BA=D1=86=D0=B8=D0=B8=20=D0=BF?= =?UTF-8?q?=D1=80=D0=B8=20=20=D1=81=D0=BE=D0=B7=D0=B4=D0=B0=D0=BD=D0=B8?= =?UTF-8?q?=D0=B8=20=D0=BA=D0=BE=D0=BC=D0=BF.=20=D1=81=D0=BA=D0=B2.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../WellCompositeEditor/NewParamsTable.jsx | 79 ++++++++++++++ .../WellCompositeSections.jsx | 101 ++++-------------- src/pages/WellOperations/WellDrillParams.jsx | 8 +- 3 files changed, 105 insertions(+), 83 deletions(-) create mode 100755 src/pages/Analytics/WellCompositeEditor/NewParamsTable.jsx diff --git a/src/pages/Analytics/WellCompositeEditor/NewParamsTable.jsx b/src/pages/Analytics/WellCompositeEditor/NewParamsTable.jsx new file mode 100755 index 0000000..6998087 --- /dev/null +++ b/src/pages/Analytics/WellCompositeEditor/NewParamsTable.jsx @@ -0,0 +1,79 @@ +import { memo, useCallback, useEffect, useState } from 'react' +import { Button, Modal, Popconfirm } from 'antd' + +import { Table } from '@components/Table' +import LoaderPortal from '@components/LoaderPortal' +import { invokeWebApiWrapperAsync } from '@components/factory' +import { DrillParamsService } from '@api' + +import { getColumns } from '@pages/WellOperations/WellDrillParams' + +export const NewParamsTable = memo(({ idWell, selectedWellsKeys }) => { + const [params, setParams] = useState([]) + const [paramsColumns, setParamsColumns] = useState([]) + const [showParamsLoader, setShowParamsLoader] = useState(false) + const [isParamsModalVisible, setIsParamsModalVisible] = useState(false) + + useEffect(() => invokeWebApiWrapperAsync( + async () => setParamsColumns(await getColumns(idWell)) + ), [idWell]) + + useEffect(() => console.log(paramsColumns), [paramsColumns]) + + const onParamButtonClick = useCallback(() => invokeWebApiWrapperAsync( + async () => { + setIsParamsModalVisible(true) + const params = await DrillParamsService.getCompositeAll(idWell) + setParams(params) + }, + setShowParamsLoader, + `Не удалось загрузить список режимов для скважины "${idWell}"`, + 'Получение списка режимов скважины' + ), [idWell]) + + const onParamsAddClick = useCallback(() => invokeWebApiWrapperAsync( + async () => { + await DrillParamsService.save(idWell, params) + setIsParamsModalVisible(false) + }, + setShowParamsLoader, + `Не удалось добавить режимы в список скважины "${idWell}"`, + 'Добавление режима скважины' + ), [idWell, params]) + + return ( + <> + + setIsParamsModalVisible(false)} + width={1700} + footer={( + + + + )} + > + + + + + + ) +}) + +export default NewParamsTable diff --git a/src/pages/Analytics/WellCompositeEditor/WellCompositeSections.jsx b/src/pages/Analytics/WellCompositeEditor/WellCompositeSections.jsx index 9dbe389..7e1505a 100755 --- a/src/pages/Analytics/WellCompositeEditor/WellCompositeSections.jsx +++ b/src/pages/Analytics/WellCompositeEditor/WellCompositeSections.jsx @@ -1,13 +1,13 @@ import { Link, useLocation } from 'react-router-dom' -import { useState, useEffect, memo, useCallback, useMemo } from 'react' +import { useState, useEffect, memo, useMemo } from 'react' import { LineChartOutlined, ProfileOutlined } from '@ant-design/icons' -import { Table, Tag, Button, Badge, Divider, Modal, Row, Col, Popconfirm } from 'antd' +import { Table, Tag, Button, Badge, Divider, Modal, Row, Col } from 'antd' import { CompanyView } from '@components/views' import LoaderPortal from '@components/LoaderPortal' import { invokeWebApiWrapperAsync } from '@components/factory' import { makeTextColumn, makeNumericColumnPlanFact } from '@components/Table' -import { DrillParamsService, WellCompositeService } from '@api' +import { WellCompositeService } from '@api' import { hasPermission } from '@utils/permissions' import { calcAndUpdateStatsBySections, @@ -16,9 +16,8 @@ import { } from '@utils/functions' import { Tvd } from '@pages/WellOperations/Tvd' -import { getColumns } from '@pages/WellOperations/WellDrillParams' import WellOperationsTable from '@pages/Cluster/WellOperationsTable' - +import NewParamsTable from './NewParamsTable' const filtersMinMax = [ { text: 'min', value: 'min' }, @@ -31,17 +30,13 @@ const filtersSectionsType = [] const DAY_IN_MS = 1000 * 60 * 60 * 24 export const WellCompositeSections = memo(({ idWell, statsWells, selectedSections }) => { - const [params, setParams] = useState([]) const [selectedWells, setSelectedWells] = useState([]) const [wellOperations, setWellOperations] = useState([]) const [selectedWellsKeys, setSelectedWellsKeys] = useState([]) const [selectedWellId, setSelectedWellId] = useState(0) const [showLoader, setShowLoader] = useState(false) - const [showParamsLoader, setShowParamsLoader] = useState(false) const [isTVDModalVisible, setIsTVDModalVisible] = useState(false) const [isOpsModalVisible, setIsOpsModalVisible] = useState(false) - const [isParamsModalVisible, setIsParamsModalVisible] = useState(false) - const [paramsColumns, setParamsColumns] = useState([]) const location = useLocation() @@ -103,10 +98,6 @@ export const WellCompositeSections = memo(({ idWell, statsWells, selectedSection return rows }, [statsWells]) - useEffect(() => invokeWebApiWrapperAsync( - async () => setParamsColumns(await getColumns(idWell)) - ), [idWell]) - useEffect(() => { if (isOpsModalVisible || selectedWellId <= 0) return invokeWebApiWrapperAsync( @@ -128,6 +119,22 @@ export const WellCompositeSections = memo(({ idWell, statsWells, selectedSection setSelectedWellsKeys(selected.map((row) => row.key)) }, [rows, selectedSections]) + const rowSelection = useMemo(() => hasPermission('WellOperation.edit') && { + selectedRowKeys: selectedWellsKeys, + 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, + `Не удалось сохранить изменения выбранных секций для композитной скважины "${idWell}"`, + 'Изменение выбранных секций скважины' + ) + }, [idWell, selectedWellsKeys]) + const columns = useMemo(() => [ makeTextColumn('скв №', 'caption', null, null, (text, item) => {text ?? '-'} @@ -176,43 +183,6 @@ export const WellCompositeSections = memo(({ idWell, statsWells, selectedSection }, ], [location.pathname]) - const rowSelection = useMemo(() => hasPermission('WellOperation.edit') && { - selectedRowKeys: selectedWellsKeys, - 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) - }, - setShowParamsLoader, - `Не удалось сохранить изменения выбранных секций для композитной скважины "${idWell}"`, - 'Изменение выбранных секций скважины' - ) - }, [idWell, selectedWellsKeys]) - - const onParamButtonClick = useCallback(() => invokeWebApiWrapperAsync( - async () => { - setIsParamsModalVisible(true) - const params = await DrillParamsService.getCompositeAll(idWell) - setParams(params) - }, - setShowParamsLoader, - `Не удалось загрузить список режимов для скважины "${idWell}"`, - 'Получение списка режимов скважины' - ), [idWell]) - - const onParamsAddClick = useCallback(() => invokeWebApiWrapperAsync( - async () => { - await DrillParamsService.save(idWell, params) - setIsParamsModalVisible(false) - }, - setShowLoader, - `Не удалось добавить режимы в список скважины "${idWell}"`, - 'Добавление режима скважины' - ), [idWell, params]) - return ( <>
- + @@ -272,29 +236,6 @@ export const WellCompositeSections = memo(({ idWell, statsWells, selectedSection - - setIsParamsModalVisible(false)} - width={1700} - footer={( - - - - )} - > - -
- - ) }) diff --git a/src/pages/WellOperations/WellDrillParams.jsx b/src/pages/WellOperations/WellDrillParams.jsx index 8db51b6..b113209 100755 --- a/src/pages/WellOperations/WellDrillParams.jsx +++ b/src/pages/WellOperations/WellDrillParams.jsx @@ -5,6 +5,7 @@ import { makeSelectColumn, makeActionHandler, makeNumericAvgRange, + makeNumericSorter, } from '@components/Table' import LoaderPortal from '@components/LoaderPortal' import { invokeWebApiWrapperAsync } from '@components/factory' @@ -14,15 +15,16 @@ import { arrayOrDefault } from '@utils' export const getColumns = async (idWell) => { let sectionTypes = await WellOperationService.getSectionTypes(idWell) - sectionTypes = Object.keys(sectionTypes).map((id) => ({ - label: sectionTypes[id], - value: id, + sectionTypes = Object.entries(sectionTypes).map(([id, value]) => ({ + label: value, + value: parseInt(id), })) return [ makeSelectColumn('Конструкция секции','idWellSectionType', sectionTypes, null, { editable: true, width: 160, + sorter: makeNumericSorter('idWellSectionType'), }), makeNumericAvgRange('Нагрузка, т', 'axialLoad', 1), makeNumericAvgRange('Давление, атм', 'pressure', 1),