tempfile.2.tmp

来自「一个使用ssh+ext的例子。 希望对开发这个应用的人带来好处。仔细研究里面的」· TMP 代码 · 共 851 行 · 第 1/2 页

TMP
851
字号
											,id:'cioPaidMoney'
											,vtype:'money'
											,allowBlank:false
											,anchor:'95%' //nessasary
											,maxLength:'12'
											,value:'0'
											,maxLengthText:'数值超出正常值,请检查后重新输入'
										}
										,{
											fieldLabel:'登记单号'
											,xtype:'textfield'
											,name:'cioOrderId'
											,id:'cioOrderId'
											,emptyText:'登记后生成'
											,disabled:true
											,allowBlank:false
											,readOnly:true
											,anchor:'95%'
										}
										,{
											fieldLabel:'登记单PKID'
											,xtype:'textfield'
											,name:'cioId'
											,id:'cioId'
											,hidden:true
											,hideLabel:true
											,anchor:'95%'
										}
										,{
											fieldLabel:'登记单PKID'
											,xtype:'textfield'
											,name:'cioId'
											,id:'cioId'
											,hidden:true
											,hideLabel:true
											,anchor:'95%'
										}
									]
									
								}
							]
						}
                   	]
				}
			]
		});
		Neo.frontdesk.CheckInForm.superclass.initComponent.apply(this,arguments);
		this.roomDetailTemplate=new Ext.XTemplate(
			 '<div class="ux-room-details">'
			 	,'<tpl for=".">'
			 		,'<div class="ux-room-details-id">'
			 		,'<p><b>房号:</b>{rmId}</p></div>'
			 		,'<div class="ux-room-details-type">'
			 		,'<p><b>房间类型:</b>{rmCatalog}</p></div>'
			 	,'</tpl>'
			 ,'</div>'
		);
	    this.roomsGrid = Ext.getCmp('roomsSlected');
	    this.checkinBtn=Ext.getCmp('checkinBtn');
	    this.cancelBtn=Ext.getCmp('cancelBtn');
	    
	    
	    this.bedRate=Ext.getCmp('cioBedRate');
	    this.bedRate.on({'change':this.onBedRateChange
	    	,scope:this});
	    this.totalRate=Ext.getCmp('cioTotalRate');
		this.paymentModel=Ext.getCmp('cioPaymentModel');
	    this.cardCatalog=Ext.getCmp('cioGuestCardCatalog');
	    this.guestType=Ext.getCmp('cioGuestType');
	    this.guestGender=Ext.getCmp('cioGuestGender');
	    this.totalRate=Ext.getCmp('cioTotalRate');
	   	this.guestName=Ext.getCmp('cioGuestName');
	    this.guestCardId=Ext.getCmp('cioGuestCardId');
	    this.guestDetailFormId = null;  //拿到detailForm的ID
	    /*this.paymentModel.setValue('现金');
	    this.cardCatalog.setValue('身份证');
	    this.guestType.setValue('普通客人');
	    this.guestGender.setValue('男');*/
	    this.roomsGrid.on({'cellcontextmenu':this.onCellContextMenu
	    			,scope:this});
	    this.roomsgGridMenu=new Ext.menu.Menu({
	    	id:'roomsGridMenu'
	    	,items:[
	    		{
	    			text:'取消该房间'
	    			,id:'cancelRoomBtn'
	    		}
	    	]
	    });
	    //this.guestCardId.on({'valid':this.onTextValueValid
	    //		,scope:this});
	    this.guestCardId.on({'blur':this.onAjaxGuestInfo
	    		,scope:this});
	    this.roomsGrid.on({'dblclick':this.onGridDblClick
	    		,scope:this});
	    this.roomsGrid.on({'afteredit':this.onGridAfterEdit
	    	,scope:this});	
	    this.checkinBtn.on({'click':this.onCheckinBtnClick
	    		,scope:this});
	    this.checkoutBtn=Ext.getCmp('checkoutBtn');
	    this.checkoutBtn.on({'click':this.onCheckOutBtnClick
	    	,scope:this});
	    this.cancelRoomBtn=Ext.getCmp('cancelRoomBtn');		
	    this.cancelRoomBtn.on({'click':this.onRoomCancelClick
	    		,scope:this});
	    this.on({'actionfailed':this.onActionFailed
	    		,scope:this});
	    this.addEvents({'updatermview':true});
	    this.resetBtn=Ext.getCmp('checkinResetBtn');
	    this.resetBtn.on({'click':this.onResetBtn
	    	,scope:this});
		this.daysNumber=Ext.getCmp('daysNumber');
	    this.daysNumber.on({'change':this.onDaysNumberChange
	    	,scope:this});
	    this.cioInDateTime=Ext.getCmp('cioInDateTime');
	    this.cioPreOutDateTime=Ext.getCmp('cioPreOutDateTime');
	    this.cioPreOutDateTime.on({'change':this.onPreOutChange
	    	,scope:this});
	}
	,onRender:function() {
		Neo.frontdesk.CheckInForm.superclass.onRender.apply(this,arguments);
	}
	,afterRender:function(){
		Neo.frontdesk.CheckInForm.superclass.afterRender.apply(this,arguments);
		var preOutDateTime=new Date().add(Date.DAY,1);
		preOutDateTime.setHours(12);
		preOutDateTime.setMinutes(0);
		preOutDateTime.setSeconds(0);
		preOutDateTime.setMilliseconds(0);
		this.cioPreOutDateTime.setValue(preOutDateTime);
		//this.preOutDateTime.setTime(new Date('12:00:00'));
	}
	/*,beforeDestroy: function(){
		Ext.FormPanel.superclass.beforeDestroy.call(this);
	}*/
	
	,addRoomInfo:function(selRoomRecord){	//增加房间到Grid
		var data=selRoomRecord.data;
		if(this.roomsGrid.store.indexOf(selRoomRecord)<0 && this.infoState=='init'){
			selRoomRecord.set('rmSetPrctDiscount',selRoomRecord.get('rmPrctDiscount'));
			this.roomsGrid.store.add(selRoomRecord);
			selRoomRecord.set('rmSetPrctPrice',selRoomRecord.get('rmPrctPrice'));
			var tr=parseFloat(this.totalRate.getValue());
			var sr=parseFloat(selRoomRecord.data.rmPrctPrice);
			this.totalRate.setValue(tr+sr);
			//Ext.ux.Toast.msg('提示','已选择房间{0}',selRoomRecord.get('rmId'));
			this.calculateTotalRate();
			this.checkinBtn.enable();
			this.resetBtn.enable();
		}	
		else{
			switch(this.infoState){
				case 'checkout':
					Ext.ux.Toast.msg('提示','该登记信息正在进行结账,不能添加新房间信息');
					break;
				case 'afterCheckout':
					Ext.ux.Toast.msg('提示','该登记信息已结账,不能添加新房间信息');
					break;
				case 'afterCheckin':
					Ext.ux.Toast.msg('提示','该登记信息已保存,请重置后重新操作');
					break;
				case 'showCheckinInfo':
					Ext.ux.Toast.msg('提示','查看登记信息时不能添加新房间');
					break;
				case 'init':
					Ext.ux.Toast.msg('提示','该房间已在登记中');
					break;
			}
			//Ext.Msg.alert('提示:','该房间已在登记中!');
			Ext.ux.Toast.msg('提示','该房间已在登记中!');
		}
		this.checkinBtn.enable();
		this.resetBtn.enable();
	}
	,deleteSelectedGridRaw:function(){		//移除已选择房间
		var record=this.getGridSelectRecord();
		if(!record||!record.id||!record.get('rmId')){
			return;
		}else{
			this.roomsGrid.store.remove(record);
		}
		var tr=parseFloat(this.totalRate.getValue());
		var sr=parseFloat(record.data.rmSetPrctPrice);
		this.totalRate.setValue(tr-sr);
		if(this.roomsGrid.store.getCount()<1){
			this.resetBtn.disable();
			this.checkinBtn.disable();
		}
	}
	,getGridSelectRecord:function(){
		var sm=this.roomsGrid.getSelectionModel();
		var record;
		record=sm.selection.record;
		return record;
	}
	,onActionFailed:function(form,action){
		console.log('actionfailed',action);
	}
	,onBedRateChange:function(){
		this.calculateTotalRate();
	}
	/**
	 * 登记入住
	 */
	,onCheckinBtnClick:function(){	
		var rds=[];
		for(var i=0;i<this.roomsGrid.store.getCount();i++){
			rds.push(this.roomsGrid.store.getAt(i).data);
			//console.log(this.roomsGrid.store.getAt(i).data);
		}
		var rdsjson=Ext.util.JSON.encode(rds);
		//console.log(rdsjson);
		this.getForm().submit({
			url:'checkin.htm?action=checkin'
			,params:{roomDataes:rdsjson}
			,method:'POST'
			,scope:this
			,success:function(){
				/*Ext.Msg.show({
					title:'提示'
					,msg: '登记已成功'
					,buttons: Ext.Msg.YES
					,fn:this.updateRmView.createDelegate(this,[],true)
					,animEl: 'elId'
					,icon: Ext.MessageBox.INFO
				});*/
				Ext.Msg.alert('提示', '登记已成功'
						,this.updateRmView.createDelegate(this,[],true)
						
						/*function(){
							console.log('checkin success');
							//this.updateRmView();
						}.createDelegate(this,[],true)*/
				)
			}
			,failure:function(form,action){
				if(action.failureType == 'server'){ 
               		obj = Ext.util.JSON.decode(action.response.responseText); 
                	Ext.Msg.alert('错误:', obj.errors.reason); 
                }
                if(action.failureType == 'client'){
                	Ext.ux.Toast.msg('提示','登记信息不正确,请核对后重新操作');
                }
                /*else{ 
                    Ext.Msg.alert('警告!', '无法连接到服务器: ' + action.response.responseText ); 
                }*/
			}
		})
	}
	,onCheckOutBtnClick:function(){
		this.infoState='checkout';
		var win=new Neo.frontdesk.CheckoutWin();
		win.show(this);
	}
	,onDaysNumberChange:function(){
		//bug
		var cioInDay=this.cioInDateTime.getValue().getDayOfYear();
		//var preOutDay=this.cioPreOutDateTime.getValue().getDayOfYear();
		//var subTime=this.cioPreOutDateTime.getValue()-this.cioInDateTime.getValue();
		//var days=preOutDay-cioInDay;
		//console.log(subTime);
		//console.log(preOutDay);
		//console.log(preOutDay);
		//console.log(days);
		var days=parseInt(this.daysNumber.getValue());
		var preOutDateTime=new Date().add(Date.DAY,days);
		preOutDateTime.setHours(12);
		preOutDateTime.setMinutes(0);
		preOutDateTime.setSeconds(0);
		preOutDateTime.setMilliseconds(0);
		this.cioPreOutDateTime.setValue(preOutDateTime);
		this.calculateTotalRate();
	}
	,onGridAfterEdit:function(e){
		if(e.field=='rmSetPrctDiscount'){
			var prctPrice=parseFloat(e.record.get('rmPrctPrice'));
			var setDiscount=parseFloat(e.value);
			var setPrice=((setDiscount*prctPrice)/100).toFixed(2);
			e.record.set('rmSetPrctPrice',setPrice);
		}
		if(e.field=='rmSetPrctPrice'){
			var prctPrice=parseFloat(e.record.get('rmPrctPrice'));
			var setPrice=parseFloat(e.value);
			var setDiscount=((setPrice/prctPrice)*100).toFixed(2);
			e.record.set('rmSetPrctDiscount',setDiscount);
		}
		this.calculateTotalRate();
	}
	,onGridDblClick:function(){
		if(this.infoState=='init'){
			this.deleteSelectedGridRaw();
			this.calculateTotalRate();
		}
	}
	,onPreOutChange:function(){
		//bug
		var cioInDay=this.cioInDateTime.getValue().getDayOfYear();
		var preOutDay=this.cioPreOutDateTime.getValue().getDayOfYear();
		var days=preOutDay-cioInDay;
		this.daysNumber.setValue(days);
		this.calculateTotalRate();
	}
	,onResetBtn:function(){
		this.roomsGrid.store.removeAll();
		var formRecord = Ext.data.Record.create([
		    	'cioInDateTime'		//入住时间
				,'daysNumber'  //天数
				,'cioPreOutDateTime'	//预计离店时间
				,'cioGuestType'		//客人类型
				,'cioManNumber'	//客人数
				,'cioGuestName'	//客人姓名
				,'cioGuestGender'	//客人性别
				,'cioGuestCardId'	//客人证件号
				,'cioGuestCardCatalog'		//客人证件类型
				,'cioBedRate'		//加床费
				,'cioTotalRate'	//总费用
				,'cioPaymentModel'		//支付方式
				,'cioPaidMoney'			//押金数
				,'cioOperator'		//操作员
				,'cioOrderId'		//单号
		]);

		var resetRecord = new formRecord({
		    cioInDateTime: new Date().format('Y-m-d')
		    ,daysNumber:'1'
		    ,cioPreOutDateTime:new Date().add(Date.DAY,1).format('Y-m-d')
		    ,cioGuestType:'普通客人'
		    ,cioManNumber:'2'
		    ,cioGuestName:''
		    ,cioGuestGender:'男'
		    ,cioGuestCardId:''
		    ,cioGuestCardCatalog:'身份证'
		    ,cioBedRate:'0'
		    ,cioTotalRate:'0'
		    ,cioPaymentModel:'现金'
		    ,cioPaidMoney:'0'
		    ,cioOperator:'admin'	//
		    ,cioOrderId:''
		});
		this.getForm().loadRecord(resetRecord);
		this.guestName.clearInvalid();
		this.guestCardId.clearInvalid();
		this.checkinBtn.disable();
		this.checkoutBtn.disable();
		this.resetBtn.disable();
		this.infoState='init';
	}
	/*,onRowContextMenu:function(grid,rowIndex,e){
			e.stopEvent();
			this.roomsGrid.getSelectionModel().selectRow(rowIndex);
			var coords=e.getXY();
			this.roomsgGridMenu.showAt([coords[0],coords[1]]);
	}*/
	,onCellContextMenu:function(grid,rowIndex,cellIndex,e){
		e.stopEvent();
		this.roomsGrid.getSelectionModel().select(rowIndex,cellIndex);
		var coords=e.getXY();
		this.roomsgGridMenu.showAt([coords[0],coords[1]]);
	}
	,onRoomCancelClick:function(){
		if(this.infoState=='init')
			this.deleteSelectedGridRaw();
	}
	,showCheckinInfo:function(rmId){
		this.form.load({
			url:'checkin.htm?action=getCheckinInfo'
			,params:{rmId:rmId}
			,method:'POST'
			,scope:this
			,waitMsg:'加载登记信息...'
			,success:function(){
			
			}
			,failure:function(form,action){
			
			}
		})
		this.roomsGrid.store.load({params:{rmId:rmId}});
		this.infoState='showCheckinInfo';
		this.checkoutBtn.enable();
		this.resetBtn.enable();
	}
	,calculateTotalRate:function(){
		//计算总费用
		//grid里价格叠加 * 天数 + 加床费
		var totalRate=0;
		for(var i=0;i<this.roomsGrid.store.getCount();i++){
			totalRate=totalRate+parseInt(this.roomsGrid.store.getAt(i).get('rmSetPrctPrice'));
			//rds.push(this.roomsGrid.store.getAt(i).data);
		}
		totalRate=totalRate*parseInt(this.daysNumber.getValue());
		totalRate=totalRate+parseInt(this.bedRate.getValue());
		this.totalRate.setValue(totalRate);
	}
	,updateRmView:function(){
		this.infoState='afterCheckin';
		this.checkinBtn.disable();
		this.fireEvent('updatermview');
	}
	,setGuestDetailForm:function(detailFormId){
		this.guestDetailFormId = detailFormId;
	}
	,onAjaxGuestInfo:function(){
		console.info("blur");
		//this.guestCardId.fireEvent('change');
		if(this.guestCardId.isValid(false)){
			this.onTextValueValid();
		}
		//this.guestCardId.on({'valid':this.onTextValueValid
	    //		,scope:this});
	  //  this.guestCardId.fireEvent('valid');
	}
	,onTextValueValid:function(){
		gtCardId = this.guestCardId.getValue();
		gtName = this.guestName.getValue();
		this.tabpanel = Ext.getCmp('tabpanel');
		this.tabpanel.setActiveTab(this.guestDetailFormId);
		this.tabpanel.setActiveTab('checkinform');
		this.detailForm = Ext.getCmp(this.guestDetailFormId);
		this.detailForm.loadRecord(gtCardId,gtName);
		console.info("valid");
	}
});
Ext.reg('checkinform',Neo.frontdesk.CheckInForm);

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?