//添加人员表单
var addPersonForm = new Ext.FormPanel({
baseCls: 'x-plain',
labelWidth: 65,
labelAlign : 'right',
bodyStyle : 'padding-top:5px',
defaultType: 'textfield',
defaultWidth: '175',
items: [{
fieldLabel: '用户名',
id: 'username',
anchor: '90%',
name: 'user_name',
maxLength: 20,
maxLengthText: '最多输入20个字符',
minLength: 2,
minLengthText: '最少输入2个字符',
allowBlank: false,
blankText: '用户名称不能为空'
},{
inputType: 'password',
id: 'userpsw',
fieldLabel: '密码',
maxLength: 20,
maxLengthText: '最多输入20个字符',
minLength: 6,
minLengthText: '最少输入6个字符',
anchor: '90%',
name: 'userpsw',
allowBlank: false,
blankText: '密码不能为空'
}, {
inputType: 'password',
id: 'userrepsw',
fieldLabel: '重复密码',
maxLength: 20,
maxLengthText: '最多输入20个字符',
minLength: 6,
minLengthText: '最少输入6个字符',
anchor: '90%',
name: 'repsw',
allowBlank: false,
blankText: '密码不能为空'
},
user_combobox,
new Ext.form.Hidden({ //hidden
id:'parent_id',
name:'parent_id'
})
,{
xtype: 'textarea',
id: 'des',
name: 'description',
maxLength: 200,
maxLengthText: '最多输入200个字符',
fieldLabel: '用户描述',
height:50,
anchor: '90%' // anchor width by percentage and height by raw adjustment
},
{
xtype: 'multiselect',
id: 'userright',
fieldLabel: '权限选择',
name: 'user_role',
//dataFields: ["value", "text"],
bodyStyle: 'padding:10px;',
valueField: "value",
blankText: '请选择用户权限',
displayField: "text",
width: 190,
height: 140,
allowBlank: false,
store: role_store,
mode: 'remote',
tbar:[{
text: "重选",
handler:function(){
addPersonForm.getForm().findField("user_right").reset();
}
}]
}
],
buttons: [{
text: '保存',
handler:function(){
if(addPersonForm.form.isValid()){
if(Ext.get('userpsw').dom.value != Ext.get('userrepsw').dom.value){
Ext.Msg.alert('错误','两次密码不一致');
return false;
}
Ext.MessageBox.show({
title: '请稍等',
msg: '正在提交数据...',
progressText: '',
width: 300,
progress: true,
closable: false,
animEl: 'loding'
});
var f = function(v){
return function(){
var i = v/11;
Ext.MessageBox.updateProgress(i, '');
};
};
for(var i = 1; i < 13; i++){
setTimeout(f(i), i*150);
}
addPersonForm.form.doAction('submit',{
url:'tree/modules/add_person.php',
method:'post',
params:'',
success:function(form,action){
if (action.result.msg=='ok') {
addPersonForm.form.reset();
addPersonWindow.hide();
Ext.MessageBox.hide();
Ext.example.msg('执行结果',"用户创建成功!");
reloadTreeAndGrid();
} else {
Ext.Msg.alert('错误',action.result.msg);
}
},
failure:function(){
Ext.Msg.alert('错误','服务器出现错误请稍后再试!');
}
});
}
}
},{
text: '取消',
handler:function(){addPersonForm.form.reset();}
}]
});
//添加人员窗口定义
var addPersonWindow = new Ext.Window({
//
// 不在关闭时销毁自己,使用 show, hide 方式显示对话框
//
title: '添加新成员',
id: 'add-person-window',
autoDestroy: false,
closeAction: 'hide',
//resizable: false, // 不允许调整大小
width: 340,
height: 400,
layout: 'fit',
plain: true,
modal: true,
bodyStyle: 'padding: 5px;',
items: addPersonForm
});
//添加人员事件定义
function addPersonAction(){
addPersonWindow.show();
//让下拉列表自动赋值。如果已经选中了部门就无需再选。
var selectedNode = westPanel.getSelectionModel().getSelectedNode();//得到选中的节点
if(selectedNode!=null && Ext.get('parent_id')!=null){
var str_type = selectedNode.attributes.str_type
if(str_type =='dept' || str_type== undefined){
var str_id = selectedNode.attributes.id;
var str_name = selectedNode.attributes.text;
Ext.get('parent_id').dom.value=str_id;
Ext.get('person_combobox').dom.value=str_name;
}else{
addPersonForm.form.reset();
}
}
}
EXT form表单提交 window中显示
最新推荐文章于 2019-05-22 20:57:20 发布