旭捷内部项目管理系统
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.

96 lines
2.8 KiB

10 months ago
  1. //公共参数
  2. var authTrees;//权限树结构
  3. var titleName = $("#current_titleName").val();
  4. //页面加载完事件
  5. $(function(){
  6. if(titleName != null && titleName != ""){
  7. $("#titleName").text(titleName);
  8. }else {
  9. window.location.href="/login";
  10. }
  11. getAuthTrees()
  12. // getMenu();
  13. //加载权限树
  14. // getAuthTree();
  15. //加载树结构标签
  16. initAuthMenu();
  17. //清除所有cookie函数
  18. // cleanCookie();
  19. });
  20. function getAuthTrees(){
  21. var returnPage = JSON.parse(localStorage.getItem("returnPage"))
  22. var titleName = JSON.parse(localStorage.getItem("titleName"))
  23. if ( returnPage != null ){
  24. authTrees = returnPage
  25. $("#titleName").text(titleName);
  26. }else {
  27. var menuId = $("#menuId").val();
  28. var list = JSON.parse(localStorage.getItem("authTrees"))
  29. var filter = list.filter(item => item.menuId==menuId );
  30. authTrees = filter[0].list
  31. titleName = filter[0].name
  32. returnPage = filter[0].list
  33. localStorage.setItem("returnPage",JSON.stringify(returnPage))
  34. localStorage.setItem("titleName",JSON.stringify(titleName))
  35. }
  36. /*
  37. var menuId = $("#menuId").val();
  38. var list = JSON.parse(localStorage.getItem("authTrees"))
  39. var filter = list.filter(item => item.menuId =menuId );
  40. authTrees = filter[0].list
  41. var titleName = filter[0].name
  42. var returnPage = JSON.parse(filter[0].list)
  43. localStorage.setItem("returnPage",returnPage)
  44. localStorage.setItem("titleName",titleName)
  45. */
  46. }
  47. //初始化树结构
  48. function initAuthMenu(){
  49. //权限的标签
  50. var authTags = '';
  51. //循环处理标签
  52. if(authTrees != null){
  53. for(var i = 0; i < authTrees.length; i++){
  54. //处理标签逻辑
  55. authTag = processMenuTags(authTrees[i]);
  56. authTags += authTag;
  57. }
  58. //替换标签
  59. $("#main-menu").append(authTags);
  60. }
  61. }
  62. //处理权限的菜单
  63. function processMenuTags(authTree){
  64. //公共参数
  65. var id = authTree.menuId;
  66. var menuId = $("#menuId").val();
  67. var url = ""
  68. var currentName = "&titleName=" + authTree.name + "&superiorName=" + titleName + "&superiorId=" + menuId;
  69. if(authTree.type == 0){
  70. url = "/pda/publicMenu"
  71. }else {
  72. url = authTree.url
  73. }
  74. url = url + "?menuId=" + authTree.menuId + "&token=" + $.cookie("token") + currentName;
  75. var name = authTree.name;
  76. var authTag = '<div data-v-45aee492="" class="ivu-row" style ="margin: 20px;margin-top: -3px;">';
  77. authTag += '<div data-v-45aee492="" class="ivu-col ivu-col-span-13 ivu-col-offset-5" style="width: 105%;margin-left: -7px;">';
  78. authTag += '<a data-v-45aee492="" type="button" id="'+id+'" href="'+url+'"';
  79. authTag += 'class="ivu-btn ivu-btn-primary ivu-btn-long" >'; //style = "border-color: #FF7F24;"
  80. authTag += '<span style="font-size: 20px">'+name+'</span>';
  81. authTag += '</a></div></div>';
  82. return authTag;
  83. }
  84. // 返回时跳转的页面
  85. function getPageUrl(){
  86. var url = '/pda/pdaBase'
  87. var data = {}
  88. axget(url, data, ()=>{})
  89. }