From d36cd1acbd3c043c35d3326f5158c23fbd9b70c6 Mon Sep 17 00:00:00 2001 From: "av.maiorov" Date: Mon, 19 Dec 2022 15:25:38 +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=D0=BA=D0=BD=D0=BE=D0=BF=D0=BA=D0=B0=20=D1=81?= =?UTF-8?q?=D0=BA=D0=B0=D1=87=D0=B8=D0=B2=D0=B0=D0=BD=D0=B8=D1=8F=20"?= =?UTF-8?q?=D0=92=D1=8B=D0=B3=D1=80=D1=83=D0=B7=D0=BA=D0=B0=20=D1=80=D0=B0?= =?UTF-8?q?=D1=81=D1=88=D0=B8=D1=80=D0=B5=D0=BD=D0=BD=D0=BE=D0=B9=20=D0=B0?= =?UTF-8?q?=D0=B2=D1=82=D0=BE=D1=84=D0=BE=D1=80=D0=BC=D0=B8=D1=80=D1=83?= =?UTF-8?q?=D0=B5=D0=BC=D0=BE=D0=B9=20=D0=A0=D0=A2=D0=9A"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Well/WellOperations/DrillProcessFlow.jsx | 65 ++++++++++++++----- 1 file changed, 50 insertions(+), 15 deletions(-) diff --git a/src/pages/Well/WellOperations/DrillProcessFlow.jsx b/src/pages/Well/WellOperations/DrillProcessFlow.jsx index a89ec3e..420cef1 100644 --- a/src/pages/Well/WellOperations/DrillProcessFlow.jsx +++ b/src/pages/Well/WellOperations/DrillProcessFlow.jsx @@ -1,6 +1,8 @@ -import { useState, useEffect, memo, useMemo, useCallback } from 'react' +import { useState, useEffect, memo, useMemo, useCallback, FC } from 'react' +import { Button, Tooltip } from 'antd' +import { FileOutlined } from '@ant-design/icons' -import { useWell } from '@asb/context' +import { useWell, useTopRightBlock } from '@asb/context' import { EditableTable, makeGroupColumn, @@ -11,10 +13,31 @@ import { makeSelectColumn, } from '@components/Table' import LoaderPortal from '@components/LoaderPortal' -import { invokeWebApiWrapperAsync } from '@components/factory' +import { invokeWebApiWrapperAsync, download } from '@components/factory' import { ProcessMapService, WellOperationService } from '@api' import { arrayOrDefault } from '@utils' + +const ImportExportBar = memo(({ well: givenWell, disabled }) => { + const style = { margin: 4 } + + const [wellContext] = useWell() + const well = useMemo(() => givenWell ?? wellContext, [givenWell, wellContext]) + + const downloadExport = useCallback( + async () => await download(`/api/ProcessMap/getReportFile/${well.id}`), + [well.id] + ) + + return ( +
+ +
+ ) +}) + const numericRender = makeNumericRender(2) export const getColumns = async (idWell) => { @@ -25,7 +48,7 @@ export const getColumns = async (idWell) => { })) return [ - makeSelectColumn('Конструкция секции','idWellSectionType', sectionTypes, null, { + makeSelectColumn('Конструкция секции', 'idWellSectionType', sectionTypes, null, { width: 160, sorter: makeNumericSorter('idWellSectionType'), }), @@ -48,16 +71,21 @@ export const DrillProcessFlow = memo(() => { const [columns, setColumns] = useState([]) const [well] = useWell() + const setTopRightBlock = useTopRightBlock() - const updateFlows = useCallback(() => invokeWebApiWrapperAsync( - async () => { - const flows = await ProcessMapService.getByIdWell(well.id) - setFlows(arrayOrDefault(flows)) - }, - setShowLoader, - `Не удалось загрузить режимно-технологическую карту`, - { actionName: 'Получение режимно-технологической карты', well }, - ), [well]) + const updateFlows = useCallback( + () => + invokeWebApiWrapperAsync( + async () => { + const flows = await ProcessMapService.getByIdWell(well.id) + setFlows(arrayOrDefault(flows)) + }, + setShowLoader, + `Не удалось загрузить режимно-технологическую карту`, + { actionName: 'Получение режимно-технологической карты', well } + ), + [well] + ) useEffect(() => { invokeWebApiWrapperAsync( @@ -67,7 +95,7 @@ export const DrillProcessFlow = memo(() => { }, setShowLoader, `Не удалось загрузить список конструкций секций`, - { actionName: 'Получение списка конструкций секций', well }, + { actionName: 'Получение списка конструкций секций', well } ) }, [well]) @@ -75,6 +103,8 @@ export const DrillProcessFlow = memo(() => { updateFlows() }, [well]) + useEffect(() => setTopRightBlock((well) => ), [setTopRightBlock]) + const tableHandlers = useMemo(() => { const handlerProps = { service: ProcessMapService, @@ -88,7 +118,12 @@ export const DrillProcessFlow = memo(() => { return { add: { ...handlerProps, action: 'insert', actionName: 'Добавление месторождения', recordParser }, edit: { ...handlerProps, action: 'update', actionName: 'Редактирование месторождения', recordParser }, - delete: { ...handlerProps, action: 'delete', actionName: 'Удаление месторождения', permission: 'DrillFlowChart.delete' }, + delete: { + ...handlerProps, + action: 'delete', + actionName: 'Удаление месторождения', + permission: 'DrillFlowChart.delete', + }, } }, [updateFlows, well.id])