From c327240ea270f7b01285ad8f90cf1bab32869179 Mon Sep 17 00:00:00 2001 From: goodm2ice Date: Mon, 27 Dec 2021 15:18:20 +0500 Subject: [PATCH] =?UTF-8?q?=D0=9D=D0=B0=20=D0=B2=D0=BA=D0=BB=D0=B0=D0=B4?= =?UTF-8?q?=D0=BA=D1=83=20=D1=81=D0=B5=D0=BA=D1=86=D0=B8=D0=B8,=20=D1=80?= =?UTF-8?q?=D0=B5=D0=B6=D0=B8=D0=BC=D1=8B=20=D0=B4=D0=BE=D0=B1=D0=B0=D0=B2?= =?UTF-8?q?=D0=BB=D0=B5=D0=BD=D1=8B=20=D0=B5=D0=B4=D0=B8=D0=BD=D0=B8=D1=86?= =?UTF-8?q?=D1=8B=20=D0=B8=D0=B7=D0=BC=D0=B5=D1=80=D0=B5=D0=BD=D0=B8=D1=8F?= =?UTF-8?q?=20=D0=9C=D0=B5=D0=BB=D0=BA=D0=B8=D0=B9=20=D1=80=D0=B5=D1=84?= =?UTF-8?q?=D1=80=D0=B0=D0=BA=D1=82=D0=BE=D1=80=D0=B8=D0=BD=D0=B3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/Table/DatePickerWrapper.tsx | 4 +- src/components/Table/EditableTable.jsx | 16 +- src/components/Table/index.tsx | 3 +- src/components/WellTreeSelector.tsx | 2 +- src/components/factory.ts | 108 ++++---- src/pages/Cluster/ClusterWells.jsx | 8 +- src/pages/Measure/InclinometryTable.jsx | 4 +- src/pages/Measure/MeasureTable.jsx | 13 +- src/pages/Measure/View.jsx | 2 +- src/pages/Measure/index.jsx | 15 +- src/pages/Report/Reports.jsx | 108 ++++---- src/pages/Report/index.jsx | 238 ++++++++---------- src/pages/TelemetryView/SetpointViewer.jsx | 25 +- .../WellCompositeSections.jsx | 14 +- src/pages/WellOperations/WellDrillParams.jsx | 58 ++--- .../WellOperations/WellOperationsEditor.jsx | 181 +++++++------ src/pages/WellOperations/WellSectionsStat.jsx | 24 +- src/utils/DateTimeUtils.ts | 5 - src/utils/datetime.ts | 48 +++- src/utils/index.ts | 4 +- 20 files changed, 413 insertions(+), 467 deletions(-) delete mode 100644 src/utils/DateTimeUtils.ts diff --git a/src/components/Table/DatePickerWrapper.tsx b/src/components/Table/DatePickerWrapper.tsx index f042a4a..b1735b8 100644 --- a/src/components/Table/DatePickerWrapper.tsx +++ b/src/components/Table/DatePickerWrapper.tsx @@ -1,6 +1,6 @@ import { DatePicker } from 'antd' import moment from 'moment' -import { formatDate } from './index' +import { defaultFormat } from '../../utils' export type DatePickerWrapperProps = { value: moment.Moment, @@ -13,7 +13,7 @@ export const DatePickerWrapper: React.FC = ({value, onCh allowClear={false} defaultValue={moment()} value={moment.utc(value).local()} - format={formatDate} + format={defaultFormat} showTime onChange={(date) => onChange(date)} {...other} diff --git a/src/components/Table/EditableTable.jsx b/src/components/Table/EditableTable.jsx index 1d1a2eb..af84287 100644 --- a/src/components/Table/EditableTable.jsx +++ b/src/components/Table/EditableTable.jsx @@ -6,17 +6,25 @@ import { invokeWebApiWrapperAsync } from '../factory' const newRowKeyValue = 'newRow' -export const makeActionHandler = (action, { service, setLoader, errorMsg, onComplete }) => service && action && ( +export const makeActionHandler = (action, { idWell, service, setLoader, errorMsg, onComplete }, recordParser) => service && action && ( (record) => invokeWebApiWrapperAsync( async () => { + const addIdWell = (...params) => idWell ? [idWell, ...params] : params + if (typeof recordParser === 'function') + record = recordParser(record) + if (action === 'insert') { record.key = Date.now() - await service.insert(record) + await service.insert(...addIdWell(record)) + } else if (action === 'insertRange') { + if (!Array.isArray(record)) + record = [record] + await service.insertRange(...addIdWell(record)) } else if (record.id) { if (action === 'update') - await service.put(record.id, record) + await service.put(...addIdWell(record.id, record)) else if (action === 'delete') - await service.delete(record.id) + await service.delete(...addIdWell(record.id)) } onComplete?.() }, diff --git a/src/components/Table/index.tsx b/src/components/Table/index.tsx index 8f6b439..57b57e1 100644 --- a/src/components/Table/index.tsx +++ b/src/components/Table/index.tsx @@ -10,7 +10,6 @@ export { DatePickerWrapper } from './DatePickerWrapper' export { SelectFromDictionary } from './SelectFromDictionary' export const RegExpIsFloat = /^[-+]?\d+\.?\d*$/ -export const formatDate = 'YYYY.MM.DD HH:mm' export const makeNumericRender = (fixed?: number) => (value: any, row: object): ReactNode => { let val = '-' @@ -209,7 +208,7 @@ export const makeSelectColumn = ( other?: columnPropsOther ) => makeColumn(title, dataIndex, { input: { - setStep(e) - }} - value={step}> - {periodOptions} - +