/**
|
* 扁平化 Children 结构数组,展开 Children 内容
|
* @param tableData
|
* @returns
|
*/
|
const flatten = (tableData, removeChild, children = 'Children') => {
|
const flattenedData = [];
|
|
for (const item of tableData) {
|
flattenedData.push(item);
|
if (item[children] && item[children].length !== 0) {
|
flattenedData.push(...flatten(item[children]));
|
}
|
if (removeChild) {
|
Reflect.deleteProperty(item, children);
|
}
|
}
|
|
return flattenedData;
|
};
|