Исправлено отображение данных в таблице "Заполнить режимы текущей скважины" и в таблице на странице "Режимы"

This commit is contained in:
ts_salikhov 2022-09-28 14:33:34 +04:00
parent b74d6d1e4f
commit 0ce979fdc8
2 changed files with 65 additions and 1 deletions

View File

@ -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

View File

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