From 00ed56c8b192a1f1d35bdb99b328123e3158cc97 Mon Sep 17 00:00:00 2001 From: KharchenkoVV Date: Thu, 7 Oct 2021 11:52:52 +0500 Subject: [PATCH] CF2-49: Added default values for 'Measure' table --- src/pages/Measure/MeasureTable.jsx | 9 +++-- ...sDrillingFluid.js => drillingFluidData.js} | 38 +++++++++++++++++++ src/pages/Measure/index.jsx | 15 +++++--- ...columnsMudDiagram.js => mudDiagramData.js} | 34 ++++++++++++++++- .../Measure/{columnsNnb.js => nnbData.js} | 29 +++++++++++++- 5 files changed, 114 insertions(+), 11 deletions(-) rename src/pages/Measure/{columnsDrillingFluid.js => drillingFluidData.js} (75%) rename src/pages/Measure/{columnsMudDiagram.js => mudDiagramData.js} (75%) rename src/pages/Measure/{columnsNnb.js => nnbData.js} (77%) diff --git a/src/pages/Measure/MeasureTable.jsx b/src/pages/Measure/MeasureTable.jsx index 5cb1c45..9ce6710 100644 --- a/src/pages/Measure/MeasureTable.jsx +++ b/src/pages/Measure/MeasureTable.jsx @@ -10,7 +10,7 @@ import '../../styles/measure.css' const format='YYYY.MM.DD HH:mm' -export const MeasureTable = ({idWell, idCategory, title, columns, values, updateMeasures}) => { +export const MeasureTable = ({idWell, idCategory, title, columns, values, updateMeasuresFunc}) => { const [showLoader, setShowLoader] = useState(false); const [selectedTimeLineId, setSelectedTimeLineId] = useState(0) @@ -72,6 +72,9 @@ export const MeasureTable = ({idWell, idCategory, title, columns, values, update key={conf.key} className='w-100' onClick={onClickDelegate} + disabled={conf.key !== 'add' && displayedValues.isDefaultData + ? true + : false} > {conf.name} @@ -94,7 +97,7 @@ export const MeasureTable = ({idWell, idCategory, title, columns, values, update if(editingActionName === 'Удалить'){ setShowLoader(true) await MeasureService.markAsDelete(idWell, displayedValues.id) - updateMeasures() + updateMeasuresFunc() setShowLoader(false) setIsTableEditing(false) } else { @@ -121,7 +124,7 @@ export const MeasureTable = ({idWell, idCategory, title, columns, values, update setShowLoader(true) await MeasureService.insert(idWell, measureParams) setIsTableEditing(false) - updateMeasures() + updateMeasuresFunc() setShowLoader(false) } diff --git a/src/pages/Measure/columnsDrillingFluid.js b/src/pages/Measure/drillingFluidData.js similarity index 75% rename from src/pages/Measure/columnsDrillingFluid.js rename to src/pages/Measure/drillingFluidData.js index 41dc820..520e2c4 100644 --- a/src/pages/Measure/columnsDrillingFluid.js +++ b/src/pages/Measure/drillingFluidData.js @@ -31,3 +31,41 @@ export const columnsDrillingFluid = [ makeColumn(v("Смазка, %"), "grease",numericColumnOptions), makeColumn(v("Карбонат кальция, кг/м³"), "calciumCarbonate",numericColumnOptions), ]; + +export const drillingFluidDefaultData = { + idWell: 0, + key: 'drillingFluidDefaultData', + idCategory: 0, + timestamp: new Date().toISOString(), + isDefaultData: true, + data: { + "name": 0, + "temperature": 0, + "density": 0, + "conditionalViscosity": 0, + "r300": 0, + "r600": 0, + "r3r6": 0, + "dnsDpa": 0, + "plasticViscocity": 0, + "snsDpa": 0, + "r3r649С": 0, + "dns49Cdpa": 0, + "plasticViscocity49c": 0, + "sns49Cdpa": 0, + "mbt": 0, + "sand": 0, + "filtering": 0, + "crust": 0, + "ktk": 0, + "ph": 0, + "hardness": 0, + "chlorides": 0, + "pf": 0, + "mf": 0, + "pm": 0, + "fluidSolidPhase": 0, + "grease": 0, + "calciumCarbonate": 0 + } +} diff --git a/src/pages/Measure/index.jsx b/src/pages/Measure/index.jsx index 6f5a20c..b96e1fb 100644 --- a/src/pages/Measure/index.jsx +++ b/src/pages/Measure/index.jsx @@ -1,9 +1,12 @@ import { useState, useEffect } from 'react' -import { columnsMudDiagram} from './columnsMudDiagram' -import { columnsDrillingFluid} from './columnsDrillingFluid' +import { columnsMudDiagram} from './mudDiagramData' +import { mudDiagramDefaultData} from './mudDiagramData' +import { columnsDrillingFluid} from './drillingFluidData' +import { drillingFluidDefaultData} from './drillingFluidData' +import { columnsNnb } from './nnbData' +import { nnbDefaultData } from './nnbData' import { invokeWebApiWrapperAsync } from '../../components/factory' import { MeasureService } from '../../services/api' -import { columnsNnb } from './columnsNnb' import LoaderPortal from '../../components/LoaderPortal' import { MeasureTable } from './MeasureTable' @@ -18,11 +21,11 @@ export default function Measure({idWell}){ const measures = await MeasureService.getHisory(idWell) const fluids = measures.filter(el => el.idCategory === 1) - setFluidValues(fluids ?? []) + setFluidValues(fluids.length ? fluids : [drillingFluidDefaultData]) const muds = measures.filter(el => el.idCategory === 2) - setMudValues(muds ?? []) + setMudValues(muds.length ? muds : [mudDiagramDefaultData]) const nnbs = measures.filter(el => el.idCategory === 3) - setNnbValues(nnbs ?? []) + setNnbValues(nnbs.length ? nnbs : [nnbDefaultData]) } ,setShowLoader ,`Не удалось загрузить последние данные по скважине ${idWell}`) diff --git a/src/pages/Measure/columnsMudDiagram.js b/src/pages/Measure/mudDiagramData.js similarity index 75% rename from src/pages/Measure/columnsMudDiagram.js rename to src/pages/Measure/mudDiagramData.js index c759786..fd2b830 100644 --- a/src/pages/Measure/columnsMudDiagram.js +++ b/src/pages/Measure/mudDiagramData.js @@ -24,4 +24,36 @@ export const columnsMudDiagram = [ makeColumn(v('С5 пентан (отн%)'), 'pentane', numericColumnOptions), makeColumn(v('Мех. скорость'), 'mechanicalSpeed', numericColumnOptions), makeColumn('Предварительное заключение о насыщении по ГК', 'preliminaryConclusion', textColumnOptions), -] \ No newline at end of file +] + +export const mudDiagramDefaultData = { + idWell: 0, + key: 'mudDiagramDefaultData', + idCategory: 0, + timestamp: new Date().toISOString(), + isDefaultData: true, + data: { + "probeNumber": 0, + "probeExtractionDepth": 0, + "sandstone": 0, + "siltstone": 0, + "argillit": 0, + "brokenArgillit": 0, + "coal": 0, + "sand": 0, + "clay": 0, + "camstone": 0, + "cement": 0, + "summary": '-', + "drillingMud": 0, + "sludge": 0, + "maxSum": 0, + "methane": 0, + "ethane": 0, + "propane": 0, + "butane": 0, + "pentane": 0, + "mechanicalSpeed": 0, + "preliminaryConclusion": '-' + } +} \ No newline at end of file diff --git a/src/pages/Measure/columnsNnb.js b/src/pages/Measure/nnbData.js similarity index 77% rename from src/pages/Measure/columnsNnb.js rename to src/pages/Measure/nnbData.js index f309328..628da25 100644 --- a/src/pages/Measure/columnsNnb.js +++ b/src/pages/Measure/nnbData.js @@ -19,4 +19,31 @@ export const columnsNnb = [ makeColumn(v('Комментарий'), 'comment', numericColumnOptions), makeColumn(v('Разница вертикальных глубин\nмежду планом и фактом'), 'depthPlanFactDifference', numericColumnOptions), makeColumn(v('Расстояние в пространстве\nмежду планом и фактом'), 'distancePlanFactDifference', numericColumnOptions), -]; \ No newline at end of file +]; + +export const nnbDefaultData = { + idWell: 0, + key: 'nnbDefaultData', + idCategory: 0, + timestamp: new Date().toISOString(), + isDefaultData: true, + data: { + "depth": 0, + "zenithAngle": 0, + "magneticAzimuth": 0, + "trueAzimuth": 0, + "directAzimuth": 0, + "verticalDepth": 0, + "absoluteMark": 0, + "localNorthOffset": 0, + "localEastOffset": 0, + "outFallOffset": 0, + "offsetAzimuth": 0, + "areaIntensity": '-', + "offsetStopAngle": 0, + "zenithIntensity": 0, + "comment": '-', + "depthPlanFactDifference": 0, + "distancePlanFactDifference": 0 + } +} \ No newline at end of file