25,985
社区成员
发帖
与我相关
我的任务
分享
UserEditWindowUi = Ext.extend(Ext.Window, {
title: '创建一位管理账户 ',
width: 341,
height: 412,
layout: 'fit',
resizable: false,
modal: true,
closeAction: 'hide',
initComponent: function() {
this.items = [
{
xtype: 'form',
height: 359,
padding: 10,
formId: 'UserEditForm',
items: [
{
xtype: 'fieldset',
title: '填写用户信息',
width: 305,
height: 293,
items: [
{
xtype: 'textfield',
fieldLabel: '登陆名称',
anchor: '100%',
name: 'tuser.loginName',
allowBlank: false,
blankText: '登陆名称不能为空!',
maxLength: 20,
minLength: 5,
minLengthText: '最小长度为5个字符!',
ref: '../../loginName'
},
{
xtype: 'textfield',
fieldLabel: '密码',
anchor: '100%',
name: 'tuser.passWord',
inputType: 'password',
allowBlank: false,
blankText: '密码不能为空!',
maxLength: 20,
ref: '../../passWord'
},
{
xtype: 'textfield',
fieldLabel: '密码确认',
anchor: '100%',
name: 'tuser.passWord2',
inputType: 'password',
blankText: '密码确认不能为空!',
maxLength: 20,
ref: '../../passWord2'
},
{
xtype: 'textfield',
fieldLabel: '真实姓名',
anchor: '100%',
maxLength: 20,
name: 'tuser.userName',
ref: '../../userName'
},
{
xtype: 'combo',
fieldLabel: '指定用户组',
anchor: '100%',
name: 'tuser.groupName',
store: 'UserGroupStore',
displayField: 'name',
triggerAction: 'all',
allowBlank: false,
resizable: true,
submitValue: true,
disableKeyFilter: true,
editable: false,
blankText: '必须指定一个用户组!',
valueField: 'id',
ref: '../../groupName'
},
{
xtype: 'checkbox',
fieldLabel: '是否锁定',
boxLabel: '锁定,暂不启用',
anchor: '100%',
ref: '../../t_islocked'
},
{
xtype: 'textarea',
anchor: '100%',
fieldLabel: '备注说明',
name: 'tuser.about',
maxLength: 255,
ref: '../../about'
},
{
xtype: 'hidden',
fieldLabel: 'Label',
anchor: '100%',
name: 'tuser.id',
ref: '../../tuserId'
},
{
xtype: 'hidden',
fieldLabel: 'Label',
anchor: '100%',
name: 'tuser.locked',
ref: '../../islocked'
}
]
},
{
xtype: 'container',
width: 309,
height: 48,
layout: 'absolute',
items: [
{
xtype: 'button',
text: '提交保存',
x: 60,
y: -1,
width: 70,
height: 40,
type: 'submit',
ref: '../../btn_Save'
},
{
xtype: 'button',
text: '清除重填',
x: 180,
y: 0,
width: 70,
height: 40,
type: 'reset',
ref: '../../btn_Reset'
}
]
}
]
}
];
UserEditWindowUi.superclass.initComponent.call(this);
}
});
UserEditWindow = Ext.extend(UserEditWindowUi, {
initComponent : function() {
UserEditWindow.superclass.initComponent.call(this);
this.btn_Save.on("click", function() {
var progbar = Ext.MessageBox.wait("",
"正在向服务器发送信息...");
var thisWnd = this;
// 判别是编辑还是添加
var requestUrl = "System/User_regist.do";
var successInfo = "用户添加成功!";
if (Number(this.tuserId.getValue()) != 0) {
requestUrl = "System/User_edit.do";
successInfo = "用户信息修改成功!";
} else {
this.tuserId.setValue(0);
}
// 验证表单数据,通过后才能提交数据
if (!this.find("formId", "UserEditForm")[0]
.getForm().isValid()) {
Ext.MessageBox.alert("提示",
"表单数据验证失败,请修改后重新提交 !");
return;
}
// 确定提交所有数据
this.loginName.setDisabled(false);
this.passWord2.setDisabled(false);
this.islocked.setValue(this.t_islocked.getValue());
Ext.Ajax.request({
url : requestUrl,
form : "UserEditForm",
success : function(response, e) {
try {
var obj = Ext
.decode(response.responseText);
if (obj.result.success == true) {
progbar.hide();
Ext.MessageBox.alert("提示",
successInfo);
thisWnd.close();
} else {
progbar.hide();
Ext.MessageBox
.alert(
"错误",
obj.result.errormsg);
}
} catch (e) {
progbar.hide();
Ext.MessageBox.alert("错误",
"您没有相应的权限!",
function() {
new LoginWindow()
.show();
});
}
},
failure : function() {
progbar.hide();
Ext.MessageBox.alert("错误",
"服务器未响应请求,请检查服务器是否正常运行!");
}
});
}, this);
}
});