实时数据逻辑优化

This commit is contained in:
fengrong 2024-11-08 17:02:35 +08:00
parent 8280b6f4ca
commit f150ea3be4

View File

@ -564,17 +564,8 @@ const getTableData = () => {
const value = tsnapshotVoObject[itemKey]?.[attributeCodeLower];
let formattedValue = value !== undefined ? (value % 1 === 0 ? value : value.toFixed(3)) : '-';
if (enumStore.keys.includes(item1.attributeCode)) {
formattedValue = enumStore.data[item1.attributeCode][formattedValue]
formattedValue = enumStore.data[item1.attributeCode][formattedValue]?enumStore.data[item1.attributeCode][formattedValue]:'-'
}
/*const newItem = {};
for (const key in item) {
if (item.hasOwnProperty(key)) {
//newItem[key] = item[key];
newItem['id'] = item['id'];
newItem['name'] = item['name'];
}
}
newItem[attributeCodeLower] = formattedValue;*/
if(attributeCodeLower==='ipitchangle'||
attributeCodeLower==='ipitchangle1'||
attributeCodeLower==='ipitchangle2'||
@ -582,7 +573,6 @@ const getTableData = () => {
arr[i] = { ...item, [attributeCodeLower]: formattedValue,[ipitchangle]: ipitchanglevalue};
}else{
arr[i] = { ...item, [attributeCodeLower]: formattedValue};
//arr[i]=newItem
}
}
}
@ -606,11 +596,32 @@ const downFun=(tableColumn,tableData)=>{
const { id, ...rest } = item;
return rest;
});
if (!tableColumn.length || !itemsWithoutAge.length) {
return [];
}
const columnSet = new Set(tableColumn.map(item => item.prop));
const result = [];
try {
itemsWithoutAge.forEach((item) => {
const newItem = {};
for (const itemKey in item) {
if (columnSet.has(itemKey)) {
newItem[itemKey] = item[itemKey];
}
}
if (Object.keys(newItem).length > 0) {
result.push(newItem);
}
});
} catch (error) {
console.error('Error in code execution:', error);
return [];
}
let addobj = {}
tableColumn.map((v, i) => {
addobj['rowData' + i] = v.label
})
let tableDatadown = JSON.parse(JSON.stringify(itemsWithoutAge))
let tableDatadown = JSON.parse(JSON.stringify(result))
tableDatadown.unshift(addobj)
let str = ``;
for(let i = 0; i < tableDatadown.length; i++) {