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.

106 lines
3.5 KiB

3 years ago
var AddDialog = function (parent) {
this.Parent = parent;
this.Setup = function () {
3 years ago
this.InitOrgList();
$("#add-dialog-sex-select span").on("click", this.OnSexButtonClick.bind(this));
3 years ago
$("#sure-btn").on("click", this.OnSureButtonClick.bind(this));
$("#cancel-btn").on("click", this.HideDialog.bind(this));
$("#close").on("click", this.HideDialog.bind(this));
};
this.Show = function () {
$('#add-dialog').show();
};
3 years ago
this.InitOrgList = function () {
$.ajax({
type: "POST",
dataType: 'text',
url: '/OrgManagement/Query',
data: {
3 years ago
page: 1,
rows: 10000
3 years ago
},
success: function (result) {
$('#add-dialog-org-list').combobox({
valueField: 'Id',
textField: 'Name',
editable: false,
3 years ago
panelHeight: 'auto',
3 years ago
data: JSON.parse(result).rows
});
}.bind(this)
});
};
3 years ago
this.OnSexButtonClick = function (event) {
3 years ago
$('#add-dialog-sex-select span').removeClass("active");
3 years ago
$(event.target).addClass("active");
};
this.OnSureButtonClick = function () {
3 years ago
this.validation();
3 years ago
};
this.HideDialog = function () {
$('#add-dialog').hide();
3 years ago
this.clearInput();
};
this.AddUser = function () {
$.ajax({
type: "POST",
dataType: 'text',
url: '/UserManagement/Add',
3 years ago
data: this.getUserParams(),
3 years ago
success: function () {
3 years ago
this.Parent.ReLoadTableData(0);
$('#org-list').combobox('setValue', 0);
3 years ago
}.bind(this)
});
};
this.clearInput = function () {
$("#name").textbox('setValue', '');
$('#loginAccount').textbox('setValue', '');
$('#loginPassword').textbox('setValue', '');
3 years ago
$('#add-dialog-sex-select span').eq(0).addClass("active");
3 years ago
$('#add-dialog-sex-select span').eq(1).removeClass('active');
3 years ago
$('#add-dialog-org-list').combobox('setValue', '');
3 years ago
};
3 years ago
this.getUserParams = function () {
return {
3 years ago
OrgId: $('#add-dialog-org-list').combobox('getValue'),
Gender: parseInt($('#add-dialog-sex-select span.active').attr('gender')),
3 years ago
RealName: $("#name").textbox('getValue'),
LoginName: $('#loginAccount').textbox('getValue'),
LoginPassword: $('#loginPassword').textbox('getValue')
}
};
3 years ago
this.validation = function () {
if ($("#name").textbox('getValue').trim() === '' || $("#name").textbox('getValue').trim === null) {
alert('请输入姓名');
return
} else if ($('#add-dialog-org-list').combobox('getValue') === '') {
alert('请选择机构');
return;
} else if ($("#loginAccount").textbox('getValue').trim() === '' || $("#loginAccount").textbox('getValue').trim === null) {
alert('请输入登录账户');
return
} else if ($("#loginPassword").textbox('getValue').trim() === '' || $("#loginPassword").textbox('getValue').trim === null) {
alert('请输入登录密码');
return
3 years ago
} else if ($("#loginPassword").textbox('getValue').trim().length < 6) {
alert('密码长度至少为6位');
return
3 years ago
} else {
this.AddUser();
this.HideDialog();
}
};
3 years ago
};