温馨提示:代码在线浏览功能只能做为源码浏览参考,如果想更进一步了解该代码请下载:酒店管理系统(ExtJs)源码
当前文件:
MyHotelManager/HotelUI/Js/AddRoomType.js,打开代码结构图
MyHotelManager/HotelUI/Js/AddRoomType.js,打开代码结构图1//添加房间类型 2
function AddRoomType() 3
{ 4
//获得是否 5
var strIs=new Ext.data.Store 6
( 7
{ 8
proxy: new Ext.data.HttpProxy 9
( 10
{ 11
url:'/HotelUI/Json/GetIs.aspx' 12
} 13
), 14
//读取Json 15
reader: new Ext.data.JsonReader 16
( 17
{root:'data'}, 18
[ 19
{name:'IsId',type:'string'}, 20
{name:'IsName',type:'string'} 21
] 22
) 23
} 24
); 25
strIs.load(); 26
27
Ext.QuickTips.init(); 28
Ext.form.Field.prototype.msgTarget = 'side'; 29
var addRoomType = new Ext.FormPanel 30
( 31
{ 32
labelWidth:75, 33
frame : true, 34
title : '请仔细填写表单', 35
width : 580, 36
waitMsgTarget : true, 37
items: 38
[ 39
{ 40
layout:'column', 41
border:false, 42
items: 43
[ 44
{ 45
columnWidth:.5, 46
layout: 'form', 47
border:false, 48
items: 49
[ 50
{ 51
xtype:'textfield', 52
fieldLabel: ' 房间类型名称', 53
labelStyle: 'width:100px', 54
width:150, 55
name: 'TypeName', 56
allowBlank:false, 57
blankText: '请输入类型名称' 58
}, 59
{ 60
xtype:'textfield', 61
fieldLabel: ' 房间类型价格', 62
labelStyle: 'width:100px', 63
width:80, 64
name: 'TypePrice', 65
allowBlank:false, 66
blankText: '请输入类型价格' 67
} 68
] 69
}, 70
{ 71
columnWidth:.5, 72
layout: 'form', 73
border:false, 74
items: 75
[ 76
new Ext.form.ComboBox 77
( 78
{ 79
80
fieldLabel: ' 是否配备电视', 81
labelStyle: 'width:100px', 82
width:100, 83
editable: false, //不允许输入 84
name: 'IsTv', 85
store:strIs, 86
emptyText:'--请选择--', 87
allowBlank:false, //不允许为空 88
blankText:'请选择', //错误提示信息 89
mode: 'client', 90
displayField:'IsName', 91
valueField:'IsName', 92
hiddenName:'IsTv', 93
triggerAction: 'all', 94
selectOnFocus:true 95
} 96
), 97
new Ext.form.ComboBox 98
( 99
{ 100
fieldLabel: ' 是否配备空调', 101
labelStyle: 'width:100px', 102
width:100, 103
editable: false, //不允许输入 104
name: 'IsKongTiao', 105
store:strIs, 106
emptyText:'--请选择--', 107
allowBlank:false, //不允许为空 108
blankText:'请选择', //错误提示信息 109
mode: 'client', 110
displayField:'IsName', 111
valueField:'IsName', 112
hiddenName:'IsKongTiao', 113
triggerAction: 'all', 114
selectOnFocus:true 115
} 116
) 117
] 118
} 119
] 120
}, 121
{ 122
xtype:'textarea', 123
name:'remark', 124
fieldLabel:' 备注', 125
labelStyle: 'width:100px', 126
height:120, 127
width:380 128
} 129
], 130
buttons: 131
[ 132
{ 133
id:'btnOk', 134
text:'确 定', 135
handler:function() 136
{ 137
//如果验证合法 138
if (addRoomType.form.isValid()) 139
{ 140
//弹出效果 141
Ext.MessageBox.show 142
( 143
{ 144
msg: '正在保存,请稍等...', 145
progressText: 'Saving...', 146
width:300, 147
wait:true, 148
waitConfig: {interval:200}, 149
icon:'download', 150
animEl: 'saving' 151
} 152
); 153
setTimeout(function(){}, 10000); 154
//提交到服务器 155
addRoomType.form.submit 156
( 157
{ 158
url:'/HotelUI/Form/AddRoomType.aspx', //提交的页面路径 159
method:'post',//提交方式为post 160
//提交成功的回调函数 161
success:function(form,action) 162
{ 163
var flage = action.result.success; 164
//如果服务器端传过来的数据为true则表示登录成功 165
if (flage == true) 166
{ 167
Ext.MessageBox.alert('恭喜','添加房间类型成功!'); 168
storeToday.reload(); 169
newWin.hide(); 170
} 171
}, 172
//提交失败的回调函数 173
failure:function() 174
{ 175
Ext.Msg.alert('错误','服务器出现错误请稍后再试!'); 176
} 177
} 178
); 179
} 180
} 181
}, 182
{ 183
text:'取 消', 184
handler:function() 185
{ 186
newWin.hide(); 187
} 188
} 189
] 190
} 191
); 192
//定义窗体 193
newWin = new Ext.Window 194
( 195
{ 196
layout : 'fit', 197
width : 540, 198
height : 300, 199
collapsible:true, //允许缩放条 200
closeAction : 'hide', 201
closable:true, 202
plain : true, 203
modal: 'true', 204
title : '添加房间类型', 205
items : addRoomType 206
} 207
) 208
//显示窗体 209
newWin.show(); 210
} 211
212





}
}