/** * 角色管理 * */ $.namespace("role.rolemenufunc"); role.rolemenufunc.allData = null; // 页面初始化展示 role.rolemenufunc.init = function() { var str = ""; var jsonallData = $.parseJSON(role.rolemenufunc.allData); if (jsonallData) { for ( var i = 0; i < jsonallData.length; i++) { var all = jsonallData[i]; str += ""; str += "|--" + all.menuName + ""; if (all.sel) { str += ""; } else { str += ""; } str += ""; if (all.children) { for ( var m = 0; m < all.children.length; m++) { var menu = all.children[m]; str += ""; str += "|--" + menu.menuName + ""; if (menu.sel) { str += ""; } else { str += ""; } str += ""; } } } $("#divcontent").empty(); $("#divcontent").append(str); } // 返回按钮功能实现 role.rolemenufunc.back = function() { location.href = $.app + "/role/querylist.html"; }; // 全选按钮的功能实现 role.rolemenufunc.all = function() { $(".menuClass").each(function() { $(this).prop("checked", true); }); }; // 全不选按钮的功能实现 role.rolemenufunc.notall = function() { $(".menuClass").each(function() { $(this).prop("checked", false); }); }; // 保存分配给该角色的菜单 role.rolemenufunc.save = function() { var menuids = new Array(); $(".menuClass").each(function() { if ($(this).prop("checked")) { menuids.push($(this).val()); } }); $.ajax({ type : 'POST', url : $.app + "/role/saverolemenu.html", data : { roleId : $("#roleid").val(), menus : menuids.toString() }, success : function(data) { $.alert({ title : '提示', content : '保存成功', confirm : function() { location.href = $.app + "/role/querylist.html"; } }); } }); }; }; // 菜单联动效果 role.rolemenufunc.liandong = function(flag) { if ($("#" + flag).prop("checked")) { var fid = $("#" + flag).attr("fid"); if (fid) { $("#" + fid).prop("checked", true); } var ffid = $("#" + fid).attr("fid"); if (ffid) { $("#" + ffid).prop("checked", true); } } };