From ebcd1eebb5a7ecbd7b6538302ec703c13c29bd09 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A5=D0=B0=D1=80=D1=87=D0=B5=D0=BD=D0=BA=D0=BE=20=D0=92?= =?UTF-8?q?=D0=BB=D0=B0=D0=B4=D0=B8=D0=BC=D0=B8=D1=80?= Date: Tue, 21 Dec 2021 16:38:30 +0500 Subject: [PATCH 1/4] Fixed null dates display (for stats table) --- src/pages/Cluster/ClusterWells.jsx | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/pages/Cluster/ClusterWells.jsx b/src/pages/Cluster/ClusterWells.jsx index 57457b3..520c54f 100644 --- a/src/pages/Cluster/ClusterWells.jsx +++ b/src/pages/Cluster/ClusterWells.jsx @@ -55,6 +55,13 @@ export default function ClusterWells({statsWells}) { if (!filtersWellsType.some((el) => el.text === well.wellType)) filtersWellsType.push({ text: well.wellType, value: well.wellType,}) + let periodPlanValue = well.total?.plan?.start && well.total?.plan?.end + ? (new Date(well.total?.plan?.end) - new Date(well.total?.plan?.start)) / DAY_IN_MS + : '-' + let periodFactValue = well.total?.fact?.start && well.total?.fact?.end + ? (new Date(well.total?.fact?.end) - new Date(well.total?.fact?.start)) / DAY_IN_MS + : '-' + return { key: well.caption, id: well.id, @@ -62,8 +69,8 @@ export default function ClusterWells({statsWells}) { wellType: well.wellType, factStart: well.total?.fact?.start, factEnd: well.total?.fact?.end, - periodPlan: (new Date(well.total?.plan?.end) - new Date(well.total?.plan?.start)) / DAY_IN_MS, - periodFact: (new Date(well.total?.fact?.end) - new Date(well.total?.fact?.start)) / DAY_IN_MS, + periodPlan: periodPlanValue, + periodFact: periodFactValue, rateOfPenetrationPlan: well.total?.plan?.rop, rateOfPenetrationFact: well.total?.fact?.rop, routeSpeedPlan: well.total?.plan?.routeSpeed, @@ -91,7 +98,9 @@ export default function ClusterWells({statsWells}) { setTableData(data) }, [statsWells]) - const getDate = (str) => Number.isNaN(+new Date(str)) ? '-' : new Date(str).toLocaleString() + const getDate = (str) => Number.isNaN(+new Date(str)) || +new Date(str) === 0 + ? '-' + : new Date(str).toLocaleString() const columns = [ makeTextColumn('скв №', 'caption', null, null, From 528b7e4f7b8560ccde58c8948011d05c8f7baaf3 Mon Sep 17 00:00:00 2001 From: goodm2ice Date: Thu, 23 Dec 2021 18:23:21 +0500 Subject: [PATCH 2/4] =?UTF-8?q?=D0=A1=D1=82=D1=80=D0=B0=D0=BD=D0=B8=D1=86?= =?UTF-8?q?=D0=B0=20"=D0=98=D0=B7=D0=BC=D0=B5=D1=80=D0=B5=D0=BD=D0=B8?= =?UTF-8?q?=D1=8F":=20*=20=D0=98=D1=81=D0=BF=D1=80=D0=B0=D0=B2=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=D0=B0=20=D0=BE=D1=88=D0=B8=D0=B1=D0=BA=D0=B0=20=D1=81=20?= =?UTF-8?q?=D0=BA=D0=BB=D1=8E=D1=87=D0=B0=D0=BC=D0=B8=20=D0=BA=D0=BB=D0=B5?= =?UTF-8?q?=D1=82=D0=BE=D0=BA=20=D1=82=D0=B0=D0=B1=D0=BB=D0=B8=D1=86=20*?= =?UTF-8?q?=20=D0=97=D0=B0=D0=BF=D0=B8=D1=81=D1=8C=20"=D0=9D=D0=B5=D1=82?= =?UTF-8?q?=20=D0=B4=D0=B0=D0=BD=D0=BD=D1=8B=D1=85"=20=D0=B2=D1=8B=D0=B2?= =?UTF-8?q?=D0=BE=D0=B4=D0=B8=D1=82=D1=81=D1=8F=20=D1=82=D0=BE=D0=BB=D1=8C?= =?UTF-8?q?=D0=BA=D0=BE=20=D0=BF=D1=80=D0=B8=20=D0=B8=D1=85=20=D0=BE=D1=82?= =?UTF-8?q?=D1=81=D1=83=D1=82=D1=81=D1=82=D0=B2=D0=B8=D0=B8=20*=20render-?= =?UTF-8?q?=D0=BC=D0=B5=D1=82=D0=BE=D0=B4=20=D0=B4=D0=BB=D1=8F=20=D0=B4?= =?UTF-8?q?=D0=BE=D0=BF=D0=BE=D0=BB=D0=BD=D0=B8=D1=82=D0=B5=D0=BB=D1=8C?= =?UTF-8?q?=D0=BD=D1=8B=D1=85=20=D0=BA=D0=BD=D0=BE=D0=BF=D0=BE=D0=BA=20?= =?UTF-8?q?=D1=81=D0=B5=D0=BA=D1=86=D0=B8=D0=B9=20=D0=B2=D1=8B=D0=BD=D0=B5?= =?UTF-8?q?=D1=81=D0=B5=D0=BD=20=D0=B2=20=D0=BA=D0=BE=D0=BD=D1=81=D1=82?= =?UTF-8?q?=D0=B0=D0=BD=D1=82=D1=83=20*=20=D0=91=D0=BE=D0=BB=D1=8C=D1=88?= =?UTF-8?q?=D0=B8=D0=B5=20=D0=BE=D0=B1=D1=8A=D0=B5=D0=BA=D1=82=D1=8B=20?= =?UTF-8?q?=D1=81=D1=82=D0=B0=D1=82=D0=B8=D1=87=D0=BD=D1=8B=D1=85=20=D1=81?= =?UTF-8?q?=D1=82=D0=B8=D0=BB=D0=B5=D0=B9=20=D0=BF=D0=B5=D1=80=D0=B5=D0=BD?= =?UTF-8?q?=D0=B5=D1=81=D0=B5=D0=BD=D1=8B=20=D0=B2=20css=20*=20=D0=9F?= =?UTF-8?q?=D1=80=D0=BE=D0=B2=D0=B5=D0=B4=D0=B5=D0=BD=D0=B0=20=D0=BC=D0=B5?= =?UTF-8?q?=D0=BB=D0=BA=D0=B0=D1=8F=20=D1=81=D1=82=D0=B8=D0=BB=D0=B8=D0=B7?= =?UTF-8?q?=D0=B0=D1=86=D0=B8=D1=8F=20=D0=BA=D0=BE=D0=B4=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/Measure/InclinometryTable.jsx | 50 ++++++----- src/pages/Measure/MeasureTable.jsx | 29 +++--- src/pages/Measure/View.jsx | 97 +++++++++----------- src/pages/Measure/columnsCommon.js | 25 ++---- src/pages/Measure/drillingFluidData.js | 115 ++++++++++++------------ src/pages/Measure/index.jsx | 56 ++++++------ src/pages/Measure/mudDiagramData.js | 44 ++++----- src/pages/Measure/nnbData.js | 36 ++++---- src/styles/measure.css | 31 +++++++ 9 files changed, 246 insertions(+), 237 deletions(-) diff --git a/src/pages/Measure/InclinometryTable.jsx b/src/pages/Measure/InclinometryTable.jsx index fe04957..ed55e38 100644 --- a/src/pages/Measure/InclinometryTable.jsx +++ b/src/pages/Measure/InclinometryTable.jsx @@ -1,29 +1,38 @@ -import React, { useEffect, useState } from 'react' import { Modal } from 'antd' +import { memo, useEffect, useState } from 'react' + import { Table } from '../../components/Table' + import { formatDate } from './MeasureTable' import { v } from './columnsCommon' -export const InclinometryTable = React.memo(({ group, visible, onClose }) => { +const tableScroll = { y: 400, x: 1300 } + +const dateColumn = { + title: 'Дата', + key: 'date', + dataIndex: 'date', + render: formatDate, + fixed: 'left', + width: '8rem', +} + +export const InclinometryTable = memo(({ group, visible, onClose }) => { const [tableColumns, setTableColumns] = useState([]) const [tableData, setTableData] = useState([]) - useEffect(() => { - setTableColumns([{ - title: 'Дата', - key: 'date', - dataIndex: 'date', - render: (item) => formatDate(item), - fixed: 'left', - width: '8rem', - }, - ...(group?.columns?.map((column) => ({...column, title: v(column.title)})) ?? []) - ]) - }, [group?.columns]) + useEffect(() => setTableColumns([ + dateColumn, + ...(group?.columns?.map((column) => ({ + ...column, + title: v(column.title) + })) ?? []) + ]), [group?.columns]) - useEffect(() => { - setTableData(group?.values?.map(row => ({ date: row.timestamp, ...row.data }))) - }, [group?.values]) + useEffect(() => setTableData(group?.values?.map(row => ({ + date: row.timestamp, + ...row.data + }))), [group?.values]) return !group?.columns ? null : ( { ) }) - -export default InclinometryTable diff --git a/src/pages/Measure/MeasureTable.jsx b/src/pages/Measure/MeasureTable.jsx index 04fbff9..71025c6 100644 --- a/src/pages/Measure/MeasureTable.jsx +++ b/src/pages/Measure/MeasureTable.jsx @@ -1,6 +1,6 @@ +import moment from 'moment' import { useState, useEffect } from 'react' import { Button, Form, Input, Popconfirm, Timeline } from 'antd' -import moment from 'moment' import { CheckSquareOutlined, EditOutlined, @@ -9,15 +9,21 @@ import { CloseCircleOutlined, DeleteOutlined } from '@ant-design/icons' -import { View } from './View' + import LoaderPortal from '../../components/LoaderPortal' import { MeasureService } from '../../services/api' -import '../../styles/index.css' -import '../../styles/measure.css' import { invokeWebApiWrapperAsync } from '../../components/factory' -const dateFormat = 'YYYY.MM.DD HH:mm' -export const formatDate = (date) => date ? moment.utc(date).local().format(dateFormat) : 'Нет данных' +import { View } from './View' + +import '../../styles/index.css' +import '../../styles/measure.css' + +export const formatDate = (date) => date ? + moment.utc(date).local().format('YYYY.MM.DD HH:mm') : 'Нет данных' + +const createEditingColumns = (cols, renderDelegate) => + cols.map(col => ({ render: renderDelegate, ...col })) export const MeasureTable = ({idWell, group, updateMeasuresFunc, additionalButtons}) => { const [showLoader, setShowLoader] = useState(false) @@ -29,11 +35,10 @@ export const MeasureTable = ({idWell, group, updateMeasuresFunc, additionalButto const [measuresForm] = Form.useForm() - const createEditingColumns = (cols, renderDelegate) => - cols.map(col => ({ render: renderDelegate, ...col })) - useEffect(() => { - const data = [group.defaultValue].concat(group.values ?? []) + let data = [group.defaultValue] + if (group?.values?.length > 0) + data = group.values setData(data) setDisplayedValues(data.at(-1)) }, [group.defaultValue, group.values]) @@ -136,11 +141,11 @@ export const MeasureTable = ({idWell, group, updateMeasuresFunc, additionalButto key={index} className={'measure-button'} onClick={() => setDisplayedValues(item)} - dot={item?.id !== displayedValues?.id ? null : + dot={item?.id === displayedValues?.id && } > - + {formatDate(item.timestamp)} diff --git a/src/pages/Measure/View.jsx b/src/pages/Measure/View.jsx index a42cbbe..04d204b 100644 --- a/src/pages/Measure/View.jsx +++ b/src/pages/Measure/View.jsx @@ -1,61 +1,50 @@ -import React from 'react' +import { memo, Fragment } from 'react' import { Empty, Form } from 'antd' + import { Grid, GridItem } from '../../components/Grid' + import '../../styles/index.css' +import '../../styles/measure.css' const colsCount = 3 -const headerCellStyle = { - border:'1px solid lightgrey' -} +export const View = memo(({ columns, item }) => !item || !columns?.length ? ( + +) : ( + + {columns.map((column, i) => ( + + + {column.title} + -const valueCellStyle = { - border:'1px solid lightgrey', - justifyContent:'right', - marginRight:'16px', - fontWeight:'bold', - textAlign:'right', - padding: 0 -} - -export const View = React.memo(({columns, item}) => { - if (!item || !columns?.length) - return - - return ( - - {columns.map((column, i) => ( - <> - - {column.title} - - - - {column.render ? ( - - {column.render(item[column.dataIndex])} - - ) : ( -

{item[column.dataIndex]}

- )} -
- - ))} -
- ) -}) \ No newline at end of file + + {column.render ? ( + + {column.render(item[column.dataIndex])} + + ) : ( +

+ {item[column.dataIndex]} +

+ )} +
+
+ ))} +
+)) diff --git a/src/pages/Measure/columnsCommon.js b/src/pages/Measure/columnsCommon.js index 8e2a9fc..8db90bd 100644 --- a/src/pages/Measure/columnsCommon.js +++ b/src/pages/Measure/columnsCommon.js @@ -1,27 +1,12 @@ -import React from 'react' import { Input } from 'antd' + import { RegExpIsFloat } from '../../components/Table' -const { TextArea } = Input +import '../../styles/measure.css' export const v = (text) => ( -
- +
+ {text}
@@ -42,7 +27,7 @@ export const numericColumnOptions = { export const textColumnOptions = { editable: true, - input: