【发布时间】:2018-08-09 07:42:43
【问题描述】:
您好,我有这样的数据
newProcessData: [
{
"processType": "ABC Type1",
"processSource": "ABC Source1",
"groupName": "G1",
"breakdowns": [
{
"size": 'S",
"quantity": 20,
},
],
},{
"processType": "ABC Type2",
"processSource": "ABC Source2",
"groupName": "G2",
"history": [
{
"size": 'S",
"quantity": 20,
},{
"size": 'XL",
"quantity": 20,
}
],
"breakdowns": [
{
"size": 'S",
"quantity": 20,
},{
"size": 'XL",
"quantity": 20,
}
],
},
];
首先我做 GroupData 以按 groupName 对数据进行排序
let groupByData = _.groupBy(newProcessData, 'groupName')
然后我使用 Lodash map 填充所有数组数据,
我的目标是使用 _.sumBy 显示故障数量、历史记录并显示流程类型
{_.map(groupByData, (v, idx) => {
<Table>
<TableBody displayRowCheckbox={false}>
<TableRow>
<TableRowColumn style={{textAlign: 'right'}}>{ " sum of all the quantity of breakdowns"}</TableRowColumn>
<TableRowColumn style={{textAlign: 'right'}}>{ " sum of all the quantity of history"}</TableRowColumn>
<TableRowColumn style={{textAlign: 'right'}}>{ "Get the processType name"}</TableRowColumn>
</TableRow>
</TableBody>
</Table>
})}
任何帮助将不胜感激
【问题讨论】:
标签: reactjs ecmascript-6 lodash