From acc04419574f25bbc8750c77dfb0afd86136a17c Mon Sep 17 00:00:00 2001 From: Argo-Lenovo Date: Tue, 25 Oct 2016 12:16:00 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=9E=E7=8E=B0=E6=9B=B4=E6=94=B9=E5=BD=93?= =?UTF-8?q?=E5=89=8D=E7=94=A8=E6=88=B7=E6=98=BE=E7=A4=BA=E5=90=8D=E7=A7=B0?= =?UTF-8?q?=E6=97=B6=EF=BC=8C=E6=95=B0=E6=8D=AE=E6=8E=A5=E5=8F=A3=E8=BF=94?= =?UTF-8?q?=E5=9B=9E=E6=88=90=E5=8A=9F=E5=90=8E=E8=84=9A=E6=9C=AC=E6=9B=B4?= =?UTF-8?q?=E6=96=B0=E5=8F=B3=E4=B8=8A=E8=A7=92=E7=99=BB=E9=99=86=E4=BF=A1?= =?UTF-8?q?=E6=81=AF=E4=B8=AD=E7=9A=84=E6=98=BE=E7=A4=BA=E5=90=8D=E7=A7=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Bootstrap.Admin/Content/js/framework.js | 4 +++- Bootstrap.Admin/Models/HeaderBarModel.cs | 8 +++++++- Bootstrap.Admin/Scripts/Users.js | 9 ++++++--- Bootstrap.Admin/Views/Shared/Header.cshtml | 1 + 4 files changed, 17 insertions(+), 5 deletions(-) diff --git a/Bootstrap.Admin/Content/js/framework.js b/Bootstrap.Admin/Content/js/framework.js index 9bda4813..dcc548cd 100644 --- a/Bootstrap.Admin/Content/js/framework.js +++ b/Bootstrap.Admin/Content/js/framework.js @@ -115,11 +115,13 @@ cancelButtonText: "取消" }, function () { var iDs = arrselections.map(function (element, index) { return element.ID }).join(","); + options.IDs = iDs; $.ajax({ url: options.url, data: { "": iDs }, type: 'DELETE', success: function (result) { + if ($.isFunction(options.success)) options.success('del', options); if (result) setTimeout(function () { swal("成功!", "删除数据", "success"); $(options.bootstrapTable).bootstrapTable('refresh'); }, 100); else setTimeout(function () { swal("失败", "删除数据", "error"); }, 200); }, @@ -140,7 +142,7 @@ type: 'POST', success: function (result) { if (result) { - if ($.isFunction(options.success)) options.success(options.data); + if ($.isFunction(options.success)) options.success('save', options.data); if (options.bootstrapTable.constructor === String && options.data.ID.constructor === String) { // 更新表格 if (options.data.ID > 0) { diff --git a/Bootstrap.Admin/Models/HeaderBarModel.cs b/Bootstrap.Admin/Models/HeaderBarModel.cs index 0ac3de60..80058ba4 100644 --- a/Bootstrap.Admin/Models/HeaderBarModel.cs +++ b/Bootstrap.Admin/Models/HeaderBarModel.cs @@ -10,12 +10,18 @@ namespace Bootstrap.Admin.Models { public HeaderBarModel() { - DisplayName = UserHelper.RetrieveUsersByName(HttpContext.Current.User.Identity.Name).DisplayName; + var user = UserHelper.RetrieveUsersByName(HttpContext.Current.User.Identity.Name); + DisplayName = user.DisplayName; + UserID = user.ID; HomeUrl = "~/"; } /// /// /// + public int UserID { get; set; } + /// + /// + /// public string DisplayName { get; set; } /// /// diff --git a/Bootstrap.Admin/Scripts/Users.js b/Bootstrap.Admin/Scripts/Users.js index 637b2373..b10a221f 100644 --- a/Bootstrap.Admin/Scripts/Users.js +++ b/Bootstrap.Admin/Scripts/Users.js @@ -8,7 +8,12 @@ Password: "password", DisplayName: "displayName" } - }) + }), + success: function (src, data) { + if (src === 'save' && data.ID === $('#userId').val()) { + $('.username').text(data.DisplayName); + } + } }); $('table').smartTable({ @@ -41,6 +46,4 @@ maxlength: 50 } }); - - //TODO: 客户端点击保存用户后,要更新页面右上角用户显示名称 }); \ No newline at end of file diff --git a/Bootstrap.Admin/Views/Shared/Header.cshtml b/Bootstrap.Admin/Views/Shared/Header.cshtml index 2f6a75b5..25cb49dc 100644 --- a/Bootstrap.Admin/Views/Shared/Header.cshtml +++ b/Bootstrap.Admin/Views/Shared/Header.cshtml @@ -33,6 +33,7 @@ @Model.DisplayName +