
shr.defineClass("shr.empContract.shrEmployeeNotLaborContractEditExt", shr.empContract.shrEmployeeNotLaborContractEdit, {
	
	initalizeDOM : function () {
		var _self = this;
		shr.empContract.shrEmployeeNotLaborContractEditExt.superClass.initalizeDOM.call(this);
		if(this.getOperateState() == 'ADDNEW'){
            _self.defaultInitalize();
        }
	},
	
	/*setInitDate : function(){
		var self = this;
		//合同签订组织
		$("#hrOrgUnit").shrPromptBox("setValue", {id:"00000000-0000-0000-0000-000000000000CCE7AED4", name:"Guangdong Technion Israel Institute of Technology"});
		//甲方劳动合同主体
		$("#labContractFirstParty").shrPromptBox("setValue", {id:"bHdk2ak5RIyQIAgXzXz/wo6rEMM=", name:"Guangdong Technion Israel Institute of Technology"});
		//合同协议
		$("#contractTemplet_contractType").shrPromptBox("setValue", {id:"mlcyHoWATgOPmeAQgwbE9AUpjB4=", name:"Agreement"});
		var contractType = this.getFieldValue('contractTemplet_contractType');
		if(contractType){
			$("#contractTemplet").shrPromptBox("setFilter","contractType.id in ('" + contractType + "')");
		}
	},*/
	
	
	//页面初始化默认值
	defaultInitalize:function(){
		var _self = this;

        _self.remoteCall({
            method: "getDefaultHrOrg",
            param: {}, 
            async: false,
            success: function(response) {
                if(response.hrOrgId){
                    var responseObejct = {id: response.hrOrgId,name: response.hrOrgName};
                    $("#hrOrgUnit").shrPromptBox("setValue", responseObejct);
                }
            },
            error : function(){
                
            }
        });

        _self.remoteCall({
            method: "getDefaultContractParty",
            param: {}, 
            async: false,
            success: function(response) {
                if(response.contractPartyId){
                    var responseObejct = {id: response.contractPartyId,name: response.contractPartyName};
                    $("#labContractFirstParty").shrPromptBox("setValue", responseObejct);
                }
            },
            error : function(){
                
            }
        });

        // _self.remoteCall({
        //     method: "getDefaultContractType",
        //     param: {}, 
        //     async: false,
        //     success: function(response) {
        //         if(response.contractTypeId){
        //             var responseObejct = {id: response.contractTypeId,name: response.contractTypeName};
        //             $("#contractTemplet_contractType").shrPromptBox("setValue", responseObejct);
        //             $("#entrys_contractTemplet").shrPromptBox("setFilter","contractType.id = '" + response.contractTypeId + "'");
        //         }
        //     },
        //     error : function(){
                
        //     }
        // });

	},
	
	//标准产品代码覆盖
	labContractPartyChangeHandler: function(listenProId, changeProId1, changeProId2) {
        var _self = this;
        if (_self.getOperateState() != 'VIEW') {
            var $labContractFirstParty = _self.getField(listenProId);
            $labContractFirstParty.shrPromptBox("option", {
                onchange: function(e, value) {
                    var currentObj = value.current;
                    var previousObj = value.previous;

                    if (currentObj && currentObj.id && previousObj && currentObj.id != previousObj.id) {
                        _self.remoteCall({
                            method: "getFirstPartyInfoById",
                            param: {
                                "id": currentObj.id
                            },
                            success: function(data) {
                                if (data) {
                                    if (data.status == "success") {
                                        if (null != data.delegatePerson_l1 && "" != data.delegatePerson_l1) {
                                            _self.getField(changeProId1).shrMultiLangBox("setValue", data.delegatePerson_l1, 'l1');
                                        }
                                        if (null != data.delegatePerson_l2 && "" != data.delegatePerson_l2) {
                                            _self.getField(changeProId1).shrMultiLangBox("setValue", data.delegatePerson_l2, 'l2');
                                        }
                                        if (null != data.delegatePerson_l3 && "" != data.delegatePerson_l3) {
                                            _self.getField(changeProId1).shrMultiLangBox("setValue", data.delegatePerson_l3, 'l3');
                                        }
                                        if (null != data.toUnitAddress_l1 && "" != data.toUnitAddress_l1) {
                                            _self.getField(changeProId2).shrMultiLangBox("setValue", data.toUnitAddress_l1, 'l1');
                                        }
                                        if (null != data.delegatePerson_l2 && "" != data.delegatePerson_l2) {
                                            _self.getField(changeProId2).shrMultiLangBox("setValue", data.toUnitAddress_l2, 'l2');
                                        }
                                        if (null != data.delegatePerson_l3 && "" != data.delegatePerson_l3) {
                                            _self.getField(changeProId2).shrMultiLangBox("setValue", data.toUnitAddress_l3, 'l3');
                                        }
                                        _self._currentContractFirstParty = {
                                            id: data.id,
                                            name: data.name
                                        };
                                    } else if (data.status == "fail") { //如果缓存的数据已被删掉，则清掉缓存。
                                        _self._currentContractFirstParty = null;
										//清除覆盖值
                                        //$labContractFirstParty.shrPromptBox("setValueNoTrigger", null);
                                    }
                                }
                            }
                        });
                    } else {
                        _self._currentContractFirstParty = null;
                    }
                }
            });
        }
    }
	
});