温馨提示:代码在线浏览功能只能做为源码浏览参考,如果想更进一步了解该代码请下载:酒店管理系统(ExtJs)源码
当前文件:
MyHotelManager/HotelUI/Js/AddUser.js,打开代码结构图
MyHotelManager/HotelUI/Js/AddUser.js,打开代码结构图1//添加普通员工 2
function AddUser() 3
{ 4
Ext.QuickTips.init(); 5
Ext.form.Field.prototype.msgTarget = 'side'; 6
var addUser = new Ext.FormPanel 7
( 8
{ 9
labelWidth:75, 10
frame : true, 11
title : '请仔细填写表单', 12
width : 300, 13
waitMsgTarget : true, 14
items: 15
[ 16
{ 17
xtype:'textfield', 18
fieldLabel: ' 登录Id', 19
labelStyle: 'width:80px', 20
width:150, 21
name: 'LoginName', 22
allowBlank:false, 23
blankText: '请输入登录Id' 24
//validator:CheckUserId,//指定验证的方法 25
//invalidText:'用户名已存在!' 26
}, 27
{ 28
inputType:'password', 29
xtype:'textfield', 30
fieldLabel: ' 登录密码', 31
labelStyle: 'width:80px', 32
width:150, 33
name: 'LoginPass', 34
allowBlank:false, 35
blankText: '请输入密码' 36
}, 37
{ 38
xtype:'textfield', 39
fieldLabel: ' 真实姓名', 40
labelStyle: 'width:80px', 41
width:150, 42
name: 'UserName', 43
allowBlank:false, 44
blankText: '请输入姓名' 45
}, 46
{ 47
xtype:'textarea', 48
name:'remark', 49
fieldLabel:' 备注', 50
labelStyle: 'width:80px', 51
height:100, 52
width:200 53
} 54
], 55
buttons: 56
[ 57
{ 58
id:'btnOk', 59
text:'确 定', 60
handler:function() 61
{ 62
//如果验证合法 63
if (addUser.form.isValid()) 64
{ 65
//弹出效果 66
Ext.MessageBox.show 67
( 68
{ 69
msg: '正在保存,请稍等...', 70
progressText: 'Saving...', 71
width:300, 72
wait:true, 73
waitConfig: {interval:200}, 74
icon:'download', 75
animEl: 'saving' 76
} 77
); 78
setTimeout(function(){}, 10000); 79
//提交到服务器 80
addUser.form.submit 81
( 82
{ 83
url:'/HotelUI/Form/AddUser.aspx', //提交的页面路径 84
method:'post',//提交方式为post 85
//提交成功的回调函数 86
success:function(form,action) 87
{ 88
var flage = action.result.success; 89
//如果服务器端传过来的数据为true则表示登录成功 90
if (flage == true) 91
{ 92
Ext.MessageBox.alert('恭喜','添加员工成功!'); 93
newWin.hide(); 94
} 95
}, 96
//提交失败的回调函数 97
failure:function() 98
{ 99
Ext.Msg.alert('错误','服务器出现错误请稍后再试!'); 100
} 101
} 102
); 103
} 104
} 105
106
}, 107
{ 108
text:'取 消', 109
handler:function() 110
{ 111
newWin.hide(); 112
} 113
} 114
] 115
} 116
); 117
//定义窗体 118
newWin = new Ext.Window 119
( 120
{ 121
layout:'fit', 122
width:350, 123
height:300, 124
collapsible:true, //允许缩放条 125
closeAction : 'hide', 126
plain : true, 127
modal: 'true', //启用遮罩 128
title : '添加普通员工', 129
items : addUser 130
} 131
); 132
//显示窗体 133
newWin.show(); 134
} 135
136
//var isok=false; 137
//function CheckUserId() 138
//{ 139
// var UserId = Ext.get('LoginName').dom.value; 140
// //ajax提交 141
// Ext.Ajax.request 142
// ( 143
// { 144
// url:'/HotelUI/Form/CheckUserId.aspx', 145
// params:{name:UserId}, 146
// success: function(response, options) 147
// { 148
// 149
// var check = Ext.util.JSON.decode(response.responseText); 150
// if(check.success == true) //已被注册 151
// { 152
// SetValue(false); 153
// } 154
// else 155
// { 156
// SetValue(true); 157
// } 158
// } 159
// } 160
// ); 161
// //给变量赋值 162
// function SetValue(b) 163
// { 164
// isok = b; 165
// } 166
// return isok; 167
//} 168




Ext.QuickTips.init();


}