// 把后台的字段改成前端需要的
export function transformArray(arr: any, origA: any, origB: any, newA: any, newB: any) {
    return arr.map(node => {
        const newNode = {};
        for (const key in node) {
            if (key === origA) {
                newNode[newA] = node[key];
            } else if (key === origB) {
                newNode[newB] = node[key];
            } else if (Array.isArray(node[key])) {
                newNode[key] = transformArray(node[key], origA, origB, newA, newB);
            } else {
                newNode[key] = node[key];
            }
        }
        return newNode;
    });
}
export function convertTreeData(data, currentLevel = 0, maxLevel = 1) {
  return data.map((item) => {
    let newItem = { ...item };
    if (item.children && currentLevel < maxLevel) {
      newItem.children = convertTreeData(item.children, currentLevel + 1, maxLevel);
    } else {
      delete newItem.children;
    }
    return newItem;
  });
}
