From c831cf011704b06a42deebf9134397e08da0d1c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A4=D1=80=D0=BE=D0=BB=D0=BE=D0=B2?= Date: Fri, 3 Sep 2021 09:26:43 +0500 Subject: [PATCH] measure design incomplete --- src/pages/Measure/Editor.jsx | 9 ++++- src/pages/Measure/MeasureTable2.jsx | 62 +++++++++++++++++++++++++++++ src/pages/Measure/View.jsx | 38 ++++++++++++++++++ src/pages/Measure/columnsCommon.js | 34 +++++++++++----- src/pages/Measure/index.jsx | 3 +- 5 files changed, 133 insertions(+), 13 deletions(-) create mode 100644 src/pages/Measure/MeasureTable2.jsx create mode 100644 src/pages/Measure/View.jsx diff --git a/src/pages/Measure/Editor.jsx b/src/pages/Measure/Editor.jsx index de9cca6..2068a4d 100644 --- a/src/pages/Measure/Editor.jsx +++ b/src/pages/Measure/Editor.jsx @@ -60,10 +60,15 @@ export const Editor = ({idWell, idCategory, columns, onUpdate}) => { id: id, idWell: idWell, idCategory: idCategory, - timestamp: timestamp?? moment(), + timestamp: moment(timestamp)?? moment(), data, } - await MeasureService.update(idWell, measure) + try{ + await MeasureService.update(idWell, measure) + } + catch(ex){ + console.write(ex) + } if(onUpdate) onUpdate() else diff --git a/src/pages/Measure/MeasureTable2.jsx b/src/pages/Measure/MeasureTable2.jsx new file mode 100644 index 0000000..621e711 --- /dev/null +++ b/src/pages/Measure/MeasureTable2.jsx @@ -0,0 +1,62 @@ +import { useState, useEffect } from 'react' +import { Button, Modal, Timeline } from 'antd' +import moment from 'moment' +import { HourglassOutlined } from '@ant-design/icons' +import LoaderPortal from '../../components/LoaderPortal' +import { invokeWebApiWrapperAsync } from '../../components/factory' +import { MeasureService } from '../../services/api' +import { Editor } from './Editor' +import TimelineItem from 'antd/lib/timeline/TimelineItem' +//import { View } from './View' + +const format='YYYY.MM.DD HH:mm' + +export const MeasureTable2 = ({idWell, idCategory, title, columns}) => { + const [showLoader, setShowLoader] = useState(false) + const [showEditor, setShowEditor] = useState(false) + const [history, setHistory] = useState([]) + + const update = () => invokeWebApiWrapperAsync(async()=>{ + const data = await MeasureService.getHisory(idWell, idCategory) + const story = data?.map( i=> ({ + id: i.id, + idWell: i.idWell, + idCategory: i.idCategory, + timestamp: moment.utc(i.timestamp).local().format(format), + ...i.data})) + setHistory(story??[]) + } + , setShowLoader + , "не удалось загрузить") + + useEffect(update, [idWell, idCategory]) + + return +

{title}

+   + + + {history.map(item=>{item.timestamp})} + + {/* */} + setShowEditor(false)} + onCancel={() => setShowEditor(false)} + width="95%" + footer={null} + > + + +
+} \ No newline at end of file diff --git a/src/pages/Measure/View.jsx b/src/pages/Measure/View.jsx new file mode 100644 index 0000000..ca3e838 --- /dev/null +++ b/src/pages/Measure/View.jsx @@ -0,0 +1,38 @@ +import { Empty } from 'antd'; +import {Grid, GridItem} from '../../components/Grid' + +export const View = ({columns, item}) => { + if (!item || !columns?.length) + return + + const colsCount = 3 + const viewItems = columns.map( (column, i) => { + const row = Math.floor(i / colsCount) + 1 + const colb = i % colsCount + return <> + + {column.title} + + + + {column.render ? column.render(item[column.dataIndex]) : item[column.dataIndex]} + + + }) + + return + {viewItems} + +} \ No newline at end of file diff --git a/src/pages/Measure/columnsCommon.js b/src/pages/Measure/columnsCommon.js index e5f5bbf..7d458b5 100644 --- a/src/pages/Measure/columnsCommon.js +++ b/src/pages/Measure/columnsCommon.js @@ -3,19 +3,33 @@ import {Input} from 'antd' const {TextArea} = Input -export const v = (text) =>
- {text} -
+// export const v = (text) =>
+// {text} +//
+ +// export const v = (text) =>
+// {text} +//
+ +export const v = (text) => text export const numericColumnOptions = { editable: true, initialValue: 0, - width:'5em', + width:'4rem', formItemRules: [ { required: true, @@ -28,4 +42,4 @@ export const numericColumnOptions = { export const textColumnOptions = { editable:true, input: