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} />