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: