From 1b33b6683f15bbd974b91dd9911befe80566d8ba Mon Sep 17 00:00:00 2001 From: KharchenkoVV Date: Tue, 3 Aug 2021 17:47:46 +0500 Subject: [PATCH] =?UTF-8?q?CF2-40:=20=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB?= =?UTF-8?q?=D0=B5=D0=BD=D0=BE=20=D1=81=D0=BE=D1=85=D1=80=D0=B0=D0=BD=D0=B5?= =?UTF-8?q?=D0=BD=D0=B8=D0=B5=20'=D0=9F=D0=BE=D1=81=D0=BB=D0=B5=D0=B4?= =?UTF-8?q?=D0=BD=D0=B8=D1=85=20=D0=B4=D0=B0=D0=BD=D0=BD=D1=8B=D1=85'=20?= =?UTF-8?q?=D0=B4=D0=BB=D1=8F=20=D0=B1=D1=83=D1=80=D0=BE=D0=B2=D0=BE=D0=B3?= =?UTF-8?q?=D0=BE=20=D1=80=D0=B0=D1=81=D1=82=D0=B2=D0=BE=D1=80=D0=B0.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../{ => modalWindows}/DrillingFluid.jsx | 89 ++++++++++++++++--- .../{ => modalWindows}/MudDiagram.jsx | 4 +- src/components/{ => modalWindows}/Nnb.jsx | 5 +- src/pages/LastData.jsx | 8 +- src/services/api/models/FluidDataDto.ts | 56 ++++++------ src/services/api/models/MudDiagramDataDto.ts | 4 +- 6 files changed, 116 insertions(+), 50 deletions(-) rename src/components/{ => modalWindows}/DrillingFluid.jsx (72%) rename src/components/{ => modalWindows}/MudDiagram.jsx (98%) rename src/components/{ => modalWindows}/Nnb.jsx (97%) diff --git a/src/components/DrillingFluid.jsx b/src/components/modalWindows/DrillingFluid.jsx similarity index 72% rename from src/components/DrillingFluid.jsx rename to src/components/modalWindows/DrillingFluid.jsx index 39c4c61..65ce6e0 100644 --- a/src/components/DrillingFluid.jsx +++ b/src/components/modalWindows/DrillingFluid.jsx @@ -1,24 +1,22 @@ -import { useState } from 'react'; +import { useState, useEffect } from 'react'; import { useParams } from "react-router-dom"; import {Table, Input, Form, Popconfirm, Typography } from 'antd' -import { makeColumn } from './factory' -import { FluidService } from '../services/api/services/FluidService'; +import { makeColumn } from '../factory' +import { FluidService } from '../../services/api/services/FluidService'; +import notify from "../notify" -const originDataPlan = [ - { +const originDataPlan = { key: '8', name: 'План', temperature: '', density: '', conditionalViscosity: '', r300: '', r600: '', r3r6: '', dnsDpa: '', plasticViscocity: '', snsDpa: '', r3r649С: '', dns49Cdpa: '', plasticViscocity49c: '', sns49Cdpa: '', mbt: '', sand: '', filter: '', crust: '', ktk: '', ph: '', hardness: '', chlorides: '', pf: '', mf: '', pm: '', fluidSolidPhase: '', grease: '', calciumCarbonate: '' } -] -const originDataFact = [ - { + +const originDataFact = { key: '9', name: 'Факт', temperature: '', density: '', conditionalViscosity: '', r300: '', r600: '', r3r6: '', dnsDpa: '', plasticViscocity: '', snsDpa: '', r3r649С: '', dns49Cdpa: '', plasticViscocity49c: '', sns49Cdpa: '', mbt: '', sand: '', filter: '', crust: '', ktk: '', ph: '', hardness: '', chlorides: '', pf: '', mf: '', pm: '', fluidSolidPhase: '', grease: '', calciumCarbonate: '' } -]; const EditableCell = ({ editing, @@ -65,10 +63,11 @@ export function DrillingFluid() { const [idCategory, setIdCategory] = useState(8); const [dataPlan, setDataPlan] = useState(originDataPlan) const [dataFact, setDataFact] = useState(originDataFact) + const [isUpdatingData, setIsUpdatingData] = useState(false) const [loader, setLoader] = useState(false) - const isEditing = (row) => row.key === editingKey; + const isEditing = (row) => row?.key === editingKey; const columns = [ makeColumn('Наименование', 'name', { dataIndex: 'name', align: 'center', className: 'small-font'}), @@ -129,6 +128,38 @@ export function DrillingFluid() { } ]; + useEffect(() => { + const update = async () => { + setLoader(true) + + try { + let response = await FluidService.get(id, 8) + response.key = 8 + response.name = 'План' + setDataPlan(response) + } + catch (ex) { + notify(`Не удалось загрузить плановые данные бурового раствора по скважине "${id}"`, 'error') + console.log(ex) + } + + try { + let response = await FluidService.get(id, 9) + response.key = 9 + response.name = 'Факт' + setDataFact(response) + } + catch (ex) { + notify(`Не удалось загрузить фактические данные бурового раствора по скважине "${id}"`, 'error') + console.log(ex) + } + + setIsUpdatingData(false) + setLoader(false) + } + update() + }, [isUpdatingData]) + const mergedColumns = columns.map((col) => { if (!col.editable) { return col; @@ -158,10 +189,44 @@ export function DrillingFluid() { }; const save = async (formData) => { + + const params = { + key: form.getFieldValue('key'), + name: idCategory === 8 ? 'План' : 'Факт', + temperature: form.getFieldValue('temperature'), + density: form.getFieldValue('density'), + conditionalViscosity: form.getFieldValue('conditionalViscosity'), + r300: form.getFieldValue('r300'), + r600: form.getFieldValue('r600'), + r3r6: form.getFieldValue('r3r6'), + dnsDpa: form.getFieldValue('dnsDpa'), + plasticViscocity: form.getFieldValue('plasticViscocity'), + snsDpa: form.getFieldValue('snsDpa'), + r3r649С: form.getFieldValue('r3r649С'), + dns49Cdpa: form.getFieldValue('dns49Cdpa'), + plasticViscocity49c: form.getFieldValue('plasticViscocity49c'), + sns49Cdpa: form.getFieldValue('sns49Cdpa'), + mbt: form.getFieldValue('mbt'), + sand: form.getFieldValue('sand'), + filtering: form.getFieldValue('filtering'), + crust: form.getFieldValue('crust'), + ktk: form.getFieldValue('ktk'), + ph: form.getFieldValue('ph'), + hardness: form.getFieldValue('hardness'), + chlorides: form.getFieldValue('chlorides'), + pf: form.getFieldValue('pf'), + mf: form.getFieldValue('mf'), + pm: form.getFieldValue('pm'), + fluidSolidPhase: form.getFieldValue('fluidSolidPhase'), + grease: form.getFieldValue('grease'), + calciumCarbonate: form.getFieldValue('calciumCarbonate') + } + try { setLoader(true) - await FluidService.put(`${id}`, idCategory, formData) + await FluidService.put(`${id}`, idCategory, params) + setIsUpdatingData(true) setLoader(false) setEditingKey('') @@ -179,7 +244,7 @@ export function DrillingFluid() { }, }} columns={mergedColumns} - dataSource={[dataPlan[0], dataFact[0]]} + dataSource={[dataPlan, dataFact]} size={'small'} bordered={true} pagination={false} diff --git a/src/components/MudDiagram.jsx b/src/components/modalWindows/MudDiagram.jsx similarity index 98% rename from src/components/MudDiagram.jsx rename to src/components/modalWindows/MudDiagram.jsx index 920ee89..369e9f1 100644 --- a/src/components/MudDiagram.jsx +++ b/src/components/modalWindows/MudDiagram.jsx @@ -1,8 +1,8 @@ import { useState } from 'react'; import { useParams } from "react-router-dom"; import { Table, Input, Form, Popconfirm, Typography } from 'antd' -import { makeColumn } from './factory' -import { MudDiagramService } from '../services/api/services/MudDiagramService'; +import { makeColumn } from '../factory' +import { MudDiagramService } from '../../services/api/services/MudDiagramService'; const originData = [ { diff --git a/src/components/Nnb.jsx b/src/components/modalWindows/Nnb.jsx similarity index 97% rename from src/components/Nnb.jsx rename to src/components/modalWindows/Nnb.jsx index b4389ae..99291d0 100644 --- a/src/components/Nnb.jsx +++ b/src/components/modalWindows/Nnb.jsx @@ -1,8 +1,8 @@ import { useState } from 'react' import { useParams } from "react-router-dom"; import {Table, Input, Form, Popconfirm, Typography } from 'antd' -import { makeColumn } from './factory' -import { NnbDataService } from '../services/api/services/NnbDataService'; +import { makeColumn } from '../factory' +import { NnbDataService } from '../../services/api/services/NnbDataService'; const originData = [ { @@ -53,6 +53,7 @@ export function Nnb() { const [form] = Form.useForm(); const [editingKey, setEditingKey] = useState(''); const [data, setData] = useState(originData) + const [isUpdatingData, setIsUpdatingData] = useState(false) const [loader, setLoader] = useState(false) diff --git a/src/pages/LastData.jsx b/src/pages/LastData.jsx index 9b3a9c8..543951d 100644 --- a/src/pages/LastData.jsx +++ b/src/pages/LastData.jsx @@ -1,11 +1,9 @@ import {Button, Modal, Checkbox } from "antd"; -import {DrillingFluid} from "../components/DrillingFluid"; +import {DrillingFluid} from "../components/modalWindows/DrillingFluid"; import {useState, useEffect} from "react"; -import {useParams} from "react-router-dom" -import {SludgeDiagram} from "../components/MudDiagram"; -import {Nnb} from "../components/Nnb" +import {SludgeDiagram} from "../components/modalWindows/MudDiagram"; +import {Nnb} from "../components/modalWindows/Nnb" import Disposition from "../components/Disposition"; -import notify from "../components/notify" export default function LastData() { diff --git a/src/services/api/models/FluidDataDto.ts b/src/services/api/models/FluidDataDto.ts index 5c893f9..b37a561 100644 --- a/src/services/api/models/FluidDataDto.ts +++ b/src/services/api/models/FluidDataDto.ts @@ -3,31 +3,33 @@ /* eslint-disable */ export type FluidDataDto = { - temperature?: string | null; - density?: string | null; - conditionalViscosity?: string | null; - r300?: string | null; - r600?: string | null; - r3r6?: string | null; - dnsDpa?: string | null; - plasticViscocity?: string | null; - snsDpa?: string | null; - 'r3r649С'?: string | null; - dns49Cdpa?: string | null; - plasticViscocity49c?: string | null; - sns49Cdpa?: string | null; - mbt?: string | null; - sand?: string | null; - filtering?: string | null; - crust?: string | null; - ktk?: string | null; - ph?: string | null; - hardness?: string | null; - chlorides?: string | null; - pf?: string | null; - mf?: string | null; - pm?: string | null; - fluidSolidPhase?: string | null; - grease?: string | null; - calciumCarbonate?: string | null; + key?: number; + name?: string | null; + temperature?: number; + density?: number; + conditionalViscosity?: number; + r300?: number; + r600?: number; + r3r6?: number; + dnsDpa?: number; + plasticViscocity?: number; + snsDpa?: number; + 'r3r649С'?: number; + dns49Cdpa?: number; + plasticViscocity49c?: number; + sns49Cdpa?: number; + mbt?: number; + sand?: number; + filtering?: number; + crust?: number; + ktk?: number; + ph?: number; + hardness?: number; + chlorides?: number; + pf?: number; + mf?: number; + pm?: number; + fluidSolidPhase?: number; + grease?: number; + calciumCarbonate?: number; } \ No newline at end of file diff --git a/src/services/api/models/MudDiagramDataDto.ts b/src/services/api/models/MudDiagramDataDto.ts index 9157450..5847cc7 100644 --- a/src/services/api/models/MudDiagramDataDto.ts +++ b/src/services/api/models/MudDiagramDataDto.ts @@ -14,7 +14,7 @@ export type MudDiagramDataDto = { clay?: number; camstone?: number; cement?: number; - summary?: string | null; + summary?: number; drillingMud?: number; sludge?: number; maxSum?: number; @@ -24,5 +24,5 @@ export type MudDiagramDataDto = { butane?: number; pentane?: number; mechanicalSpeed?: number; - preliminaryConclusion?: string | null; + preliminaryConclusion?: number; } \ No newline at end of file