CF2-49: Main changes for new Measures table display

This commit is contained in:
KharchenkoVV 2021-10-04 18:06:42 +05:00
parent c2243f1eb6
commit 5755b41abc
6 changed files with 176 additions and 91 deletions

View File

@ -7,16 +7,17 @@ import { invokeWebApiWrapperAsync } from '../../components/factory'
import { MeasureService } from '../../services/api' import { MeasureService } from '../../services/api'
import { Editor } from './Editor' import { Editor } from './Editor'
import TimelineItem from 'antd/lib/timeline/TimelineItem' import TimelineItem from 'antd/lib/timeline/TimelineItem'
//import { View } from './View' import { View } from './View'
import '../../styles/measure.css'
const format='YYYY.MM.DD HH:mm' const format='YYYY.MM.DD HH:mm'
export const MeasureTable2 = ({idWell, idCategory, title, columns}) => { export const MeasureTable2 = ({idWell, idCategory, title, columns, currentValues}) => {
const [showLoader, setShowLoader] = useState(false) const [showLoader, setShowLoader] = useState(false)
const [showEditor, setShowEditor] = useState(false) const [showEditor, setShowEditor] = useState(false)
const [history, setHistory] = useState([]) const [history, setHistory] = useState([])
const update = () => invokeWebApiWrapperAsync(async()=>{ const updateHistory = () => invokeWebApiWrapperAsync(async()=>{
const data = await MeasureService.getHisory(idWell, idCategory) const data = await MeasureService.getHisory(idWell, idCategory)
const story = data?.map( i=> ({ const story = data?.map( i=> ({
id: i.id, id: i.id,
@ -27,22 +28,40 @@ export const MeasureTable2 = ({idWell, idCategory, title, columns}) => {
setHistory(story??[]) setHistory(story??[])
} }
, setShowLoader , setShowLoader
, "не удалось загрузить") , `Не удалось загрузить последние данные по скважине ${idWell}`)
useEffect(update, [idWell, idCategory]) useEffect(updateHistory, [idWell, idCategory])
return <LoaderPortal show={showLoader}> const lastHistoryIndex = history.length
return <>
<LoaderPortal show={showLoader}>
&nbsp;
<h3>{title}</h3> <h3>{title}</h3>
&nbsp; &nbsp;
<Button <div className='d-flex'>
onClick={() => setShowEditor(true)} <div className='measure-dates'>
icon={<HourglassOutlined/>}>История</Button>
<Timeline> <Timeline>
{history.map(item=><TimelineItem value={item}>{item.timestamp}</TimelineItem>)} {history.map((item, index)=>
<Timeline.Item
key={item.id}
className={index === lastHistoryIndex - 1
? 'last-measure-button'
: 'measure-button'}
onClick={() => setShowEditor(true)}
value={item}
>
<p>{item.timestamp}</p>
</Timeline.Item>)}
</Timeline> </Timeline>
{/* <View </div>
item = {lastData?.data} <div className='w-100'>
columns = {columns}/> */} <View
item = {currentValues.data}
columns = {columns}
/>
</div>
</div>
<Modal <Modal
title={title} title={title}
centered centered
@ -56,7 +75,9 @@ export const MeasureTable2 = ({idWell, idCategory, title, columns}) => {
idWell={idWell} idWell={idWell}
idCategory={idCategory} idCategory={idCategory}
columns = {columns} columns = {columns}
onUpdate={update}/> onUpdate={updateHistory}
/>
</Modal> </Modal>
</LoaderPortal> </LoaderPortal>
</>
} }

View File

@ -9,30 +9,35 @@ export const View = ({columns, item}) => {
const viewItems = columns.map( (column, i) => { const viewItems = columns.map( (column, i) => {
const row = Math.floor(i / colsCount) + 1 const row = Math.floor(i / colsCount) + 1
const colb = i % colsCount const colb = i % colsCount
return <> return <>
<GridItem <GridItem
//style={{width:'100%', border:'1px solid red'}}
row={row} row={row}
col={colb*2 + 1} col={colb*2 + 1}
background='#00000005' background='#00000005'
border='1px solid #FFFE' border='1px solid #FFFE'
> >
{column.title} {column.title}
</GridItem> </GridItem>
<GridItem <GridItem
//style={{width:'50%', border:'1px solid blue'}}
row={row} row={row}
col={colb*2 + 2} col={colb*2 + 2}
border='1px solid rgba(0, 0, 0, 0.05)' border='1px solid rgba(0, 0, 0, 0.05)'
justifyContect='right' justifycontent='right'
marginRight='16px' marginright='16px'
fontWeight='bold' fontWeight='bold'
textAlign='right'> textalign='right'
>
{column.render ? column.render(item[column.dataIndex]) : item[column.dataIndex]} {column.render ? column.render(item[column.dataIndex]) : item[column.dataIndex]}
</GridItem> </GridItem>
</> </>
}) })
return <Grid> return <>
<Grid>
{viewItems} {viewItems}
</Grid> </Grid>
</>
} }

View File

@ -4,10 +4,6 @@ import {v, numericColumnOptions, textColumnOptions} from './columnsCommon'
export const columnsMudDiagram = [ export const columnsMudDiagram = [
makeColumn(v('N пробы'), 'probeNumber', numericColumnOptions), makeColumn(v('N пробы'), 'probeNumber', numericColumnOptions),
makeColumn(v('Глубина отбора пробы'), 'probeExtractionDepth', numericColumnOptions), makeColumn(v('Глубина отбора пробы'), 'probeExtractionDepth', numericColumnOptions),
{
title: 'Литология',
key: 'lithology',
children: [
makeColumn(v('Песчаник (%)'), 'sandstone', numericColumnOptions), makeColumn(v('Песчаник (%)'), 'sandstone', numericColumnOptions),
makeColumn(v('Алевролит (%)'), 'siltstone', numericColumnOptions), makeColumn(v('Алевролит (%)'), 'siltstone', numericColumnOptions),
makeColumn(v('Аргиллит (%)'), 'argillit', numericColumnOptions), makeColumn(v('Аргиллит (%)'), 'argillit', numericColumnOptions),
@ -17,23 +13,15 @@ export const columnsMudDiagram = [
makeColumn(v('Глина (%)'), 'clay', numericColumnOptions), makeColumn(v('Глина (%)'), 'clay', numericColumnOptions),
makeColumn(v('Известняк (%)'), 'camstone', numericColumnOptions), makeColumn(v('Известняк (%)'), 'camstone', numericColumnOptions),
makeColumn(v('Цемент (%)'), 'cement', numericColumnOptions), makeColumn(v('Цемент (%)'), 'cement', numericColumnOptions),
]
},
makeColumn('Краткое описание', 'summary', textColumnOptions), makeColumn('Краткое описание', 'summary', textColumnOptions),
makeColumn(v('ЛБА бурового раствора'), 'drillingMud', numericColumnOptions), makeColumn(v('ЛБА бурового раствора'), 'drillingMud', numericColumnOptions),
makeColumn(v('ЛБА (шлама)'), 'sludge', numericColumnOptions), makeColumn(v('ЛБА (шлама)'), 'sludge', numericColumnOptions),
{
title: 'Газопоказания',
key: 'gasIndications',
children: [
makeColumn(v('Сумма УВ мах. (абс%)'), 'maxSum', numericColumnOptions), makeColumn(v('Сумма УВ мах. (абс%)'), 'maxSum', numericColumnOptions),
makeColumn(v('С1 метан (отн%)'), 'methane', numericColumnOptions), makeColumn(v('С1 метан (отн%)'), 'methane', numericColumnOptions),
makeColumn(v('С2 этан (отн%)'), 'ethane', numericColumnOptions), makeColumn(v('С2 этан (отн%)'), 'ethane', numericColumnOptions),
makeColumn(v('С3 пропан (отн%)'), 'propane', numericColumnOptions), makeColumn(v('С3 пропан (отн%)'), 'propane', numericColumnOptions),
makeColumn(v('С4 бутан (отн%)'), 'butane', numericColumnOptions), makeColumn(v('С4 бутан (отн%)'), 'butane', numericColumnOptions),
makeColumn(v('С5 пентан (отн%)'), 'pentane', numericColumnOptions), makeColumn(v('С5 пентан (отн%)'), 'pentane', numericColumnOptions),
]
},
makeColumn(v('Мех. скорость'), 'mechanicalSpeed', numericColumnOptions), makeColumn(v('Мех. скорость'), 'mechanicalSpeed', numericColumnOptions),
makeColumn('Предварительное заключение о насыщении по ГК', 'preliminaryConclusion', textColumnOptions), makeColumn('Предварительное заключение о насыщении по ГК', 'preliminaryConclusion', textColumnOptions),
] ]

View File

@ -1,25 +1,60 @@
import { useState, useEffect } from 'react'
import { columnsMudDiagram} from './columnsMudDiagram' import { columnsMudDiagram} from './columnsMudDiagram'
import { columnsDrillingFluid} from './columnsDrillingFluid' import { columnsDrillingFluid} from './columnsDrillingFluid'
import { invokeWebApiWrapperAsync } from '../../components/factory'
import { MeasureService } from '../../services/api'
import { columnsNnb } from './columnsNnb' import { columnsNnb } from './columnsNnb'
import { MeasureTable } from './MeasureTable' import LoaderPortal from '../../components/LoaderPortal'
//import { MeasureTable2 } from './MeasureTable2' //import moment from 'moment'
//import { MeasureTable } from './MeasureTable'
import { MeasureTable2 } from './MeasureTable2'
const format='YYYY.MM.DD HH:mm'
export default function Measure({idWell}){ export default function Measure({idWell}){
const [showLoader, setShowLoader] = useState(false)
const [currentFluidValues, setCurrentFluidValues] = useState([])
const [currentMudValues, setCurrentMudValues] = useState([])
const [currentNnbValues, setCurrentNnbValues] = useState([])
const updateCurrentValues = () => invokeWebApiWrapperAsync(async()=>{
const data = await MeasureService.getAllLast(idWell)
const fluidValues = data?.find(value => value.idCategory === 1)
setCurrentFluidValues(fluidValues ?? [])
const mudValues = data?.find(value => value.idCategory === 2)
setCurrentMudValues(mudValues ?? [])
const nnbValues = data?.find(value => value.idCategory === 3)
setCurrentNnbValues(nnbValues ?? [])
}
,setShowLoader
,`Не удалось загрузить последние данные по скважине ${idWell}`)
useEffect(updateCurrentValues, [idWell])
return <> return <>
<MeasureTable <LoaderPortal show={showLoader}>
<MeasureTable2
idWell={idWell} idWell={idWell}
idCategory={1} idCategory={1}
title='Замер бурового раствора' title='Замер бурового раствора'
columns={columnsDrillingFluid}/> columns={columnsDrillingFluid}
<MeasureTable currentValues={currentFluidValues}
/>
<MeasureTable2
idWell={idWell} idWell={idWell}
idCategory={2} idCategory={2}
title='Шламограмма' title='Шламограмма'
columns={columnsMudDiagram}/> columns={columnsMudDiagram}
<MeasureTable currentValues={currentMudValues}
/>
<MeasureTable2
idWell={idWell} idWell={idWell}
idCategory={3} idCategory={3}
title='ННБ' title='ННБ'
columns={columnsNnb}/> columns={columnsNnb}
currentValues={currentNnbValues}
/>
</LoaderPortal>
</> </>
} }

View File

@ -19,6 +19,10 @@ body {
display: none; display: none;
} }
.w-15 {
width: 15%
}
.w-100 { .w-100 {
width: 100% width: 100%
} }

32
src/styles/measure.css Normal file
View File

@ -0,0 +1,32 @@
.measure-dates {
width: 15%;
overflow-y: scroll;
}
.measure-button {
display: flex;
margin-top: 8px;
width: 95%;
height: 30px;
border: 1px solid black;
border-radius: 5px;
}
.measure-button:hover {
cursor: pointer;
}
.last-measure-button {
display: flex;
margin-top: 8px;
background-color: #DCDCDC;
width: 95%;
height: 30px;
border: 1px solid black;
border-radius: 5px;
}
.last-measure-button:hover {
cursor: pointer;
background-color: #D3D3D3;
}