123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122 |
- /**
- * 角色管理
- *
- */
- $.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;
- }
|