forked from ddrilling/asb_cloud_front
Добавлена кнопка скачивания "Выгрузка расширенной автоформируемой РТК"
This commit is contained in:
parent
923d469a86
commit
d36cd1acbd
@ -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 {
|
import {
|
||||||
EditableTable,
|
EditableTable,
|
||||||
makeGroupColumn,
|
makeGroupColumn,
|
||||||
@ -11,10 +13,31 @@ import {
|
|||||||
makeSelectColumn,
|
makeSelectColumn,
|
||||||
} from '@components/Table'
|
} from '@components/Table'
|
||||||
import LoaderPortal from '@components/LoaderPortal'
|
import LoaderPortal from '@components/LoaderPortal'
|
||||||
import { invokeWebApiWrapperAsync } from '@components/factory'
|
import { invokeWebApiWrapperAsync, download } from '@components/factory'
|
||||||
import { ProcessMapService, WellOperationService } from '@api'
|
import { ProcessMapService, WellOperationService } from '@api'
|
||||||
import { arrayOrDefault } from '@utils'
|
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 (
|
||||||
|
<div>
|
||||||
|
<Tooltip title={'Выгрузка расширенной автоформируемой РТК'}>
|
||||||
|
<Button disabled={disabled} icon={<FileOutlined />} style={style} onClick={downloadExport} />
|
||||||
|
</Tooltip>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
})
|
||||||
|
|
||||||
const numericRender = makeNumericRender(2)
|
const numericRender = makeNumericRender(2)
|
||||||
|
|
||||||
export const getColumns = async (idWell) => {
|
export const getColumns = async (idWell) => {
|
||||||
@ -25,7 +48,7 @@ export const getColumns = async (idWell) => {
|
|||||||
}))
|
}))
|
||||||
|
|
||||||
return [
|
return [
|
||||||
makeSelectColumn('Конструкция секции','idWellSectionType', sectionTypes, null, {
|
makeSelectColumn('Конструкция секции', 'idWellSectionType', sectionTypes, null, {
|
||||||
width: 160,
|
width: 160,
|
||||||
sorter: makeNumericSorter('idWellSectionType'),
|
sorter: makeNumericSorter('idWellSectionType'),
|
||||||
}),
|
}),
|
||||||
@ -48,16 +71,21 @@ export const DrillProcessFlow = memo(() => {
|
|||||||
const [columns, setColumns] = useState([])
|
const [columns, setColumns] = useState([])
|
||||||
|
|
||||||
const [well] = useWell()
|
const [well] = useWell()
|
||||||
|
const setTopRightBlock = useTopRightBlock()
|
||||||
|
|
||||||
const updateFlows = useCallback(() => invokeWebApiWrapperAsync(
|
const updateFlows = useCallback(
|
||||||
|
() =>
|
||||||
|
invokeWebApiWrapperAsync(
|
||||||
async () => {
|
async () => {
|
||||||
const flows = await ProcessMapService.getByIdWell(well.id)
|
const flows = await ProcessMapService.getByIdWell(well.id)
|
||||||
setFlows(arrayOrDefault(flows))
|
setFlows(arrayOrDefault(flows))
|
||||||
},
|
},
|
||||||
setShowLoader,
|
setShowLoader,
|
||||||
`Не удалось загрузить режимно-технологическую карту`,
|
`Не удалось загрузить режимно-технологическую карту`,
|
||||||
{ actionName: 'Получение режимно-технологической карты', well },
|
{ actionName: 'Получение режимно-технологической карты', well }
|
||||||
), [well])
|
),
|
||||||
|
[well]
|
||||||
|
)
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
invokeWebApiWrapperAsync(
|
invokeWebApiWrapperAsync(
|
||||||
@ -67,7 +95,7 @@ export const DrillProcessFlow = memo(() => {
|
|||||||
},
|
},
|
||||||
setShowLoader,
|
setShowLoader,
|
||||||
`Не удалось загрузить список конструкций секций`,
|
`Не удалось загрузить список конструкций секций`,
|
||||||
{ actionName: 'Получение списка конструкций секций', well },
|
{ actionName: 'Получение списка конструкций секций', well }
|
||||||
)
|
)
|
||||||
}, [well])
|
}, [well])
|
||||||
|
|
||||||
@ -75,6 +103,8 @@ export const DrillProcessFlow = memo(() => {
|
|||||||
updateFlows()
|
updateFlows()
|
||||||
}, [well])
|
}, [well])
|
||||||
|
|
||||||
|
useEffect(() => setTopRightBlock((well) => <ImportExportBar well={well} />), [setTopRightBlock])
|
||||||
|
|
||||||
const tableHandlers = useMemo(() => {
|
const tableHandlers = useMemo(() => {
|
||||||
const handlerProps = {
|
const handlerProps = {
|
||||||
service: ProcessMapService,
|
service: ProcessMapService,
|
||||||
@ -88,7 +118,12 @@ export const DrillProcessFlow = memo(() => {
|
|||||||
return {
|
return {
|
||||||
add: { ...handlerProps, action: 'insert', actionName: 'Добавление месторождения', recordParser },
|
add: { ...handlerProps, action: 'insert', actionName: 'Добавление месторождения', recordParser },
|
||||||
edit: { ...handlerProps, action: 'update', 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])
|
}, [updateFlows, well.id])
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user