From dcd37177a175dd83e1f8a56eb24c5a69a84ac3b7 Mon Sep 17 00:00:00 2001 From: goodmice Date: Tue, 25 Oct 2022 19:00:14 +0500 Subject: [PATCH] =?UTF-8?q?=D0=98=D0=BC=D0=BF=D0=BE=D1=80=D1=82/=D1=8D?= =?UTF-8?q?=D0=BA=D1=81=D0=BF=D0=BE=D1=80=D1=82=20=D0=BD=D0=B0=20=D0=BF?= =?UTF-8?q?=D0=BB=D0=B0=D0=BD/=D1=84=D0=B0=D0=BA=D1=82=20=D0=BF=D0=B5?= =?UTF-8?q?=D1=80=D0=B5=D0=BD=D0=B5=D1=81=D1=91=D0=BD=20=D1=81=D0=BF=D1=80?= =?UTF-8?q?=D0=B0=D0=B2=D0=B0=20=D0=BE=D1=82=20=D0=BA=D1=80=D0=BE=D1=88?= =?UTF-8?q?=D0=B5=D0=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../OperationEditor/WellOperationsEditor.jsx | 51 ++++++++++--------- 1 file changed, 27 insertions(+), 24 deletions(-) diff --git a/src/pages/Well/WellOperations/OperationEditor/WellOperationsEditor.jsx b/src/pages/Well/WellOperations/OperationEditor/WellOperationsEditor.jsx index ac23224..653ec16 100644 --- a/src/pages/Well/WellOperations/OperationEditor/WellOperationsEditor.jsx +++ b/src/pages/Well/WellOperations/OperationEditor/WellOperationsEditor.jsx @@ -3,7 +3,7 @@ import { Input } from 'antd' import { useLocation } from 'react-router-dom' import { useState, useEffect, memo, useMemo, useCallback } from 'react' -import { useWell } from '@asb/context' +import { useTopRightBlock, useWell } from '@asb/context' import { EditableTable, makeColumn, @@ -15,7 +15,6 @@ import { makeNumericSorter, makeTextColumn, } from '@components/Table' -import { Flex } from '@components/Grid' import LoaderPortal from '@components/LoaderPortal' import { invokeWebApiWrapperAsync } from '@components/factory' import { arrayOrDefault } from '@utils' @@ -61,6 +60,7 @@ export const WellOperationsEditor = memo(({ idType, showNpt, ...other }) => { const [showLoader, setShowLoader] = useState(false) const [well] = useWell() + const setTopRightBlock = useTopRightBlock() const [categories, setCategories] = useState([]) const [sectionTypes, setSectionTypes] = useState([]) @@ -73,21 +73,6 @@ export const WellOperationsEditor = memo(({ idType, showNpt, ...other }) => { return arrayOrDefault(query.get('selectedId')?.split(',')?.map(parseInt)) }, [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( async () => { const skip = ((pageNumAndPageSize.current - 1) * pageNumAndPageSize.pageSize) || 0 @@ -105,10 +90,6 @@ export const WellOperationsEditor = memo(({ idType, showNpt, ...other }) => { { actionName: 'Получение списка операций', well } ), [well, idType, pageNumAndPageSize]) - useEffect(() => { - updateOperations() - }, [updateOperations]) - const onRow = useCallback((record) => { if (selectedIds?.includes(record.id)) return { style: { background: '#BF0000A0' } } @@ -138,11 +119,33 @@ export const WellOperationsEditor = memo(({ idType, showNpt, ...other }) => { } }, [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( + + ) + }, [well, setTopRightBlock, updateOperations]) + return ( - - -