/** * 角色管理 * */ $.namespace("role.main"); role.main.init = function() { // 把form传入,构造翻页控件 pageinfo($("#roleform")); } // 查询 role.main.search = function() { $("#currentpage").val(1); //console.log($("#roleform").serialize()); $("#roleform").submit(); } // 删除 role.main.del = function(roleid) { $.confirm({ title : '提示', content : '确认删除?', confirm : function() { $.ajax({ url : basePath + '/role/delOneRole.html', type : "post", data : { roleId : roleid }, dataType : "json", success : function(data) {// ajax返回的数据 if (data.success) { location.href = basePath + '/role/querylist.html'; } else { $.alert({ title : '提示', content : '删除失败', }); } } }); } }); } //清空新增输入 role.main.clear = function() { $("#htitle").html('角色新增'); $("#editid").val(""); $("#editroleName").val(""); $("#editroleCode").val(""); /*$("#editroleSort").val("");*/ } // 获取编辑对象内容 role.main.edit = function(data) { $.post(basePath + "/role/edit.html", { id : data }, function(data) { $("#htitle").html('角色修改'); if (data) { for ( var a in data) { if ($("#edit" + a)) { $("#edit" + a).val(data[a]); } } } }, "json"); } // 编辑和新增保存 role.main.save = function save() { var rolename=$("#editroleName").val(); if(rolename==''){ $.alert({ title : '提示', content : '角色名不能为空' }); return; } var rolecode=$("#editroleCode").val(); if(rolecode==''){ $.alert({ title : '提示', content : '角色编码不能为空' }); return; } $.ajax({ url : basePath + "/role/saveRole.html", data : $("#addform").serialize(), type : "post", dataType : "json", success : function(data) {// ajax返回的数据 if (data.success) { $.alert({ title : '提示', content : '保存成功', confirm : function() { location.href = basePath + '/role/querylist.html'; } }); } else { $.alert({ title : '提示', content : data.message, confirm : function() { } }); } } }); } role.main.grant = function(data) { location.href = basePath + "/role/rolegrant.html?roleId=" + data; }