实现更改当前用户显示名称时,数据接口返回成功后脚本更新右上角登陆信息中的显示名称

This commit is contained in:
Argo-Lenovo 2016-10-25 12:16:00 +08:00
parent 2f7bb03626
commit acc0441957
4 changed files with 17 additions and 5 deletions

View File

@ -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) {

View File

@ -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 = "~/";
}
/// <summary>
///
/// </summary>
public int UserID { get; set; }
/// <summary>
///
/// </summary>
public string DisplayName { get; set; }
/// <summary>
///

View File

@ -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: 客户端点击保存用户后,要更新页面右上角用户显示名称
});

View File

@ -33,6 +33,7 @@
<img alt="" src="../content/images/logo6.jpg">
<span class="username">@Model.DisplayName</span>
<b class="caret"></b>
<input id="userId" type="text" class="hide" value="@Model.UserID"/>
</a>
<ul class="dropdown-menu extended logout">
<div class="log-arrow-up"></div>