|
|
|
var EditDialog = function (parent) {
|
|
|
|
this.Parent = parent;
|
|
|
|
this.User = {};
|
|
|
|
|
|
|
|
this.Setup = function () {
|
|
|
|
this.InitOrgList();
|
|
|
|
|
|
|
|
$("#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) {
|
|
|
|
this.User = data;
|
|
|
|
$('#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.InitOrgList = function () {
|
|
|
|
$.ajax({
|
|
|
|
type: "POST",
|
|
|
|
dataType: 'text',
|
|
|
|
url: '/OrgManagement/Query',
|
|
|
|
data: {
|
|
|
|
pageIndex: 1,
|
|
|
|
pageSize: 10000
|
|
|
|
},
|
|
|
|
success: function (result) {
|
|
|
|
$('#edit-dialog-org-list').combobox({
|
|
|
|
valueField: 'Id',
|
|
|
|
textField: 'Name',
|
|
|
|
editable: false,
|
|
|
|
data: JSON.parse(result).rows
|
|
|
|
});
|
|
|
|
|
|
|
|
$('#edit-dialog-org-list').combobox('setValue', this.User.OrgId);
|
|
|
|
}.bind(this)
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
this.OnSexButtonClick = function (event) {
|
|
|
|
$('#sex span').removeClass("active");
|
|
|
|
$(event.target).addClass("active");
|
|
|
|
};
|
|
|
|
|
|
|
|
this.OnSureButtonClick = function () {
|
|
|
|
this.User.OrgId = $('#edit-dialog-org-list').combobox('getValue');
|
|
|
|
this.User.Gender = parseInt($('#sex span.active').attr('gender'));
|
|
|
|
this.User.RealName = $("#username").textbox('getValue');
|
|
|
|
this.User.LoginName = $('#account').textbox('getValue');
|
|
|
|
this.User.LoginPassWord = $('#password').textbox('getValue');
|
|
|
|
|
|
|
|
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.User,
|
|
|
|
success: function () {
|
|
|
|
this.Parent.ReLoadTableData();
|
|
|
|
}.bind(this)
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
this.clearInput = function () {
|
|
|
|
$('#edit-dialog-org-list').combobox('setValue', ''),
|
|
|
|
$("#username").textbox('setValue', ''),
|
|
|
|
$('#account').textbox('setValue', ''),
|
|
|
|
$('#password').textbox('setValue', ''),
|
|
|
|
$('#sex span').eq(0).addClass("active");
|
|
|
|
};
|
|
|
|
};
|