企业🤖AI智能体构建引擎,智能编排和调试,一键部署,支持私有化部署方案 广告
``` getSummaries(param) { const { columns, data } \= param; const sums \= \[\]; var size \= '' var length \= '' columns.forEach((column, index) \=> { const values \= data.map(item \=> Number(item\[column.property\])); if (!values.every(value \=> isNaN(value))) { sums\[index\] \= values.reduce((prev, curr) \=> { const value \= Number(curr); if (!isNaN(value)) { return prev + curr; } else { return prev; } }, 0); sums\[index\]; length \= data.length } else { sums\[index\] \= 'N/A'; } }); return \['合计', (sums\[1\] / length).toFixed(2) + 'kW·h',(sums\[2\] / length).toFixed(2) + 'kW·h',(sums\[3\] / length).toFixed(2) + '%'\]; } ```