?? addroominfo.js
字號:
?// JScript 文件
AddRoonInfos=function()
{
//驗證房間號是否存在
var isok=false;
CheckRoomID=function()
{
var number=Ext.get('number').dom.value;
Ext.Ajax.request({
url:'URL/Room/RoomIDIsOK.aspx',
method:"POST",
params:{roomid:number},
success: function(response, options) {
var responseArray = Ext.util.JSON.decode(response.responseText);
if(responseArray.success == true){ //房間號已經(jīng)存在
SetValue(false);
}else{//房間號可以使用
SetValue(true);
}
}
});
function SetValue(b){
isok = b;//給變量賦值
}
return isok;
}
var roomtypefileds = Ext.data.Record.create([
{name: 'typeid',mapping:'typeid'},{name: 'typename',mapping:'typename'},{name:'typedesc',mapping:'typedesc'}
]);
var roomtypestore = new Ext.data.Store({
proxy: new Ext.data.HttpProxy({
url:'DATA/RoomType/OpenRoomGetAllRoomType.aspx'
}),
reader: new Ext.data.JsonReader({
root: 'data',
id: 'typeid'
},
roomtypefileds
)
});
roomtypestore.load();
var AddRoomForm=new Ext.form.FormPanel({
width:375,
height:270,
plain:true,
layout:"form",
defaultType:"textfield",
labelWidth:75,
baseCls:"x-plain",
//錨點布局-
defaults:{anchor:"95%",msgTarget:"side"},
buttonAlign:"center",
bodyStyle:"padding:0 0 0 0",
items:[
{
name:"number",
fieldLabel:"<font color=red>房間號碼</font>",
allowBlank:false,
blankText:"房間號碼不允許為空",
validator:CheckRoomID,//指定驗證器
invalidText:'該房間號己在存在'
},{
name:"bednumber",
fieldLabel:"床位數(shù)量",
allowBlank:false,
blankText:"床位數(shù)量不允許為空",
regex:/^[0-9]{1,2}$/,
regexText:"1-2位數(shù)"
},{
name:"guestnumber",
fieldLabel:"容納人數(shù)",
allowBlank:false,
blankText:"容納人數(shù)不允許為空",
regex:/^[0-9]{1,2}$/,
regexText:"1-2位數(shù)"
},{
xtype:"combo",
tpl: '<tpl for="."><div ext:qtip="{typename}. {typedesc}" class="x-combo-list-item">{typename}</div></tpl>',
store: roomtypestore,
typeAhead: true,
fieldLabel:'房間類型',
hiddenName:'typeid',
name:'typeids',
forceSelection: true,
triggerAction: 'all',
emptyText:'請選擇房間類型',
selectOnFocus:true,
width:130,
editable: false,
allowBlank:false,
blankText:'請選擇類型',
displayField:'typename',
valueField: 'typeid',
mode: 'remote'
},{
xtype:"combo",
name:'roomstates',
fieldLabel:'初始狀態(tài)',
emptyText:'請設(shè)定房間初始狀態(tài)',
allowBlank:false,
blankText:'請選擇房間初始狀態(tài)',
editable: false,
hiddenName:'roomstate',
store:new Ext.data.SimpleStore({
data:[["空閑","0"],["入住","1"],["維修","2"],["自用","3"],["其它","4"]],
fields:["state","value"]
}),
tpl: '<tpl for="."><div ext:qtip="設(shè)置房間狀態(tài)為--{state}" class="x-combo-list-item">{state}</div></tpl>',
displayField:"state",
mode:"local",
valueField:"value",
triggerAction:"all"
},{
name:"roomdesc",
xtype:"textarea",
fieldLabel:"房間描述",
allowBlank:false,
blankText:"房間描述不允許為空",
regex:/^[\s\S]{1,25}$/,
regexText:"房間描述請不要超過25個字符"
}]});
var AddRoomwin=new Ext.Window({
title:"增加房間信息",
width:410,
height:285,
plain:true,
//layout:"form",
iconCls:"openroomicon",
//不可以隨意改變大小
resizable:false,
//是否可以拖動
//draggable:false,
defaultType:"textfield",
labelWidth:100,
collapsible:true, //允許縮放條
closeAction : 'hide',
closable:true,
//彈出模態(tài)窗體
modal: 'true',
buttonAlign:"center",
bodyStyle:"padding:10px 0 0 15px",
items:[AddRoomForm],
listeners:{
"show":function()
{
//當window show事件發(fā)生時清空一下表單
AddRoomForm.getForm().reset();
}
},
buttons:[{
text:"保存信息",
minWidth:70,
handler:function()
{
if(AddRoomForm.getForm().isValid())
{
//彈出效果
Ext.MessageBox.show
(
{
msg: '正在保存,請稍等...',
progressText: 'Saving...',
width:300,
wait:true,
waitConfig: {interval:200},
icon:'download',
animEl: 'saving'
}
);
setTimeout(function(){}, 1000);
AddRoomForm.form.submit({
url:"URL/Room/AddRoomInfo.aspx",
method:"POST",
success:function(form,action)
{
//成功后
var flag=action.result.success;
if(flag=="true")
{
Ext.MessageBox.alert("恭喜","添加房間信息成功!");
Roomstore.reload();
AddRoomwin.hide();
}
},
failure:function(form,action)
{
Roomstore.reload();
Ext.MessageBox.alert("提示!","保存房間信息失敗!");
}
});
}
}
},{
text:"重置",
minWidth:70,
qtip:"重置數(shù)據(jù)",
handler:function()
{
AddRoomForm.getForm().reset();
}
},{
text:"取 消",
minWidth:70,
handler:function()
{
AddRoomwin.hide();
}
}]
});
AddRoomwin.show();
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -