From 0ce979fdc812a45dbc382457aa08d81dac727082 Mon Sep 17 00:00:00 2001 From: ts_salikhov Date: Wed, 28 Sep 2022 14:33:34 +0400 Subject: [PATCH] =?UTF-8?q?=D0=98=D1=81=D0=BF=D1=80=D0=B0=D0=B2=D0=BB?= =?UTF-8?q?=D0=B5=D0=BD=D0=BE=20=D0=BE=D1=82=D0=BE=D0=B1=D1=80=D0=B0=D0=B6?= =?UTF-8?q?=D0=B5=D0=BD=D0=B8=D0=B5=20=D0=B4=D0=B0=D0=BD=D0=BD=D1=8B=D1=85?= =?UTF-8?q?=20=D0=B2=20=D1=82=D0=B0=D0=B1=D0=BB=D0=B8=D1=86=D0=B5=20"?= =?UTF-8?q?=D0=97=D0=B0=D0=BF=D0=BE=D0=BB=D0=BD=D0=B8=D1=82=D1=8C=20=D1=80?= =?UTF-8?q?=D0=B5=D0=B6=D0=B8=D0=BC=D1=8B=20=D1=82=D0=B5=D0=BA=D1=83=D1=89?= =?UTF-8?q?=D0=B5=D0=B9=20=D1=81=D0=BA=D0=B2=D0=B0=D0=B6=D0=B8=D0=BD=D1=8B?= =?UTF-8?q?"=20=D0=B8=20=D0=B2=20=D1=82=D0=B0=D0=B1=D0=BB=D0=B8=D1=86?= =?UTF-8?q?=D0=B5=20=D0=BD=D0=B0=20=D1=81=D1=82=D1=80=D0=B0=D0=BD=D0=B8?= =?UTF-8?q?=D1=86=D0=B5=20"=D0=A0=D0=B5=D0=B6=D0=B8=D0=BC=D1=8B"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/Table/EditableTable.jsx | 20 ++++++++- src/pages/WellOperations/WellDrillParams.jsx | 46 ++++++++++++++++++++ 2 files changed, 65 insertions(+), 1 deletion(-) diff --git a/src/components/Table/EditableTable.jsx b/src/components/Table/EditableTable.jsx index a94955e..2d75dcd 100755 --- a/src/components/Table/EditableTable.jsx +++ b/src/components/Table/EditableTable.jsx @@ -113,10 +113,28 @@ export const EditableTable = memo(({ const newData = [...data] const index = newData.findIndex((item) => record.key === item.key) const item = newData[index] - const newItem = { ...item, ...row } + let newItem = { ...item, ...row } newData.splice(index, 1, newItem) + if (otherTableProps.objRowType) { + const newObj = {} + const objRowType = otherTableProps.objRowType + for (const itemElement in objRowType) { + if (typeof objRowType[itemElement] === 'object') { + for (const el in objRowType[itemElement]) { + if (!newObj[itemElement]) { + newObj[itemElement] = {} + } + newObj[itemElement][el] = newItem[itemElement + el[0].toUpperCase() + el.slice(1)] ?? objRowType[itemElement][el] + } + } else { + newObj[itemElement] = newItem[itemElement] + } + } + newItem = newObj + } + if (item.key === newRowKeyValue) item.key = newRowKeyValue + newData.length diff --git a/src/pages/WellOperations/WellDrillParams.jsx b/src/pages/WellOperations/WellDrillParams.jsx index 7c7d7bb..65d3b59 100755 --- a/src/pages/WellOperations/WellDrillParams.jsx +++ b/src/pages/WellOperations/WellDrillParams.jsx @@ -54,6 +54,51 @@ export const getColumns = async (idWell) => { ] } +const objRowType = { + 'id': 0, + 'idWell': 0, + 'depth': { + 'min': 0, + 'max': 0 + }, + 'idWellSectionType': 0, + 'axialLoad': { + 'min': 0, + 'max': 0, + 'avg': 0, + 'isMax': false, + 'isMin': false, + }, + 'pressure': { + 'min': 0, + 'max': 0, + 'avg': 0, + 'isMax': false, + 'isMin': false, + }, + 'rotorTorque': { + 'min': 0, + 'max': 0, + 'avg': 0, + 'isMax': false, + 'isMin': false, + }, + 'rotorSpeed': { + 'min': 0, + 'max': 0, + 'avg': 0, + 'isMax': false, + 'isMin': false, + }, + 'flow': { + 'min': 0, + 'max': 0, + 'avg': 0, + 'isMax': false, + 'isMin': false, + } +} + export const WellDrillParams = memo(() => { const [params, setParams] = useState([]) const [showLoader, setShowLoader] = useState(false) @@ -108,6 +153,7 @@ export const WellDrillParams = memo(() => { onRowAdd={tableHandlers.add} onRowEdit={tableHandlers.edit} onRowDelete={tableHandlers.delete} + objRowType={objRowType} pagination={false} />