Исправления страницы суточного рапорта

This commit is contained in:
goodmice 2022-08-02 15:26:06 +05:00
parent 4df60c8d9d
commit 5ab2bf237f
2 changed files with 122 additions and 208 deletions

View File

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

View File

@ -24,7 +24,7 @@ const DailyReport = memo(() => {
const updateTable = useCallback(() => invokeWebApiWrapperAsync( const updateTable = useCallback(() => invokeWebApiWrapperAsync(
async () => { async () => {
const data = arrayOrDefault(await DailyReportService.getList(idWell)) const data = arrayOrDefault(await DailyReportService.getList(idWell))
setData(data) setData(data.map((row) => ({ ...row, reportDate: row.head.reportDate })))
}, },
setIsLoading, setIsLoading,
'Не удалось загрузить список суточных рапортов', 'Не удалось загрузить список суточных рапортов',