var isLastCycle = false;
shr.defineClass("shr.ats.HolidayLimitEditEx", shr.ats.HolidayLimitEdit, {
   initalizeDOM:function(){
		shr.ats.HolidayLimitEditEx.superClass.initalizeDOM.call(this);
	}
	,dealLimitChange:function(){
		//重新计算实际额度
		$('#addOrSubLimit').change(function(){
	    	$('#realLimit').shrNumberField('setValue',parseFloat(this.value)+parseFloat(atsMlUtile.getFieldOriginalValue('standardLimit')));
	    	//获取系统中设置小数位
	    	var num =atsMlUtile.getSysDecimalPlace();
	    	//重新计算剩余额度
	    	var billId = $("#id").val();
	    	var carryLimit = 0;
	    	_self.remoteCall({
            type:"post",
            async: false,
            method:"getCarryLimit",
            param:{"billId":billId},
            success:function(res){
               carryLimit = res.carryLimit;
            }
        });
	    	$('#remainLimit').val(
	    		(parseFloat(atsMlUtile.getFieldOriginalValue('realLimit'))-parseFloat(atsMlUtile.getFieldOriginalValue('usedLimit'))-parseFloat(atsMlUtile.getFieldOriginalValue('freezeLimit')) + carryLimit).toFixed(num)
	    	);
	    	
	   });
	   
	},
	saveAction: function(event) {
		var _self = this;
		
		if (_self.validate() && _self.verify()) {	
			var isOver = $('#holidayPolicy_isOver').val();
			var isOverAutoSub = $('#holidayPolicy_isOverAutoSub').val();
			var standardLimit = atsMlUtile.getFieldOriginalValue("standardLimit");
			var addOrSubLimit = atsMlUtile.getFieldOriginalValue("addOrSubLimit");
			var usedLimit = atsMlUtile.getFieldOriginalValue("usedLimit");
			var freezeLimit = atsMlUtile.getFieldOriginalValue("freezeLimit");
			var preOverdraftLimit = atsMlUtile.getFieldOriginalValue("preOverdraftLimit");
			if(isOver == 1){
				if(isOverAutoSub == 1){
					shr.showConfirm(jsBizMultLan.atsManager_holidayLimitEdit_i18n_11,function(){
						_self.doSave(event, 'save');
					})
				}else {
					_self.doSave(event, 'save');
				}
			}else {
				var billId = $("#id").val();
				var carryLimit = 0;
		    	_self.remoteCall({
	            type:"post",
	            async: false,
	            method:"getCarryLimit",
	            param:{"billId":billId},
	            success:function(res){
	               carryLimit = res.carryLimit;
	            }
	        });

				if((parseFloat(standardLimit)+parseFloat(addOrSubLimit)-parseFloat(usedLimit)-parseFloat(freezeLimit)-parseFloat(preOverdraftLimit) + carryLimit) < 0 ){
					shr.showInfo({message: jsBizMultLan.atsManager_holidayLimitEdit_i18n_12});
					return false;
				}else {
					_self.doSave(event, 'save');
				}
			}
		}else{
			if(_self != top){// in iframe
				shr.setIframeHeight(window.name);
			} 
				
		}	
	}

});
