forked from ddrilling/asb_cloud_front
Исправления страницы суточного рапорта
This commit is contained in:
parent
4df60c8d9d
commit
5ab2bf237f
@ -1,4 +1,4 @@
|
||||
import { DatePicker, Descriptions, Divider, Form, Input, InputNumber, Modal, Select, Space, Table } from 'antd'
|
||||
import { DatePicker, Descriptions, Form, Input, InputNumber, Modal, Table, Tabs } from 'antd'
|
||||
import { memo, useCallback, useEffect, useState } from 'react'
|
||||
import moment from 'moment'
|
||||
|
||||
@ -7,15 +7,11 @@ import LoaderPortal from '@components/LoaderPortal'
|
||||
import { invokeWebApiWrapperAsync } from '@components/factory'
|
||||
import { makeColumn, makeGroupColumn } from '@components/Table'
|
||||
import { DailyReportService } from '@api'
|
||||
import { Tabs } from 'antd'
|
||||
|
||||
const { Item: RawItem } = Form
|
||||
const { Summary } = Table
|
||||
const { TabPane } = Tabs
|
||||
|
||||
const onChange = (key) => {
|
||||
console.log(key)
|
||||
}
|
||||
const Item = memo(({ style, ...other }) => <RawItem style={{ margin: 0, ...style }} {...other} />)
|
||||
|
||||
const table1Columns = [
|
||||
@ -54,13 +50,30 @@ const table1Columns = [
|
||||
}),
|
||||
]),
|
||||
]
|
||||
|
||||
const names = [
|
||||
['head', ['wellName', 'clusterName','contractor','countLaunchesMSE','customer','bottomholeDepth','verticalDepth','firstDriller','secondDriller','zenithAngle','azimuthAngle','penetrationSAUB','penetrationSpinMaster','penetrationTorkMaster','secondDriller','wellDepthIntervalFinishDate','wellDepthIntervalStartDate','workTimeSAUB','workTimeSpinMaster','workTimeTorkMaster','reportDate']],
|
||||
['bha', ['bhaDescription','extensionDrillingOneBegin','extensionDrillingOneFinish','sluiceBegin','sluiceFinish','climbBegin','climbFinish','descentBegin','descentFinish','extensionDrillingTwoBegin','extensionDrillingTwoFinish']],
|
||||
['noDrilling', ['actualTimeBarrelPreparation','actualTimeExtension','standardTimeBarrelPreparation','standardTimeExtension']],
|
||||
['timeBalance', ['drilling','flushing','building','elaboration','extension','repair','knbk','spo','pzr','pzr','pgr','gis','ozc','engineeringWorks','takingMeasure','cementing','simple','npv']],
|
||||
['saub', ['avgDiffDropRotor','avgDiffPressureSlide','declinesReasonsROP','deviationFromTVD','drillingTimeInRotor','declinesReasonsROP','extensionsCount','extensionsCount','penetrationInRotor','penetrationInSlide','rotorDrillingModes','rotorSlidePercent','reductionTimeDrilling','increaseSpeedSection','increaseSpeedDay','sectionDrillingTimeTotal','sectionPenetrationTotal','sectionROPPlan','slideDrillingModes','mspSection']],
|
||||
['sign', ['drillingMaster','supervisor']],
|
||||
['head', [
|
||||
'wellName', 'clusterName', 'contractor', 'countLaunchesMSE', 'customer', 'bottomholeDepth', 'verticalDepth',
|
||||
'firstDriller', 'secondDriller', 'zenithAngle', 'azimuthAngle', 'penetrationSAUB', 'penetrationSpinMaster',
|
||||
'penetrationTorkMaster', 'secondDriller', 'wellDepthIntervalFinishDate', 'wellDepthIntervalStartDate',
|
||||
'workTimeSAUB', 'workTimeSpinMaster', 'workTimeTorkMaster', 'reportDate',
|
||||
]],
|
||||
['bha', [
|
||||
'bhaDescription', 'extensionDrillingOneBegin', 'extensionDrillingOneFinish', 'sluiceBegin', 'sluiceFinish',
|
||||
'climbBegin', 'climbFinish', 'descentBegin', 'descentFinish', 'extensionDrillingTwoBegin', 'extensionDrillingTwoFinish',
|
||||
]],
|
||||
['noDrilling', ['actualTimeBarrelPreparation', 'actualTimeExtension', 'standardTimeBarrelPreparation', 'standardTimeExtension']],
|
||||
['timeBalance', [
|
||||
'drilling', 'flushing', 'building', 'elaboration', 'extension', 'repair', 'knbk', 'spo', 'pzr', 'pzr', 'pgr', 'gis',
|
||||
'ozc', 'engineeringWorks', 'takingMeasure', 'cementing', 'simple', 'npv',
|
||||
]],
|
||||
['saub', [
|
||||
'avgDiffDropRotor', 'avgDiffPressureSlide', 'declinesReasonsROP', 'deviationFromTVD', 'drillingTimeInRotor',
|
||||
'declinesReasonsROP', 'extensionsCount', 'extensionsCount', 'penetrationInRotor', 'penetrationInSlide',
|
||||
'rotorDrillingModes', 'rotorSlidePercent', 'reductionTimeDrilling', 'increaseSpeedSection', 'increaseSpeedDay',
|
||||
'sectionDrillingTimeTotal', 'sectionPenetrationTotal', 'sectionROPPlan', 'slideDrillingModes', 'mspSection'
|
||||
]],
|
||||
['sign', ['drillingMaster', 'supervisor']],
|
||||
]
|
||||
|
||||
const cellData = {
|
||||
@ -233,6 +246,44 @@ const table2Summary = () => (
|
||||
</Summary.Row>
|
||||
)
|
||||
|
||||
const makeItem = (name, label) => ({ name, label })
|
||||
const renderDescriptions = (items) => items.map(({ name, label }) => (
|
||||
<Descriptions.Item label={label}>
|
||||
<Item name={name}>
|
||||
<Input style={{ width: '100%' }} />
|
||||
</Item>
|
||||
</Descriptions.Item>
|
||||
))
|
||||
|
||||
const tab1Items = [
|
||||
makeItem('wellName', 'Название скважины'),
|
||||
makeItem('clusterName', 'Название куста'),
|
||||
makeItem('customer', 'Заказчик'),
|
||||
makeItem('contractor', 'Подрядчик'),
|
||||
]
|
||||
|
||||
const tab4Items = [
|
||||
makeItem('drilling', 'Бурение'),
|
||||
makeItem('sectionDrillingTimeTotal', 'Время бурения за секцию'),
|
||||
makeItem('flushing', 'Промывка'),
|
||||
makeItem('building', 'Наращивание'),
|
||||
makeItem('elaboration', 'Проработка'),
|
||||
makeItem('extension', 'Расширка'),
|
||||
makeItem('repair', 'Ремонт'),
|
||||
makeItem('knbk', 'КНБК'),
|
||||
makeItem('spo', 'СПО'),
|
||||
makeItem('pzr', 'ПЗР'),
|
||||
makeItem('pvo', 'ПВО'),
|
||||
makeItem('pgr', 'ПГР'),
|
||||
makeItem('gis', 'ГИС'),
|
||||
makeItem('ozc', 'ОЗЦ'),
|
||||
makeItem('engineeringWorks', 'Тех. работы'),
|
||||
makeItem('takingMeasure', 'Снятие замера'),
|
||||
makeItem('cementing', 'Цементирование'),
|
||||
makeItem('simple', 'Простой'),
|
||||
makeItem('npv', 'НПВ'),
|
||||
]
|
||||
|
||||
export const ReportEditor = memo(({ visible, data, onDone, onCancel, checkIsDateBusy }) => {
|
||||
const [form] = Form.useForm()
|
||||
const [isInvalid, setIsInvalid] = useState(false)
|
||||
@ -240,69 +291,52 @@ export const ReportEditor = memo(({ visible, data, onDone, onCancel, checkIsDate
|
||||
|
||||
const idWell = useIdWell()
|
||||
|
||||
const setFields = useCallback(
|
||||
(data) =>
|
||||
form.setFieldsValue(
|
||||
data
|
||||
? {
|
||||
...data.head,
|
||||
...data.bha,
|
||||
...data.noDrilling,
|
||||
...data.timeBalance,
|
||||
...data.saub,
|
||||
...data.sign,
|
||||
reportDate: moment.utc(data.head.reportDate).local(),
|
||||
}
|
||||
: {}
|
||||
),
|
||||
[form]
|
||||
)
|
||||
const setFields = useCallback((data) =>
|
||||
form.setFieldsValue(data ? {
|
||||
...data.head,
|
||||
...data.bha,
|
||||
...data.noDrilling,
|
||||
...data.timeBalance,
|
||||
...data.saub,
|
||||
...data.sign,
|
||||
reportDate: moment.utc(data.head.reportDate).local(),
|
||||
} : {})
|
||||
, [form])
|
||||
|
||||
useEffect(() => setFields(data), [data, setFields])
|
||||
|
||||
const onFormChange = useCallback(
|
||||
async () =>
|
||||
const onFormChange = useCallback(async () =>
|
||||
await form
|
||||
.validateFields()
|
||||
.then(() => setIsInvalid(false))
|
||||
.catch(() => setIsInvalid(true)),
|
||||
[form]
|
||||
)
|
||||
.catch(() => setIsInvalid(true))
|
||||
, [form])
|
||||
|
||||
const onFormFinish = useCallback(
|
||||
(formData) =>
|
||||
invokeWebApiWrapperAsync(
|
||||
async () => {
|
||||
console.log(formData)
|
||||
const payload = Object.fromEntries(names.map(([head, names]) => [head, Object.fromEntries(names.map((name) => [name, formdata[name]]))]))
|
||||
if (data) await DailyReportService.update(idWell, data.head.reportDate, payload)
|
||||
else await DailyReportService.add(idWell, payload)
|
||||
onDone?.(formData)
|
||||
form.resetFields()
|
||||
},
|
||||
setIsLoading,
|
||||
'Не удалось сохранить суточный рапорт',
|
||||
'Сохранение суточного рапорта'
|
||||
),
|
||||
[data, onDone, idWell, form]
|
||||
)
|
||||
const onFormFinish = useCallback((formData) => invokeWebApiWrapperAsync(
|
||||
async () => {
|
||||
const payload = Object.fromEntries(names.map(([head, names]) => [head, Object.fromEntries(names.map((name) => [name, formData[name]]))]))
|
||||
if (data) await DailyReportService.update(idWell, data.head.reportDate, payload)
|
||||
else await DailyReportService.add(idWell, payload)
|
||||
onDone?.(formData)
|
||||
form.resetFields()
|
||||
},
|
||||
setIsLoading,
|
||||
'Не удалось сохранить суточный рапорт',
|
||||
'Сохранение суточного рапорта'
|
||||
), [data, onDone, idWell, form])
|
||||
|
||||
const onDateChange = useCallback(
|
||||
(date) =>
|
||||
invokeWebApiWrapperAsync(
|
||||
async () => {
|
||||
if (data) return
|
||||
const newData = await DailyReportService.getOrGenerate(idWell, date.format('YYYY-MM-DD') + 'Z')
|
||||
if (checkIsDateBusy(moment(newData.reportDate)))
|
||||
throw new Error('Рапорт на данную дату уже существует')
|
||||
setFields(newData)
|
||||
},
|
||||
setIsLoading,
|
||||
(e) => `Не удалось загрузить автозаполняемые данные для нового рапорта: ${e}`,
|
||||
'Получение автозаполняемых данных суточного рапорта'
|
||||
),
|
||||
[idWell, data, setFields, checkIsDateBusy]
|
||||
)
|
||||
const onDateChange = useCallback((date) => invokeWebApiWrapperAsync(
|
||||
async () => {
|
||||
if (data) return
|
||||
const newData = await DailyReportService.getOrGenerate(idWell, date.format('YYYY-MM-DD') + 'Z')
|
||||
if (checkIsDateBusy(moment(newData.reportDate)))
|
||||
throw new Error('Рапорт на данную дату уже существует')
|
||||
setFields(newData)
|
||||
},
|
||||
setIsLoading,
|
||||
(e) => `Не удалось загрузить автозаполняемые данные для нового рапорта: ${e}`,
|
||||
'Получение автозаполняемых данных суточного рапорта'
|
||||
), [idWell, data, setFields, checkIsDateBusy])
|
||||
|
||||
return (
|
||||
<Modal
|
||||
@ -311,15 +345,11 @@ export const ReportEditor = memo(({ visible, data, onDone, onCancel, checkIsDate
|
||||
visible={visible}
|
||||
onCancel={onCancel}
|
||||
okText={'Сохранить'}
|
||||
title={
|
||||
data ? (
|
||||
<>
|
||||
Суточная сводка бурения скважины № {data?.wellName} куст № {data?.clusterName}
|
||||
</>
|
||||
) : (
|
||||
<>Новая cуточная сводка бурения скважины</>
|
||||
)
|
||||
}
|
||||
title={data ? (
|
||||
<>Суточная сводка бурения скважины № {data?.wellName} куст № {data?.clusterName}</>
|
||||
) : (
|
||||
<>Новая cуточная сводка бурения скважины</>
|
||||
)}
|
||||
onOk={form.submit}
|
||||
okButtonProps={{
|
||||
disabled: isInvalid,
|
||||
@ -336,29 +366,10 @@ export const ReportEditor = memo(({ visible, data, onDone, onCancel, checkIsDate
|
||||
disabledDate={checkIsDateBusy}
|
||||
/>
|
||||
</Item>
|
||||
<Tabs defaultActiveKey='1'>
|
||||
<TabPane tab='Заголовок' key='head' forceRender>
|
||||
<Tabs defaultActiveKey={'1'}>
|
||||
<TabPane tab={'Заголовок'} key={'head'} forceRender>
|
||||
<Descriptions bordered size={'small'} column={1}>
|
||||
<Descriptions.Item label={'Название скважины'}>
|
||||
<Item name={'wellName'}>
|
||||
<Input style={{ width: '100%' }} />
|
||||
</Item>
|
||||
</Descriptions.Item>
|
||||
<Descriptions.Item label={'Название куста'}>
|
||||
<Item name={'clusterName'}>
|
||||
<Input style={{ width: '100%' }} />
|
||||
</Item>
|
||||
</Descriptions.Item>
|
||||
<Descriptions.Item label={'Заказчик'}>
|
||||
<Item name={'customer'}>
|
||||
<Input style={{ width: '100%' }} />
|
||||
</Item>
|
||||
</Descriptions.Item>
|
||||
<Descriptions.Item label={'Подрядчик'}>
|
||||
<Item name={'contractor'}>
|
||||
<Input style={{ width: '100%' }} />
|
||||
</Item>
|
||||
</Descriptions.Item>
|
||||
{renderDescriptions(tab1Items)}
|
||||
</Descriptions>
|
||||
<Table
|
||||
bordered
|
||||
@ -374,10 +385,10 @@ export const ReportEditor = memo(({ visible, data, onDone, onCancel, checkIsDate
|
||||
dataSource={table12Data}
|
||||
pagination={false}
|
||||
/>
|
||||
<Item label={'Бурильщик 1 смена'} name={'firstDriller'}>
|
||||
<Item style={{ margin: '15px 0' }} label={'Бурильщик 1 смена'} name={'firstDriller'}>
|
||||
<Input />
|
||||
</Item>
|
||||
<Item label={'Бурильщик 2 смена'} name={'secondDriller'}>
|
||||
<Item style={{ margin: '15px 0' }} label={'Бурильщик 2 смена'} name={'secondDriller'}>
|
||||
<Input />
|
||||
</Item>
|
||||
|
||||
@ -390,7 +401,7 @@ export const ReportEditor = memo(({ visible, data, onDone, onCancel, checkIsDate
|
||||
pagination={false}
|
||||
/>
|
||||
</TabPane>
|
||||
<TabPane tab='КНБК' key='bha' forceRender>
|
||||
<TabPane tab={'КНБК'} key={'bha'} forceRender>
|
||||
<Table
|
||||
bordered
|
||||
size={'small'}
|
||||
@ -423,7 +434,7 @@ export const ReportEditor = memo(({ visible, data, onDone, onCancel, checkIsDate
|
||||
pagination={false}
|
||||
/>
|
||||
</TabPane>
|
||||
<TabPane tab='Безметражные работы' key='noDrilling' forceRender>
|
||||
<TabPane tab={'Безметражные работы'} key={'noDrilling'} forceRender>
|
||||
<Table
|
||||
bordered
|
||||
size={'small'}
|
||||
@ -432,108 +443,12 @@ export const ReportEditor = memo(({ visible, data, onDone, onCancel, checkIsDate
|
||||
pagination={false}
|
||||
/>
|
||||
</TabPane>
|
||||
<TabPane tab='Баланс времени' key='4' forceRender>
|
||||
<TabPane tab={'Баланс времени'} key={'4'} forceRender>
|
||||
<Descriptions bordered size={'small'} column={1}>
|
||||
<Descriptions.Item label={'Бурение'}>
|
||||
<Item name={'drilling'}>
|
||||
<Input style={{ width: '100%' }} />
|
||||
</Item>
|
||||
</Descriptions.Item>
|
||||
<Descriptions.Item label={'Время бурения за секцию'}>
|
||||
<Item name={'sectionDrillingTimeTotal'}>
|
||||
<Input style={{ width: '100%' }} />
|
||||
</Item>
|
||||
</Descriptions.Item>
|
||||
<Descriptions.Item label={'Промывка'}>
|
||||
<Item name={'flushing'}>
|
||||
<Input style={{ width: '100%' }} />
|
||||
</Item>
|
||||
</Descriptions.Item>
|
||||
<Descriptions.Item label={'Наращивание'}>
|
||||
<Item name={'building'}>
|
||||
<Input style={{ width: '100%' }} />
|
||||
</Item>
|
||||
</Descriptions.Item>
|
||||
<Descriptions.Item label={'Проработка'}>
|
||||
<Item name={'elaboration'}>
|
||||
<Input style={{ width: '100%' }} />
|
||||
</Item>
|
||||
</Descriptions.Item>
|
||||
<Descriptions.Item label={'Расширка'}>
|
||||
<Item name={'extension'}>
|
||||
<Input style={{ width: '100%' }} />
|
||||
</Item>
|
||||
</Descriptions.Item>
|
||||
<Descriptions.Item label={'Ремонт'}>
|
||||
<Item name={'repair'}>
|
||||
<Input style={{ width: '100%' }} />
|
||||
</Item>
|
||||
</Descriptions.Item>
|
||||
<Descriptions.Item label={'КНБК'}>
|
||||
<Item name={'knbk'}>
|
||||
<Input style={{ width: '100%' }} />
|
||||
</Item>
|
||||
</Descriptions.Item>
|
||||
<Descriptions.Item label={'СПО'}>
|
||||
<Item name={'spo'}>
|
||||
<Input style={{ width: '100%' }} />
|
||||
</Item>
|
||||
</Descriptions.Item>
|
||||
<Descriptions.Item label={'ПЗР'}>
|
||||
<Item name={'pzr'}>
|
||||
<Input style={{ width: '100%' }} />
|
||||
</Item>
|
||||
</Descriptions.Item>
|
||||
<Descriptions.Item label={'ПВО'}>
|
||||
<Item name={'pvo'}>
|
||||
<Input style={{ width: '100%' }} />
|
||||
</Item>
|
||||
</Descriptions.Item>
|
||||
<Descriptions.Item label={'ПГР'}>
|
||||
<Item name={'pgr'}>
|
||||
<Input style={{ width: '100%' }} />
|
||||
</Item>
|
||||
</Descriptions.Item>
|
||||
<Descriptions.Item label={'ГИС'}>
|
||||
<Item name={'gis'}>
|
||||
<Input style={{ width: '100%' }} />
|
||||
</Item>
|
||||
</Descriptions.Item>
|
||||
<Descriptions.Item label={'ОЗЦ'}>
|
||||
<Item name={'ozc'}>
|
||||
<Input style={{ width: '100%' }} />
|
||||
</Item>
|
||||
</Descriptions.Item>
|
||||
<Descriptions.Item label={'Тех. работы'}>
|
||||
<Item name={'engineeringWorks'}>
|
||||
<Input style={{ width: '100%' }} />
|
||||
</Item>
|
||||
</Descriptions.Item>
|
||||
<Descriptions.Item label={'Снаятие замера'}>
|
||||
<Item name={'takingMeasure'}>
|
||||
<Input style={{ width: '100%' }} />
|
||||
</Item>
|
||||
</Descriptions.Item>
|
||||
<Descriptions.Item label={'Цементирование'}>
|
||||
<Item name={'cementing'}>
|
||||
<Input style={{ width: '100%' }} />
|
||||
</Item>
|
||||
</Descriptions.Item>
|
||||
<Descriptions.Item label={'Простой'}>
|
||||
<Item name={'simple'}>
|
||||
<Input style={{ width: '100%' }} />
|
||||
</Item>
|
||||
</Descriptions.Item>
|
||||
<Descriptions.Item label={'НПВ'}>
|
||||
<Item name={'npv'}>
|
||||
<Input style={{ width: '100%' }} />
|
||||
</Item>
|
||||
</Descriptions.Item>
|
||||
{renderDescriptions(tab4Items)}
|
||||
</Descriptions>
|
||||
</TabPane>
|
||||
<TabPane tab='блок Сауб' key='saub' forceRender>
|
||||
<Divider />
|
||||
|
||||
<TabPane tab={'блок Сауб'} key={'saub'} forceRender>
|
||||
<Table
|
||||
bordered
|
||||
size={'small'}
|
||||
@ -577,7 +492,7 @@ export const ReportEditor = memo(({ visible, data, onDone, onCancel, checkIsDate
|
||||
</Descriptions.Item>
|
||||
</Descriptions>
|
||||
|
||||
<Item name={'declinesReasonsROP'} label={'Примечание:'}>
|
||||
<Item style={{ margin: '15px 0' }} name={'declinesReasonsROP'} label={'Примечание:'}>
|
||||
<Input.TextArea rows={4} />
|
||||
</Item>
|
||||
|
||||
@ -619,14 +534,13 @@ export const ReportEditor = memo(({ visible, data, onDone, onCancel, checkIsDate
|
||||
</Descriptions.Item>
|
||||
</Descriptions>
|
||||
</TabPane>
|
||||
<TabPane tab='Подписи' key='sign' forceRender>
|
||||
<Item label={'ФИО Мастера буровой'} name={'drillingMaster'}>
|
||||
<TabPane tab={'Подписи'} key={'sign'} forceRender>
|
||||
<RawItem label={'ФИО Мастера буровой'} name={'drillingMaster'}>
|
||||
<Input />
|
||||
</Item>
|
||||
<Divider />
|
||||
<Item label={'ФИО супервайзера'} name={'supervisor'}>
|
||||
</RawItem>
|
||||
<RawItem label={'ФИО супервайзера'} name={'supervisor'}>
|
||||
<Input />
|
||||
</Item>
|
||||
</RawItem>
|
||||
</TabPane>
|
||||
</Tabs>
|
||||
</Form>
|
||||
|
@ -24,7 +24,7 @@ const DailyReport = memo(() => {
|
||||
const updateTable = useCallback(() => invokeWebApiWrapperAsync(
|
||||
async () => {
|
||||
const data = arrayOrDefault(await DailyReportService.getList(idWell))
|
||||
setData(data)
|
||||
setData(data.map((row) => ({ ...row, reportDate: row.head.reportDate })))
|
||||
},
|
||||
setIsLoading,
|
||||
'Не удалось загрузить список суточных рапортов',
|
||||
|
Loading…
Reference in New Issue
Block a user