exportfunctiontransformData(inputStr) {
constrows=inputStr.map(item=> {
returndataSourceList.map(_item=> {
returnitem[_item]
}).filter(item=> {
return!!item });
});
constres= {
children: {}
};
rows.forEach(row=> {
row.reduce((pre, cur) => {
if (!pre.children[cur]) {
pre.children[cur] = {
label: cur,
value: pre.value?`${pre.value}_${cur}` : cur,
children: {}
}
}
returnpre.children[cur];
}, res);
});
constmapToArray= (map) => {
returnObject.values(map).map(item=> {
if (item.children) {
item.children=mapToArray(item.children);
}
if (Object.keys(item.children).length===0) {
deleteitem.children;
}
returnitem;
});
};
returnmapToArray(res.children);
}