menu.js 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. var prefix = ctx + "system/menu"
  2. window.onload = function() {
  3. loading();
  4. };
  5. function loading() {
  6. var columns = [
  7. {
  8. title : '菜单名称',
  9. field : 'menuName',
  10. width : '20%',
  11. formatter : function(row, index) {
  12. if(row.icon == null || row == "") {
  13. return row.menuName;
  14. } else {
  15. return '<i class="' + row.icon + '"></i> <span class="nav-label">' + row.menuName + '</span>';
  16. }
  17. }
  18. },
  19. {
  20. field : 'orderNum',
  21. title : '排序',
  22. width : '10%',
  23. },
  24. {
  25. field : 'url',
  26. title : '请求地址',
  27. width : '15%',
  28. },
  29. {
  30. title : '类型',
  31. field : 'menuType',
  32. width : '10%',
  33. formatter : function(item, index) {
  34. if (item.menuType == 'M') {
  35. return '<span class="label label-success">目录</span>';
  36. }
  37. if (item.menuType == 'C') {
  38. return '<span class="label label-primary">菜单</span>';
  39. }
  40. if (item.menuType == 'F') {
  41. return '<span class="label label-warning">按钮</span>';
  42. }
  43. }
  44. },
  45. {
  46. field: 'visible',
  47. title: '可见',
  48. width : '10%',
  49. formatter: function(row, index) {
  50. if (row.visible == 0) {
  51. return '<span class="label label-success">显示</span>';
  52. } else if (row.visible == 1) {
  53. return '<span class="label label-danger">隐藏</span>';
  54. }
  55. }
  56. },
  57. {
  58. field : 'perms',
  59. title : '权限标识',
  60. width : '15%',
  61. },
  62. {
  63. title : '操作',
  64. width : '20%',
  65. formatter : function(row, index) {
  66. var actions = [];
  67. actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="#" mce_href="#" onclick="edit(\'' + row.menuId + '\')"><i class="fa fa-edit"></i>编辑</a> ');
  68. actions.push('<a class="btn btn-info btn-xs ' + addFlag + '" href="#" onclick="add(\'' + row.menuId + '\')"><i class="fa fa-plus"></i>新增</a> ');
  69. actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="#" onclick="remove(\'' + row.menuId + '\')"><i class="fa fa-remove"></i>删除</a>');
  70. return actions.join('');
  71. }
  72. }];
  73. var url = prefix + "/list";
  74. $.initTreeTable('menuId', 'parentId', columns, url, false);
  75. }
  76. /*菜单管理-新增*/
  77. function add(menuId) {
  78. var url = prefix + '/add/' + menuId;
  79. layer_showAuto("新增菜单", url);
  80. }
  81. /*菜单管理-修改*/
  82. function edit(menuId) {
  83. var url = prefix + '/edit/' + menuId;
  84. layer_showAuto("修改菜单", url);
  85. }
  86. /*菜单管理-删除*/
  87. function remove(menuId) {
  88. layer.confirm("确定要删除菜单吗?",{icon: 3, title:'提示'},function(index){
  89. $.ajax({
  90. type : 'get',
  91. url: prefix + "/remove/" + menuId,
  92. success : function(r) {
  93. if (r.code == 0) {
  94. layer.msg(r.msg, { icon: 1, time: 1000 });
  95. loading();
  96. } else {
  97. layer.alert(r.msg, { icon: 2, title: "系统提示" });
  98. }
  99. }
  100. });
  101. });
  102. }