?? addroomtype.js
字號:
?// JScript 文件
//定義房間類型編號
//添加房間類型時判斷該類型名稱是否存在
var RoomTypeisOK=false;
CheckRoomTypeIsOk=function()
{
var roomtypename=Ext.get('typename').dom.value;
Ext.Ajax.request({
url:'URL/RoomType/RoomTypeNameIsOk.aspx',
method:"POST",
params:{typename:roomtypename},
success: function(response, options) {
var responseArray = Ext.util.JSON.decode(response.responseText);
if(responseArray.success == true){ //房間號已經存在
SetValue(false);
}else{//房間號可以使用
SetValue(true);
}
}
});
function SetValue(b){
RoomTypeisOK = b;//給變量賦值
}
return RoomTypeisOK;
}
var AddRoomTypeForm=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:"typename",
id:'typename',
fieldLabel:"<font color=red>類型名稱</font>",
allowBlank:false,
blankText:"房間類型名稱不允許為空",
validator:CheckRoomTypeIsOk,//指定驗證器
invalidText:'該房間類型己在存在'
},{
name:"typeprice",
fieldLabel:"類型價格",
allowBlank:false,
blankText:"類型價格不允許為空",
regex:/^[1-9][0-9.]{1,10}$/,
regexText:"2到10位數字可有小數點-第一位不允許有小數點"
},{
name:"typeaddbed",
xtype:"combo",
fieldLabel:"是否加床",
//傳入后臺真實值value field /value
//hiddenName:"abcd",
readOnly:true,
mode:"local",
displayField:"addroomtypeSimpleStore",
valueField:"addroomtypeSimpleStore",
triggerAction:"all",
value:"是",
store:new Ext.data.SimpleStore({
fields:["addroomtypeSimpleStore"],
data:[["是"],["否"]]
}),listeners:{
"beforeselect":function(combo,record)
{
if(record.data.addroomtypeSimpleStore=="是")
{
//啟用該組件
combo.ownerCt.findById("addRoomTypeaddbed").enable();
}
else if(record.data.addroomtypeSimpleStore=="否")
{
//禁用該組件
combo.ownerCt.findById("addRoomTypeaddbed").disable();
combo.ownerCt.findById("addRoomTypeaddbed").setValue("0.00");
}
}
}
},{
name:"addbed",
id:"addRoomTypeaddbed",
fieldLabel:"加床價格",
allowBlank:false,
blankText:"加床價格不允許為空",
regex:/^[1-9][0-9.]{1,10}$/,
regexText:"2到10位數字可有小數點-第一位不允許有小數點"
},{
name:"typedesc",
xtype:"textarea",
fieldLabel:"類型描述",
allowBlank:false,
blankText:"房間類型描述不允許為空",
regex:/^[\s\S]{1,50}$/,
regexText:"描述請不要超過50個字符"
}]});
var AddRoomTypewin=new Ext.Window({
title:"添加房間類型信息",
width:410,
height:285,
plain:true,
//layout:"form",
iconCls:"addicon",
//不可以隨意改變大小
resizable:false,
//是否可以拖動
//draggable:false,
defaultType:"textfield",
labelWidth:100,
collapsible:true, //允許縮放條
closeAction : 'hide',
closable:true,
//彈出模態窗體
modal: 'true',
buttonAlign:"center",
bodyStyle:"padding:10px 0 0 15px",
items:[AddRoomTypeForm],
listeners:{
"show":function()
{
//當window show事件發生時清空一下表單
AddRoomTypeForm.getForm().reset();
}
},
buttons:[{
text:"保存信息",
minWidth:70,
handler:function()
{
if(AddRoomTypeForm.getForm().isValid())
{
//彈出效果
Ext.MessageBox.show
(
{
msg: '正在保存,請稍等...',
progressText: 'Saving...',
width:300,
wait:true,
waitConfig: {interval:200},
icon:'download',
animEl: 'saving'
}
);
setTimeout(function(){}, 1000);
AddRoomTypeForm.form.submit({
url:"URL/RoomType/AddRoomType.aspx",
method:"POST",
success:function(form,action)
{
//成功后
var flag=action.result.success;
if(flag=="true")
{
Ext.MessageBox.alert("恭喜","添加房間類型信息成功!");
RoomTypestore.reload();
AddRoomTypewin.hide();
}
},
failure:function(form,action)
{
Ext.MessageBox.alert("提示!","保存房間類型信息失敗!");
}
});
}
}
},{
text:"重置",
minWidth:70,
qtip:"重置數據",
handler:function()
{
AddRoomTypeForm.getForm().reset();
}
},{
text:"取 消",
minWidth:70,
handler:function()
{
AddRoomTypewin.hide();
}
}]
});
AddRoomTypeInfo=function()
{
AddRoomTypewin.show();
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -