旭捷内部项目管理系统
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

25 lines
694 B

10 months ago
  1. // 根据父级编号获取 父级的父级的子级
  2. function getParent(tree , parentId ){
  3. var menuList = []
  4. var list = [];
  5. treeFindPath(tree,menuList);
  6. for (const menuListElement of menuList) {
  7. if(menuListElement.menuId == parentId){
  8. for (const menuListElement1 of menuList) {
  9. if (menuListElement1.parentId == menuListElement.menuId){
  10. list.push(menuListElement1);
  11. }
  12. }
  13. }
  14. }
  15. }
  16. // 树形转 list
  17. function treeFindPath(tree, path = []) {
  18. if (!tree) return []
  19. for (const data of tree) {
  20. path.push(data)
  21. this.treeFindPath(data.list, path)
  22. }
  23. return path
  24. }