Blogger Information
Blog 47
fans 0
comment 2
visits 102663
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
部门员工的递归算法
拾一枝樱花的博客
Original
1315 people have browsed it
  1. 数据格式
  2. data:[
  3. {
  4. id: "a0a5c642e45c452b821d2f13c1ff2515",
  5. label: "人力资源部",
  6. pid: "",
  7. disabled: true,
  8. children: [
  9. {
  10. children:[]
  11. disabled:true
  12. id:"e30b8078383d4ddd8ccc2ab4fd8c2b52"
  13. label:"张大三"
  14. pid:"a0a5c642e45c452b821d2f13c1ff2515"
  15. }
  16. ]
  17. }
  18. 递归算法
  19. var recursiveFunction = function(){
  20. var ul='';
  21. var appednMenu = function (data) {
  22. data.forEach(function (item) {
  23. if(item.deptChildList){
  24. ul+='<li>'+item.name+'<ul>';
  25. appednMenu(item.deptChildList);
  26. ul+='</ul>';
  27. for(var i in item.userChildList){
  28. ul += '<input type="checkbox" name="person" value="'+item.userChildList[i].id+'" title="'+item.userChildList[i].name+'" lay-skin="primary">';
  29. }
  30. ul+= '</li>';
  31. }else {
  32. ul+='<li>'+item.name+'</li>';
  33. }
  34. })
  35. };
  36. appednMenu(res.data.departmentArray);
  37. $('.tree').html(ul);
  38. };
  39. recursiveFunction()
Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post