From 148dd2e96c3f26f54968faefd54f0aec82e8afb2 Mon Sep 17 00:00:00 2001 From: goodmice Date: Tue, 19 Apr 2022 19:26:35 +0500 Subject: [PATCH] =?UTF-8?q?*=20=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=D0=B0=20=D0=BF=D0=BE=D0=B4=D0=B3=D1=80=D1=83=D0=B7=D0=BA?= =?UTF-8?q?=D0=B0=20=D0=B0=D0=B2=D1=82=D0=BE=D0=B7=D0=B0=D0=BF=D0=BE=D0=BB?= =?UTF-8?q?=D0=BD=D1=8F=D0=B5=D0=BC=D1=8B=D1=85=20=D0=B7=D0=BD=D0=B0=D1=87?= =?UTF-8?q?=D0=B5=D0=BD=D0=B8=D0=B9=20*=20=D0=98=D1=81=D0=BF=D1=80=D0=B0?= =?UTF-8?q?=D0=B2=D0=BB=D0=B5=D0=BD=D0=B0=20=D0=BE=D1=88=D0=B8=D0=B1=D0=BA?= =?UTF-8?q?=D0=B0=20=D1=81=20=D0=BE=D1=82=D1=81=D1=83=D1=82=D1=81=D1=82?= =?UTF-8?q?=D0=B2=D0=B8=D0=B5=D0=BC=20'key'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Reports/DailyReport/ReportEditor.jsx | 37 +++++++++++++------ 1 file changed, 26 insertions(+), 11 deletions(-) diff --git a/src/pages/Reports/DailyReport/ReportEditor.jsx b/src/pages/Reports/DailyReport/ReportEditor.jsx index 89c6abd..c871b20 100644 --- a/src/pages/Reports/DailyReport/ReportEditor.jsx +++ b/src/pages/Reports/DailyReport/ReportEditor.jsx @@ -16,9 +16,9 @@ const Item = memo(({ style, ...other }) => ( + makeColumn('От (дата, время)', 'dateStart', { width: 200, render: (_, { disabled, onChange }) => ( - + )}), ]), @@ -52,9 +52,9 @@ const table2Columns = [ ] const table2Data = [ - { label: 'АПД (автоматическая подача долота), ч/м:', hours: 'workTimeSAUB', meters: 'penetrationSAUB' }, - { label: 'Спин Мастер (осцилляция), ч/м:', hours: 'workTimeSpinMaster', meters: 'penetrationSpinMaster' }, - { label: 'Торк Мастер (демпфирование), ч/м:', hours: 'workTimeTorkMaster', meters: 'penetrationTorkMaster' }, + { key: '1', label: 'АПД (автоматическая подача долота), ч/м:', hours: 'workTimeSAUB', meters: 'penetrationSAUB' }, + { key: '2', label: 'Спин Мастер (осцилляция), ч/м:', hours: 'workTimeSpinMaster', meters: 'penetrationSpinMaster' }, + { key: '3', label: 'Торк Мастер (демпфирование), ч/м:', hours: 'workTimeTorkMaster', meters: 'penetrationTorkMaster' }, ] const table3Columns = [ @@ -65,7 +65,7 @@ const table3Columns = [ ]), ] -const table3Data = [{ sinking: 'penetrationInRotor', hours: 'numberDrillingHours', pressure: 'avgDiffDropRotor' }] +const table3Data = [{ key: '', sinking: 'penetrationInRotor', hours: 'numberDrillingHours', pressure: 'avgDiffDropRotor' }] const table4Columns = [ makeGroupColumn('Бурение в слайде (за отчётный период) с использованием САУБ-1', [ @@ -75,7 +75,7 @@ const table4Columns = [ ]), ] -const table4Data = [{ sinking: 'penetrationInSlide', hours: 'drillingTimeInRotor', pressure: 'avgDiffPressureSlide' }] +const table4Data = [{ key: '', sinking: 'penetrationInSlide', hours: 'drillingTimeInRotor', pressure: 'avgDiffPressureSlide' }] const table6Columns = [ makeGroupColumn('БЕЗМЕТРАЖНЫЕ РАБОТЫ', [ @@ -87,11 +87,13 @@ const table6Columns = [ ] const table6Data = [{ + key: '1', l_label: 'Норматив на одну операцию, (мин):', r_label: 'Норматив на одну операцию, (мин):', l_value: 'standardTimeBarrelPreparation', r_value: 'standardTimeExtension' }, { + key: '2', l_label: 'Проработка при бур, факт (ч):', r_label: 'Наращивание, факт (ч):', l_value: 'actualTimeBarrelPreparation', @@ -127,12 +129,14 @@ export const ReportEditor = memo(({ visible, data, onDone, onCancel }) => { const idWell = useContext(IdWellContext) - useEffect(() => form.setFieldsValue(data ? { + const setFields = useCallback((data) => form.setFieldsValue(data ? { ...data, rotorDrillingModes: Array.isArray(data.rotorDrillingModes) ? data.rotorDrillingModes ?? [] : [], slideDrillingModes: Array.isArray(data.slideDrillingModes) ? data.slideDrillingModes ?? [] : [], reportDate: moment.utc(data.reportDate).local(), - } : {}), [data, form]) + } : {}), [form]) + + useEffect(() => setFields(data), [data, setFields]) const onFormChange = useCallback(async () => await form.validateFields() .then(() => setIsInvalid(false)) @@ -152,6 +156,17 @@ export const ReportEditor = memo(({ visible, data, onDone, onCancel }) => { 'Сохранение суточного рапорта', ), [data, onDone, idWell]) + const onDateChange = useCallback((date) => invokeWebApiWrapperAsync( + async () => { + if (data) return + const newData = await DailyReportService.getOrGenerate(idWell, date.toISOString()) + setFields(newData) + }, + setIsLoading, + 'Не удалось загрузить автозаполняемые данные для нового рапорта', + 'Получение автозаполняемых данных суточного рапорта', + )) + return ( { onChange={onFormChange} > - + @@ -186,7 +201,7 @@ export const ReportEditor = memo(({ visible, data, onDone, onCancel }) => { bordered size={'small'} columns={table1Columns} - dataSource={[{ dateStart: !!data }]} + dataSource={[{ key: '', disabled: !!data, onChange: onDateChange }]} pagination={false} />