实现更改当前用户显示名称时,数据接口返回成功后脚本更新右上角登陆信息中的显示名称
This commit is contained in:
parent
2f7bb03626
commit
acc0441957
|
@ -115,11 +115,13 @@
|
||||||
cancelButtonText: "取消"
|
cancelButtonText: "取消"
|
||||||
}, function () {
|
}, function () {
|
||||||
var iDs = arrselections.map(function (element, index) { return element.ID }).join(",");
|
var iDs = arrselections.map(function (element, index) { return element.ID }).join(",");
|
||||||
|
options.IDs = iDs;
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: options.url,
|
url: options.url,
|
||||||
data: { "": iDs },
|
data: { "": iDs },
|
||||||
type: 'DELETE',
|
type: 'DELETE',
|
||||||
success: function (result) {
|
success: function (result) {
|
||||||
|
if ($.isFunction(options.success)) options.success('del', options);
|
||||||
if (result) setTimeout(function () { swal("成功!", "删除数据", "success"); $(options.bootstrapTable).bootstrapTable('refresh'); }, 100);
|
if (result) setTimeout(function () { swal("成功!", "删除数据", "success"); $(options.bootstrapTable).bootstrapTable('refresh'); }, 100);
|
||||||
else setTimeout(function () { swal("失败", "删除数据", "error"); }, 200);
|
else setTimeout(function () { swal("失败", "删除数据", "error"); }, 200);
|
||||||
},
|
},
|
||||||
|
@ -140,7 +142,7 @@
|
||||||
type: 'POST',
|
type: 'POST',
|
||||||
success: function (result) {
|
success: function (result) {
|
||||||
if (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.bootstrapTable.constructor === String && options.data.ID.constructor === String) {
|
||||||
// 更新表格
|
// 更新表格
|
||||||
if (options.data.ID > 0) {
|
if (options.data.ID > 0) {
|
||||||
|
|
|
@ -10,12 +10,18 @@ namespace Bootstrap.Admin.Models
|
||||||
{
|
{
|
||||||
public HeaderBarModel()
|
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 = "~/";
|
HomeUrl = "~/";
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
///
|
///
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
public int UserID { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
public string DisplayName { get; set; }
|
public string DisplayName { get; set; }
|
||||||
/// <summary>
|
/// <summary>
|
||||||
///
|
///
|
||||||
|
|
|
@ -8,7 +8,12 @@
|
||||||
Password: "password",
|
Password: "password",
|
||||||
DisplayName: "displayName"
|
DisplayName: "displayName"
|
||||||
}
|
}
|
||||||
})
|
}),
|
||||||
|
success: function (src, data) {
|
||||||
|
if (src === 'save' && data.ID === $('#userId').val()) {
|
||||||
|
$('.username').text(data.DisplayName);
|
||||||
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
$('table').smartTable({
|
$('table').smartTable({
|
||||||
|
@ -41,6 +46,4 @@
|
||||||
maxlength: 50
|
maxlength: 50
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
//TODO: 客户端点击保存用户后,要更新页面右上角用户显示名称
|
|
||||||
});
|
});
|
|
@ -33,6 +33,7 @@
|
||||||
<img alt="" src="../content/images/logo6.jpg">
|
<img alt="" src="../content/images/logo6.jpg">
|
||||||
<span class="username">@Model.DisplayName</span>
|
<span class="username">@Model.DisplayName</span>
|
||||||
<b class="caret"></b>
|
<b class="caret"></b>
|
||||||
|
<input id="userId" type="text" class="hide" value="@Model.UserID"/>
|
||||||
</a>
|
</a>
|
||||||
<ul class="dropdown-menu extended logout">
|
<ul class="dropdown-menu extended logout">
|
||||||
<div class="log-arrow-up"></div>
|
<div class="log-arrow-up"></div>
|
||||||
|
|
Loading…
Reference in New Issue