var EditPasswordDialog = function (parent) { this.Parent = parent; this.User = {}; this.Setup = function () { $("#edit-password-sure-btn").on("click", this.OnSureButtonClick.bind(this)); $("#edit-password-cancel-btn").on("click", this.HideDialog.bind(this)); $("#edit-password-close").on("click", this.HideDialog.bind(this)); }; this.Show = function (data) { this.User = data; this.InitOrgList(); $('#edit-password-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: { page: 1, rows: 10000 }, success: function (result) { console.log(this.User.OrgId) }.bind(this) }); }; this.OnSureButtonClick = function () { this.validation(); }; this.validation = function () { if ($("#password").textbox('getValue').trim() === '' || $("#password").textbox('getValue').trim === null) { alert('请输入新密码'); return } else if ($("#confirm-password").textbox('getValue').trim() === '' || $("#confirm-password").textbox('getValue').trim === null) { alert('请输入确认密码'); return } else if ($("#password").textbox('getValue') !== $("#confirm-password").textbox('getValue')) { alert('两次输入的密码不一致'); return; } else { //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-password-dialog').hide(); this.clearInput(); }; this.EditUser = function () { $.ajax({ type: "POST", dataType: 'text', url: '/UserManagement/Update', data: this.User, success: function () { this.Parent.ReLoadTableData($('#org-list').combobox('getValue')); }.bind(this) }); }; this.clearInput = function () { $('#password').textbox('setValue', ''), $('#confirm-password').textbox('setValue', '') }; };