
shr.defineClass("shr.affair.hrman.PluralityDelBizBillHrManEditExt", shr.affair.hrman.PluralityDelBizBillHrManEdit, {

    initalizeDOM: function () {
        var _self = this;
        shr.affair.hrman.PluralityDelBizBillHrManEditExt.superClass.initalizeDOM.call(this);
        if (this.operateState.toUpperCase() != 'VIEW') {
            _self.positionChange();
        }
    },

    //兼职职位监控
    positionChange: function () {
        var self = this;

        self.getField("entrys_oldPosition").on("change", function () {
            var personId = $("#entrys_person_el").val();
            var positionId = $("#entrys_oldPosition_el").val();
            shr.callHandler({
                handler: "com.kingdee.shr.affair.web.handler.hrman.FluctuationBizBillHrManEditHandlerEx",
                action: 'getPartEmpOrgRelation',
                async: false,
                type: "POST",
                param: {
                    "personId": personId,
                    "positionId": positionId
                },
                success: function (data) {
                    //【直属上级】
                    $("#entrys_ptlmanager").shrPromptBox("setValue", { id: data.leaderId, name: data.leaderName });
                    //【当前时薪】
                    self.getField("entrys_pthwage").shrTextField('setValue', data.hourlywage);
                    // 【离职日期】
                    // self.getField("entrys_bizDate").shrDateTimePicker('setValue',data.leftDate);
                }
            });

        });
    },
    positionF7ChangeEvent: function () { //监听岗位的变化
        var _self = this;
        $("#entrys_oldPosition").shrPromptBox("option", {
            onchange: function (e, value) {
                _self.clearPluralityPositionF7AndAssociateF7();
                if (value.current == null || value.current.id == null) {
                    return true;
                }
                var positionId = value.current.id;
                var personId = _self.getFieldValue("entrys.person");
                if (!personId) {
                    return true;
                }
                // 开始结束时间 赋值
                var effdt = value.current["EmpPosOrgRelation.EFFDT"];
                $("#entrys_beginDate").shrDateTimePicker("setValue", effdt)
                var leffdt = value.current["EmpPosOrgRelation.LEFFDT"];
                $("#entrys_bizDate").shrDateTimePicker("setValue", leffdt)
                var adminOrgName = value.current["adminorgunit.department.name"];
                // $("#entrys_oldPosition_adminOrgUnit_department").shrDateTimePicker("setValue",adminOrgName)




                //			 	var positionAndAdminOrgData = _self.getPositionById(positionId);
                //			 	_self.updateAdminF7Data(positionAndAdminOrgData);
                //取兼职开始时间等相关信息
                _self.remoteCall({
                    method: "getPluralityPositionData", //获取员工任职岗位,初始化兼职岗位
                    param: {
                        positionId: positionId,
                        personId: personId
                    },
                    success: function (response) {
                        if (response.adminorgunit != null) {
                            _self.updatePluralityPositionData(response);
                        } else {
                            _self.remoteCall({
                                method: "getPluralityPositionDataEx", //获取员工任职岗位,初始化兼职岗位
                                param: {
                                    positionId: positionId,
                                    personId: personId
                                },
                                success: function (response) {
                                    _self.updatePluralityPositionData(response);
                                }
                            });
                        }

                    }
                });
            }
        });
    },
});