感谢 reduce函数学会了
const taskgrouplist = data.reduce((result, item) => {
const existingGroup = result.find(group => group.sid === item.rwzid);
if (existingGroup) {
existingGroup.taskLists.push({
sid: item.rwid,
groupid: item.rwzid,
taskName: item.rwmc
});
} else {
result.push({
sid: item.rwzid,
groupName: item.rwzmc,
taskLists: [{
sid: item.rwid,
groupid: item.rwzid,
taskName: item.rwmc
}]
});
}
return result;
}, []);