From a26cd7265e0cafd31da2cbed89e3090132734f91 Mon Sep 17 00:00:00 2001 From: goodmice Date: Wed, 17 Nov 2021 12:07:46 +0500 Subject: [PATCH] =?UTF-8?q?=D0=9D=D0=B5=D0=BD=D1=83=D0=B6=D0=BD=D1=8B?= =?UTF-8?q?=D0=B9=20=D1=84=D0=B0=D0=B9=D0=BB=20=D1=83=D0=B4=D0=B0=D0=BB?= =?UTF-8?q?=D1=91=D0=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/Measure/Editor.jsx | 100 ----------------------------------- 1 file changed, 100 deletions(-) delete mode 100644 src/pages/Measure/Editor.jsx diff --git a/src/pages/Measure/Editor.jsx b/src/pages/Measure/Editor.jsx deleted file mode 100644 index 2068a4d..0000000 --- a/src/pages/Measure/Editor.jsx +++ /dev/null @@ -1,100 +0,0 @@ -import { useState, useEffect } from 'react' -import moment from 'moment' -import { EditableTable, DatePickerWrapper } from '../../components/Table' -import LoaderPortal from '../../components/LoaderPortal' -import { invokeWebApiWrapperAsync } from '../../components/factory' -import { MeasureService } from '../../services/api' - -const format='YYYY.MM.DD HH:mm' - -const columnTimestamp = { - editable: true, - title: 'Время', - key:'timestamp', - dataindex:'timestamp', - input: , - width:'12em', - render: (text, record, idx) => record['timestamp'], -} - -export const Editor = ({idWell, idCategory, columns, onUpdate}) => { - const [showLoader, setShowLoader] = 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]) - - const onAdd = async (row) => { - const {id, idCategory: _idCategory, idWell : _idWell, timestamp, key, ...data} = row - const measure = { - id:0, - idWell: idWell, - idCategory: idCategory, - timestamp: timestamp?? moment(), - data, - } - await MeasureService.insert(idWell, measure) - if(onUpdate) - onUpdate() - else - update() - } - - const onEdit = async (row) => { - if(!row?.id) - return - const {id, idCategory: _idCategory, idWell : _idWell, timestamp, ...data} = row - const measure = { - id: id, - idWell: idWell, - idCategory: idCategory, - timestamp: moment(timestamp)?? moment(), - data, - } - try{ - await MeasureService.update(idWell, measure) - } - catch(ex){ - console.write(ex) - } - if(onUpdate) - onUpdate() - else - update() - } - - const onDelete = async (row) => { - if(!row?.id) - return - await MeasureService.markAsDelete(idWell, row.id) - if(onUpdate) - onUpdate() - else - update() - } - - return - - -} \ No newline at end of file