You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

69 lines
2.3 KiB

var EditDialog = function (parent) {
this.Parent = parent;
this.OrgId = null;
this.Setup = function () {
$("#sex span").on("click", this.OnSexButtonClick.bind(this));
$("#edit-sure-btn").on("click", this.OnSureButtonClick.bind(this));
$("#edit-cancel-btn").on("click", this.HideDialog.bind(this));
$("#edit-close").on("click", this.HideDialog.bind(this));
};
this.Show = function (data) {
console.log(data);
this.OrgId = data.OrgId;
$('#edit-dialog').show();
$("#username").textbox('setValue', data.RealName);
$("#account").textbox('setValue', data.LoginName);
$("#password").textbox('setValue', data.LoginPassWord);
parseInt($('#sex span').eq(0).attr('gender')) === data.Gender ? $('#sex span').eq(0).addClass('active') : $('#sex span').eq(0).removeClass('active');
parseInt($('#sex span').eq(1).attr('gender')) === data.Gender ? $('#sex span').eq(1).addClass('active') : $('#sex span').eq(1).removeClass('active');
};
this.OnSexButtonClick = function (event) {
$('#sex span').removeClass("active");
$(event.target).addClass("active");
};
this.OnSureButtonClick = function () {
console.log(this.getUserParams())
this.EditUser();
this.HideDialog();
};
this.HideDialog = function () {
$('#edit-dialog').hide();
this.clearInput();
};
this.EditUser = function () {
$.ajax({
type: "POST",
dataType: 'text',
url: '/UserManagement/Update',
data: this.getUserParams(),
success: function (result) {
console.log(this.getUserParams())
this.Parent.ReLoadTableData();
}.bind(this)
});
};
this.clearInput = function () {
$("#username").textbox('setValue', ''),
$('#account').textbox('setValue', ''),
$('#password').textbox('setValue', ''),
$('#sex span').eq(0).addClass("active");
};
this.getUserParams = function () {
return {
OrgId: this.OrgId,
Gender: parseInt($('#sex span.active').attr('gender')),
RealName: $("#username").textbox('getValue'),
LoginName: $('#account').textbox('getValue'),
LoginPassword: $('#password').textbox('getValue')
}
};
};