diff --git a/Bootstrap.Admin/Content/js/framework.js b/Bootstrap.Admin/Content/js/framework.js index 80f88be2..c05c8547 100644 --- a/Bootstrap.Admin/Content/js/framework.js +++ b/Bootstrap.Admin/Content/js/framework.js @@ -17,7 +17,7 @@ if ($.isArray(ele)) { for (index in ele) { if (ele[index].id === undefined) { - window.console.log('options.click.assign[{0}].{1}.id 未设置控件id', index, name); + window.console.log('options.click.assign[{0}].{1}.id 未设置控件id', ele[index].id, name); continue; } cId = ele[index]['id']; @@ -227,9 +227,15 @@ return $.format('
', element.ID, element.RoleName, element.Checked, element.Description); }).join(''); data.callback(html); + return; } } - else { data.callback(false); } + else if ($.isPlainObject(data.callback) && data.callback.modal !== undefined) { + $("#" + data.callback.modal).modal('hide'); + } + if (result) { swal("成功", "授权角色", "success"); } + else { swal("失败", "授权角色", "error"); } + data.callback(result); }, error: function (XMLHttpRequest, textStatus, errorThrown) { if ($.isFunction(data.callback)) data.callback(false); @@ -264,14 +270,18 @@ if ($.isFunction(data.callback)) { if ($.isArray(result)) { var html = $.map(result, function (element, index) { - return $.format('
{1}
', element.ID, element.DisplayName, element.Checked); + return $.format('
', element.ID, element.DisplayName, element.Checked); }).join(''); data.callback(html); + return; } - else - data.callback(result); } - else { data.callback(false); } + else if ($.isPlainObject(data.callback) && data.callback.modal !== undefined) { + $("#" + data.callback.modal).modal('hide'); + } + if (result) { swal("成功", "授权用户", "success"); } + else { swal("失败", "授权用户", "error"); } + data.callback(result); }, error: function (XMLHttpRequest, textStatus, errorThrown) { if ($.isFunction(data.callback)) data.callback(false); diff --git a/Bootstrap.Admin/Scripts/Menus.js b/Bootstrap.Admin/Scripts/Menus.js index f8da8a4f..94fdb17f 100644 --- a/Bootstrap.Admin/Scripts/Menus.js +++ b/Bootstrap.Admin/Scripts/Menus.js @@ -29,14 +29,7 @@ var roleIds = $('#dialogRole :checked').map(function (index, element) { return $(element).val(); }).toArray().join(','); - Role.saveRolesByMenuId(menuId, roleIds, function (result) { - if (result) { - $('#dialogRole').modal("hide"); - swal("成功", "修改角色", "success"); - } else { - swal("失败", "修改角色", "error"); - } - }); + Role.saveRolesByMenuId(menuId, roleIds, { modal: 'dialogRole' }); } }] } diff --git a/Bootstrap.Admin/Scripts/Roles.js b/Bootstrap.Admin/Scripts/Roles.js index 8167cb05..58ab1bfb 100644 --- a/Bootstrap.Admin/Scripts/Roles.js +++ b/Bootstrap.Admin/Scripts/Roles.js @@ -30,22 +30,9 @@ var userIds = $('#dialogUser :checked').map(function (index, element) { return $(element).val(); }).toArray().join(','); - User.saveUsersByRoleId(roleId, userIds, function (result) { - if (result) { - $('#dialogUser').modal('hide'); - swal("成功", "修改用户", "success"); - } - else { - swal("失败", "修改用户", "error"); - } - }); + User.saveUsersByRoleId(roleId, userIds, { modal: 'dialogUser' }); } }] - }, - success: function (src, data) { - if (src === 'save' && data.ID === $('#roleId').val()) { - //$('.username').text(data.DisplayName); - } } }); diff --git a/Bootstrap.Admin/Scripts/Users.js b/Bootstrap.Admin/Scripts/Users.js index 8d614e08..ad4f7abc 100644 --- a/Bootstrap.Admin/Scripts/Users.js +++ b/Bootstrap.Admin/Scripts/Users.js @@ -31,14 +31,7 @@ var roleIds = $('#dialogRole :checked').map(function (index, element) { return $(element).val(); }).toArray().join(','); - Role.saveRolesByUserId(userId, roleIds, function (result) { - if (result) { - $('#dialogRole').modal("hide"); - swal("成功", "修改角色", "success"); - } else { - swal("失败", "修改角色", "error"); - } - }); + Role.saveRolesByUserId(userId, roleIds, { modal: 'dialogRole' }); } }] },