/**
 * 离职申请：拓展
 * coyle
 */
shr.defineClass("shr.affair.hrman.ResignBizBillHrManEditEx", shr.affair.hrman.ResignBizBillHrManEdit, {
	 
	initalizeDOM : function () {
 		shr.affair.hrman.ResignBizBillHrManEditEx.superClass.setUiClass("com.kingdee.eas.hr.affair.app.ResignBizBill.formAll");
		shr.affair.hrman.ResignBizBillHrManEditEx.superClass.setBizBillInfoOsfName("getPersonResignBizBillInfoService");
		shr.affair.hrman.ResignBizBillHrManEditEx.superClass.initalizeDOM.call(this);
		var _self = this;
		if(_self.getOperateState() != 'VIEW'){
			_self.getField('entrys_isLodging').shrCheckbox("onChange",function(){
				var  flag = $(this).shrCheckbox('getValue');
				 _self.switchCusStyle(flag);
			});
		}

	},
	
	
	callChildBillDefinedOsf:function(personF7Id){
		var self = this;
		if(self._bizBillInfoOsfName!=""){
			shr.callService( {
				serviceName : self._bizBillInfoOsfName,
				param : {
					personId : personF7Id
				},
				async : false,
				success : function(data) {
					self.updateShrAffairBizBillData(data);
				}
			});
		}
		var effdtDate = $("#entrys_bizDate").shrDateTimePicker("getValue");
		self.assessLodging(personF7Id,effdtDate);
		
	},


	//判断住宿
	assessLodging: function  (personF7Id,effdtDate) {
		var self = this;
		self.remoteCall({
			method : "getIsLodging",
			async : false,
			param : {
				personId : personF7Id,
				effdtDate: effdtDate
			},
			success : function(data){
				if( data  && (data['isLodging'] == "true" || data['isLodging'] == true ) ){
					self.getField("entrys_isLodging").shrCheckbox('setValue', true);
				}else{
					self.getField("entrys_isLodging").shrCheckbox('setValue', false);
					 
				}
			}
		});
	},

	

	switchCusStyle:function(flagTar){
		var self = this;
		if(flagTar == "true" || flagTar ){
			self.getField("entrys_checkOutDate").shrDateTimePicker('enable');
			self.getField("entrys_checkOutDate").shrDateTimePicker('option','required',true);
		}else{
			self.getField("entrys_checkOutDate").shrDateTimePicker('disable');
			self.getField("entrys_checkOutDate").shrDateTimePicker('option','required',false);
		}

	},

	changeLeftCompanyDate : function(bizDate){
		var self = this ;
        var effdt=bizDate.shrDateTimePicker("getValue");
        if(effdt != null && effdt !=''){
        	var date = new Date(effdt);
            var beforeDate = new Date(date.getTime()-24*60*60*1000);
            
            var minDate = beforeDate.format("yyyy-MM-dd");
            var maxDate = date.format("yyyy-MM-dd");
            self.displayDate("entrys.leftCompanyDate",minDate,maxDate);
			// 提供给客户只读展示，因为预置字段配置只读无效
			$('#leftCompanyDateView').shrTextField('setValue', $('#entrys_leftCompanyDate').val());
			//计算年假
			self.calculateLeaveCount();
			var  personF7 = self.getField("entrys.person").shrPromptBox("getValue");
			if(null != personF7){
				self.assessLodging(personF7['id'],effdt);
			}
        }else{
        	self.getField("entrys.leftCompanyDate").shrDateTimePicker("setValue",null);
        	self.getField("entrys.forbidUserDate").shrDateTimePicker("setValue",null);
        	self.getField("entrys.forbidUserDate").shrDateTimePicker("setStartDate",null);
			$('#leftCompanyDateView').shrTextField('setValue', null);
        }   
    },
       


	
	
	
});