// 根据id, 取出此id的后代节点数据, 即[{id: '', name: '', parentid: ''}]
function getFlatTreeDescendantNodes(tree, id) {
  // eslint-disable-next-line
  if (typeof id === 'number') id = String(id);
  var descendants = [];
  function buildDescendants(tree, id) {
    for (var i = 0; i < tree.length; i++) {
      var item = tree[i];
      if (id && item['parentid'] === id.toString()) {
        descendants.push(item);
        buildDescendants(tree, item['id']);
      }
    }
  }
  buildDescendants(tree, id);
  return descendants;
}
export default getFlatTreeDescendantNodes;