jsf7多选

shr.defineClass("shr.emp.EmployeeEdit", shr.org.SHRMainDataEdit, {

    _resStr: null,
    verifyFlag_idCard: "",
    verifyFlag_passport: "",
    initalizeDOM: function () {
        var _self = this;


        _self.verifyFlag_passport = false;
        var description = _self.getDescription(_self.getOperateState(), _self.getHistoryOperateState());
        shr.emp.EmployeeEdit.superClass.setDescription(description);
        shr.emp.EmployeeEdit.superClass.initalizeDOM.call(this);
        var idCardNOElement = this.getRealId('idCardNO');
        var passportNOElement = this.getRealId('passportNO');
        _self.bornDayChangeEvent(); // 出生日期变动监听
        if (this.getOperateState() != 'VIEW') {
            _self.addPassportTips("passportNO");//添加护照tips
            var idCardNO_Info = this.getFieldValue("idCardNO");
            var passportNO_Info = this.getFieldValue("passportNO");
            var idCardAndPassPortNotNull = false;
            if ((idCardNO_Info != null && idCardNO_Info != "") || (passportNO_Info != null && passportNO_Info != "")) {
                idCardAndPassPortNotNull = true;
            }
            if (idCardAndPassPortNotNull == true) {
                $("#" + idCardNOElement).removeAttr("placeholder");
            }

            var dom =
                '<div id="zjsj" style="padding-left:30px; padding-right:30px">'
                + '<div class="photoCtrlBox">'
                + '<div style="float:left;margin-left:15px">'
                + '<span style="margin-left:-15px">直接上级</span>&nbsp;&nbsp;'
                + '<div style="margin-left:35px;margin-top:-20px;margin-bottom:0px;width:200px">'
                + '<input type="text" id="zhouqi" name="ZQ" class="input-height" isHRBaseItem="true" bizFilterFields="hrOrgUnit">'
                + '</div>'
                + '</div>'
                + '</div>'
                + '</div>';
            $(document.body).append(dom);
            //监听文本改变事件
            $("#ywsjcs").click(function () {
                var zhoouqi_F7 = {
                    id: "zhouqi",
                    name: "ZQ",
                    subWidgetName: 'shrPromptGrid',
                    subWidgetOptions: {
                        title: "直接上级",
                        uipk: "com.kingdee.eas.basedata.person.app.Person.F7"//员工UIPK
                    },
                    permItemId : shr.getButtonPermItemId({method:"zjsj"})
                };
                $('#zhouqi').shrPromptBox(zhoouqi_F7);
                var dialog=$("#zjsj").dialog({
                    autoOpen : true,
                    show : "blind",
                    width : 600,
                    height : 200,
                    title : "选择直接上级",
                    resizable : false,
                    position : [ 'center', 'center' ],
                    modal : true,
                    buttons : {
                        '确定' : function() {
                            var userName=$('#zhouqi').get(0).title;
                            var userFid=$('#zhouqi_el').get(0).value;
                            console.log(userName)
                            console.log(userFid)
                            shr.callHandler({
                                handler: "com.kingdee.eas.custom.handler.ProductReturnHandler",
                                action: 'syncReturnInfo',
                                param:  {
                                },
                                async: false,
                                type:"POST",
                                success: function(response) {
                                    shr.showInfo({
                                        message:"同步成功!!!",
                                        hideAfter: 3
                                    });
                                    that.reloadGrid();
                                    dialog.dialog('close');
                                }

                            })

                        },
                        '取消' : function() {
                            dialog.dialog('close');
                        }
                    }

                });
            });
            if (this.operateState == "EDIT") {
                this.bindFun();
            }
            //根据身份证取出生日期和性别
            $("#" + idCardNOElement).change(function () {
                _self.verifyFlag_idCard = false;
                var idCardNO_InfoInner = _self.getFieldValue("idCardNO");
                if (idCardNO_InfoInner == null || idCardNO_InfoInner == "") return;
                var hrOrgUnitId = $("#hrOrgUnitId").val();
                var localLang = shr.getFieldLangByContext();
                var personName = _self.getFieldValue("name")[localLang];
                shr.callService({
                    serviceName: "getPersonIdCardNOInfoService",
                    param: {
                        idCardNO: idCardNO_InfoInner,
                        personId: _self.billId,
                        hrOrgUnitId: hrOrgUnitId,
                        personName: personName
                    },
                    success: function (data) {
                        _self.verifyFlag_idCard = true;
                        var birthdayElement = _self.getRealId('birthday');
                        if (data.birthday) {
                            $("#" + birthdayElement).shrDateTimePicker('setValue', data.birthday);
                            var birthday = _self.getFieldValue(birthdayElement);
                            var birthDate = new Date(birthday);
                            var curDate = new Date();
                            var yearVal = curDate.getFullYear() - birthDate.getFullYear();
                            var age = _self.getRealId('age');
                            var i = 0;
                            if (curDate.getMonth() < birthDate.getMonth()) {
                                i = -1;
                            } else if (curDate.getMonth() > birthDate.getMonth()) {
                                i = 0;
                            } else {
                                //getDay是获得星期几,getDate才是获得日期
                                if (curDate.getDate() < birthDate.getDate()) {
                                    i = -1;
                                } else if (curDate.getDate() >= birthDate.getDate()) {
                                    i = 0;
                                }
                            }
                            if (yearVal) {
                                $("#" + age).val(yearVal + i);
                            }
                            // 获取星座和属相
                            _self.checkConstellationAndZodiac(data.birthday.split(" ")[0]);
                        }
                        if (data.gender_value) {
                            var value = data.gender_value;
                            var genderElement = _self.getRealId('gender');
                            $("#" + genderElement).shrSelect('setValue', value);
                        }
                    }
                });
            });
            //校验护照号是否有和预入职、入职、员工重复
            $("#" + passportNOElement).change(function () {
                _self.verifyFlag_passport = false;
                var passportNO_Info = _self.getFieldValue("passportNO");
                if (passportNO_Info == null || passportNO_Info == "") return;
                var localLang = shr.getFieldLangByContext();
                var personName = _self.getFieldValue("name")[localLang];
                shr.callService({
                    serviceName: "getPersonPassPortNOInfoService",
                    param: {
                        passportNO: passportNO_Info,
                        personId: _self.billId,
                        personName: personName
                    },
                    success: function (data) {
                        _self.verifyFlag_passport = true;
                    }
                });
            });
//			var birthdayElement = _self.getRealId('birthday');
//			$("#"+birthdayElement).change(function(){
//				_self.updateAgeField(birthDate, endDate);
//			});
            _self.getField("birthday").shrDateTimePicker("onChange", function () {
                _self.updateAgeField();
            });
            var $deathDate = _self.getField("deathDate");
            if ($deathDate) {
                deathDate = $deathDate.shrDateTimePicker("onChange", function () {
                    _self.verifyDeathDate();
                    _self.updateAgeField();
                });
            }
            //计算社会工作年限
//			_self.calSocialServiceYears();
            $("#" + this.getRealId('jobStartDate')).change(function () {
                _self.calSocialServiceYears();
            });
            var $adjustSerVal = $("#" + this.getRealId('adjustSerVal'));
            $adjustSerVal.change(function () {
                _self.calSocialServiceYears();
            });
            $adjustSerVal.on("keyup", function () {
                _self.numberControlHandler($adjustSerVal);
            });

            _self.initRetireDate();
            _self.processIdCardLongEffect();
        }
        _self.checkFullNameIsSubFeild();
        //姓名分栏改变事件
        _self.globalNameChangeEvent();
        _self.initDecimalFormatter();
        _self.showHistoryDifferentInfo();//变色显示历史版本变动的字段
        $('.view_manager_body', parent.document).animate({'margin-top': '30px'});


    },

    verify: function () {
        var _self = this;
        var idCardNO_InfoInner = _self.getFieldValue("idCardNO");
        var passportNO_Info = _self.getFieldValue("passportNO");
        if (idCardNO_InfoInner == null || idCardNO_InfoInner == "") {
            _self.verifyFlag_idCard = true;
            if (passportNO_Info == null || passportNO_Info == "") {
                _self.verifyFlag_passport = false;
                shr.showError({message: jsBizMultLan.emp_employeeEdit_i18n_1});
                return false;
            }
        }
        ;
        // 这里取当前语言的personName进行校验
        var localLang = shr.getFieldLangByContext();
        var personName = _self.getFieldValue("name")[localLang];
        if (idCardNO_InfoInner && _self.verifyFlag_idCard == false) {
            var hrOrgUnitId = $("#hrOrgUnitId").val();
            shr.callService({
                serviceName: "getPersonIdCardNOInfoService",
                param: {
                    idCardNO: idCardNO_InfoInner,
                    personId: _self.billId,
                    hrOrgUnitId: hrOrgUnitId,
                    personName: personName
                },
                async: false,
                success: function (data) {
                    _self.verifyFlag_idCard = true;
                }
            });
            if (_self.verifyFlag_idCard == false) {
                return _self.verifyFlag_idCard;
            }
        }
        if (passportNO_Info && _self.verifyFlag_passport == false) {
            shr.callService({
                serviceName: "getPersonPassPortNOInfoService",
                param: {
                    passportNO: passportNO_Info,
                    personId: _self.billId,
                    personName: personName
                },
                success: function (data) {
                    _self.verifyFlag_passport = true;
                }
            });
            if (_self.verifyFlag_passport == false) {
                return _self.verifyFlag_passport;
            }
        }
        return true;
    },
    initRetireDate: function () {
        var self = this;
        if (self.checkAction()) {
            self.getField("retireDate").shrDateTimePicker("enable");
            self.getField("retireDate").shrDateTimePicker("option", {
                readonly: false
            });
        }
    },
    checkAction: function () {
        var flag = false;
        var personId = _self.getField('id').val()
        shr.callService({
            serviceName: "checkActionService",
            async: false,
            param: {
                personId: personId,
                type: 3
            },
            success: function (result) {
                flag = result;
            }
        });
        return flag;
    },
    /**
     * 根据出生日期和身故日期更新年龄
     */
    updateAgeField: function () {
        var _self = this;
        var birthday = _self.getField("birthday").shrDateTimePicker("getValue");
        var deathDate = null;
        var $deathDate = _self.getField("deathDate");
        if ($deathDate.length > 0)
            deathDate = $deathDate.shrDateTimePicker("getValue");
        if (birthday) {
            var birthDate = new Date(birthday);
            var endDate = deathDate ? new Date(deathDate) : new Date();
            var yearVal = endDate.getFullYear() - birthDate.getFullYear();
            var i = 0;
            if (endDate.getMonth() < birthDate.getMonth()) {
                i = -1;
            } else if (endDate.getMonth() > birthDate.getMonth()) {
                i = 0;
            } else {
                if (endDate.getDate() < birthDate.getDate()) {
                    i = -1;
                } else if (endDate.getDate() >= birthDate.getDate()) {
                    i = 0;
                }
            }
            _self.getField("age").shrTextField("setValue", yearVal + i);
        }
    },

    /**
     * 校验身故日期
     * 填写身故日期时,若身故日期早于或等于出生日期,提示“身故日期不能早于出生日期!”;若身故日期晚于当前系统日期,提示“身故日期不能晚于当前日期!”
     */
    verifyDeathDate: function () {
        var _self = this;
        var $deathDate = _self.getField("deathDate");
        var deathDate = $deathDate.shrDateTimePicker("getValue");
        if (deathDate) {
            deathDate = new Date(deathDate);
            var curDate = new Date();
            if (deathDate > curDate) {
                _self.getField("deathDate").shrDateTimePicker("setValue", "");
                shr.showError({message: jsBizMultLan.emp_employeeEdit_i18n_2});
            } else {
                var birthday = _self.getField("birthday").shrDateTimePicker("getValue");
                if (birthday) {
                    birthday = new Date(birthday);
                    if (deathDate <= birthday) {
                        _self.getField("deathDate").shrDateTimePicker("setValue", "");
                        shr.showError({message: jsBizMultLan.emp_employeeEdit_i18n_3});
                    }
                }
            }
        }
    },
    bindFun: function () {
        alert('1111')
    },
    getDescription: function (operateState, historyOperateState) {
        var description = "";
        if (operateState == 'EDIT') {
            if (historyOperateState == 'change') {
                description = jsBizMultLan.emp_employeeEdit_i18n_5;
            } else if (historyOperateState == 'revise') {
                description = jsBizMultLan.emp_employeeEdit_i18n_4;
            }

        }
        return description;
    },
    /**
     * 覆盖父类'设置历史相关内容',设置生效日期可编辑
     */
    handleHistorySetting: function () {

    },
    getCalEndDate: function () {
        var endDate = "";
        if (this.getFieldValue("retireDate") != null && this.getFieldValue("retireDate") != "") {
            endDate = this.getFieldValue("retireDate");
        }
        return endDate;
    },
    calSocialServiceYears: function () {
        var self = this;
        var beginDateStr = self.getFieldValue("jobStartDate");
        var endDateStr = self.getCalEndDate();
        var adjVal = self.getFieldValue("adjustSerVal");
        var txtFieldVal = self.calculateWorkTimeVal(beginDateStr, endDateStr, adjVal);
        var socialServiceYears = "#" + self.getRealId("socialServiceYears");
        self.showSocialServiceYears(socialServiceYears, txtFieldVal);
    },
    showSocialServiceYears: function (fieldName, val) {
        if (this.getOperateState() != 'VIEW') {
            if (val == "") {
                $(fieldName).val("");
            } else if (val >= 0) {
                $(fieldName).val(val);
            } else if (val < 0) {
                $(fieldName).val(0.0);
            }
        } else {
            if (val == "") {
                $(fieldName).html("");
            } else if (val >= 0) {
                $(fieldName).html(val);
            } else if (val < 0) {
                $(fieldName).html(0.0);
            }
        }
    },
    calculateWorkTimeVal: function (beginDateStr, endDateStr, adjVal) {//计算工作年限
        var self = this;
        if (beginDateStr != null && beginDateStr != "") {
            var beginDate = new Date(beginDateStr);
            var endDate;
            if (endDateStr == null || endDateStr == "") {
                endDate = new Date();
            } else {
                endDate = new Date(endDateStr);
            }
            var yearVal = endDate.getFullYear() - beginDate.getFullYear();
            var monthVal = endDate.getMonth() - beginDate.getMonth();
            if (adjVal == null || adjVal == "") {
                adjVal = 0.0;
            }
            var workTime = yearVal + monthVal / 12.0 - adjVal;
            var workTime_Trunc = self.getRoundValueBySysParam(workTime);
            return workTime_Trunc;
        } else {
            return "";
        }
    },
    /**
     * 用于keyup事件,控制只能输入两位小数
     * @Param field input输入框jQuery对象
     */
    numberControlHandler: function (field) {
        var obj = field[0];
        obj.value = obj.value.replace(/[^-\d.]/g, ""); //清除"数字"和"."以外的字符
        obj.value = obj.value.replace(/^\./g, ""); //验证第一个字符是数字而不是小数点
        obj.value = obj.value.replace(/\.{2,}/g, "."); //只保留第一个. 清除多余的小数点
        obj.value = obj.value.replace(".", "$#$").replace(/\./g, "").replace("$#$", ".");//只保留第一个. 清除多余的小数点
        obj.value = obj.value.replace(/^-/g, "$#$").replace(/-/g, "").replace("$#$", "-");//只保留开头的负号. 清除多余的负号
        obj.value = obj.value.replace(/^(\-)*(\d+)\.(\d\d).*$/, '$1$2.$3'); //只能输入两个小数
    },

    /**
     * 根据系统参数对小数位进行取舍
     */
    getRoundValueBySysParam: function (value) {
        var self = this;
        var scale = parseInt(self.getFieldValue("scale"));//小数位数
        var factor = Math.pow(10, scale);
        var roundMode = self.getFieldValue("roundMode");//取舍规则:四舍五入ROUND_HALF_UP,向上取整ROUND_CEILING,向下取整ROUND_FLOOR
        if (roundMode == "ROUND_HALF_UP") {
            return (Math.round(value * factor)) / factor;
        } else if (roundMode == "ROUND_CEILING") {
            return (Math.ceil(value * factor)) / factor;
        } else if (roundMode == "ROUND_FLOOR") {
            return (Math.floor(value * factor)) / factor;
        }
    },
    /**
     * 查看信息变更记录
     */
    viewHistoryRecordAction: function () {
        var _self = this;
//		var url = shr.getContextPath() + '/objectHistoryInfoList.do';
//		this.reloadPage({
//			breadcrumbType: 'viewTiele'
//		}, url);
        var billId = shr.getUrlRequestParam('billId');
        if (billId) {
        } else {
            billId = $('input#id').val();
        }
        _self.remoteCall({
            method: "viewHistoryRecord",
            param: {
                billId: billId
            },
            success: function (data) {
                if (data == true) {
                    _self.reloadPage({
                        uipk: 'shr.Person.History.list',
                        billId: billId
                    });
                }
            }
        });
    },
    /**
     * 变更过得变色显示
     */
    showHistoryDifferentInfo: function () {
        var historyInfoDifferentKey = jsBinder.initData.historyInfoDifferentKey;
        if (historyInfoDifferentKey && historyInfoDifferentKey != "") {
            var keys = historyInfoDifferentKey.split(",");
            for (var index in keys) {
                var realId = shr.getRealId(keys[index]);
                if ($("#" + realId).length == 1) {
                    $("#" + realId).css("color", "red");
                    $("#" + realId + "  pre").css("color", "red");
                }
            }
        }
    },
    reviseAction: function (method, options) {
        var self = this;
        //没生成管理关系之前,不允许编辑
        if (!self.checkHrOrgUnitId()) {
            shr.showError({
                message: _resStr
            });
            return;
        }
        if (!self.checkPersonCanEdit()) {
            shr.showError({
                message: _resStr
            });
            return;
        }
        shr.emp.EmployeeEdit.superClass.reviseAction.call(self, method, options);
    },
    changeAction: function (method, options) {
        var self = this;
        //没生成管理关系之前,不允许编辑
        if (!self.checkHrOrgUnitId()) {
            shr.showError({
                message: _resStr
            });
            return;
        }
        if (!self.checkPersonCanEdit()) {
            shr.showError({
                message: _resStr
            });
            return;
        }
        shr.emp.EmployeeEdit.superClass.changeAction.call(self, method, options);
    },
    checkHrOrgUnitId: function () {
        var _self = this;
        var $hrOrgUnitInput = $("#hrOrgUnitId");
        if ($hrOrgUnitInput.length <= 0) {
            $hrOrgUnitInput = $("#hrOrgUnitId", parent.document);
        }
        if ($hrOrgUnitInput.length == 0) {
            _resStr = jsBizMultLan.emp_employeeEdit_i18n_0;
            return false;
        }
        var personIdStr = shr.getUrlParam("billId");
        var verifyFlag = true;

        if (personIdStr) {
            _resStr = shr.callHandler({
                handler: "com.kingdee.eas.hr.emp.web.handler.EmployeeEditHandler",
                action: "checkHrOrgUnitId",
                param: {
                    personId: personIdStr
                },
                async: false,
                type: "POST",
                success: function (message) {
                    if (message == "") {
                        verifyFlag = true;
                    } else {
                        verifyFlag = false;
                        _resStr = message;
                    }
                }
            });
        }
        return verifyFlag;
    },

    checkPersonCanEdit: function () {
        var _self = this;
        var personIdStr = shr.getUrlParam("billId");
        var verifyFlag = true;

        if (personIdStr) {
            _resStr = shr.callHandler({
                handler: "com.kingdee.eas.hr.emp.web.handler.EmployeeEditHandler",
                action: "checkPersonCanEdit",
                param: {
                    personId: personIdStr
                },
                async: false,
                type: "POST",
                success: function (message) {
                    if (message == "") {
                        verifyFlag = true;
                    } else {
                        verifyFlag = false;
                        _resStr = message;
                    }
                }
            });
        }
        return verifyFlag;
    },

    processIdCardLongEffect: function () {
        var _self = this;
        if (_self.getOperateState() != 'VIEW') {
            var longEffect = $("#idCardLongEffect").is(':checked');
            _self.longEffectStatus(longEffect);
            if ($.browser.msie) {
                $('input:checkbox#idCardLongEffect').click(function () {
                    _self.longEffectStatus($(this).is(':checked'));
                });
            } else {
                $("#idCardLongEffect").change(function () {
                    _self.longEffectStatus(this.checked);
                });
            }
        }
    },

    longEffectStatus: function (status) {
        if (status && status == true) {
            $("#idCardEndDate").shrDateTimePicker("setValue", '');
            $("#idCardEndDate").shrDateTimePicker("disable");
        } else {
            $("#idCardEndDate").shrDateTimePicker("enable");
        }
    },

    initDecimalFormatter: function () {
        var self = this;
        var socialServiceYears = self.getFieldValue("socialServiceYears");
        if (socialServiceYears) {
            var fieldName = "#" + self.getRealId("socialServiceYears");
            self.showSocialServiceYears(fieldName, self.getRoundValueBySysParam(socialServiceYears));
        }
    },
    //添加护照tips
    addPassportTips: function (field) {
        var prefix = "tips_";
        var descNode = $("#" + field + "").parents(".field-ctrl").siblings(".field-desc");
        var innerHtmlDesc = $("#" + prefix + field).html();//获取界面上配的提示信息
        var pClass = "<p>" + innerHtmlDesc + "</p>";
        descNode.html(["<div class='emp-field-tips' >",
            "<div class='emp-tips-icon'><img src='/shr/addon/orgnization/web/resource/tips_2.png'>",
            "<div class='emp-tips-content'>", pClass, "</div>",
            "</div>",
            "</div>"].join(""));
        $(".emp-tips-icon img").mouseover(function () {
            $(this).attr('src', "/shr/addon/orgnization/web/resource/tips_2_hover.png");
        });
        $(".emp-tips-icon img").mouseout(function () {
            $(this).attr('src', "/shr/addon/orgnization/web/resource/tips_2.png");
        });
    },

    // 出生日期变更事件处理
    bornDayChangeEvent: function () {
        var that = this;
        that.getField("birthday").on("change", function () {
            var bornDay = that.getFieldValue("birthday");
            that.checkConstellationAndZodiac(bornDay);
        });
    },

    checkConstellationAndZodiac: function (bornDay) {
        if (bornDay) {
            shr.callHandler({
                handler: "com.kingdee.shr.affair.web.handler.ConstellationEditHandler",
                action: "getConstellaAndZodiac",
                param: {"bornDay": bornDay},
                type: "POST",
                success: function (res) {
                    if (null != res) {
                        if (null != res.constellationId && null != res.constellation) {
                            $("#constellation").shrPromptBox('setValue', {
                                id: res.constellationId,
                                name: res.constellation
                            });
                        } else {
                            $("#constellation").shrPromptBox('setValue', null);
                        }
                        if (null != res.zodiacId && null != res.zodiac) {
                            $("#zodiac").shrPromptBox('setValue', {id: res.zodiacId, name: res.zodiac});
                        } else {
                            $("#zodiac").shrPromptBox('setValue', null);
                        }
                    } else {
                        $("#constellation").shrPromptBox('setValue', null);
                        $("#zodiac").shrPromptBox('setValue', null);
                    }
                }
            });
        }
    },

    /**
     * 一进入页面判断姓名是否分栏维护
     */
    checkFullNameIsSubFeild: function () {
        var that = this;
        shr.callHandler({
            handler: "com.kingdee.shr.affair.web.handler.hrman.EmpEnrollBizBillHrManEditHandler",
            action: "checkFullNameSubField",
            param: {},
            type: "POST",
            success: function (res) {
                if (null != res) {
                    if (res.isSubField) { // 参数设置为true则姓名分栏维护
                        if (that.getOperateState().toUpperCase() == 'EDIT') {
                            $("#name").shrMultiLangBox("disable");
                            $("#lastName").attr("validate", "{maxlength:50,required:true}");
                            $("#lastName").css("background-color", "#D9EDF7");
                            $("#firstName").attr("validate", "{maxlength:50,required:true}");
                            $("#firstName").css("background-color", "#D9EDF7");
                        }
                    } else {
                        $("#firstName").parents(".field-area").hide();
                        $("#middleName").parents(".field-area").hide();
                        $("#lastName").parents(".field-area").hide();
                    }
                }
            }
        });
    },

    /**
     * 姓名分栏变更事件
     */
    globalNameChangeEvent: function () {
        var self = this;
        if (self.getOperateState() != 'VIEW') {
            $("#lastName").shrMultiLangBox("option", {
                onchange: function (e, value) {
                    var lang = value.lang;
                    var firstName = $("#firstName").shrMultiLangBox("getValue", lang);
                    self.checkGlobalName(firstName, value.current[lang], lang);
                }
            });

            $("#firstName").shrMultiLangBox("option", {
                onchange: function (e, value) {
                    var lang = value.lang;
                    var lastName = $("#lastName").shrMultiLangBox("getValue", lang);
                    self.checkGlobalName(value.current[lang], lastName, lang);
                }
            });
        }
    },

    /**
     * 判断姓名分栏是否包含中文字符
     */
    checkGlobalName: function (firstName, lastName, lang) {
        if ((null == firstName || "" == firstName || undefined == firstName)
            || (null == lastName || "" == lastName || undefined == lastName)) {
            $("#name").shrMultiLangBox("setValue", "", lang);
            return;
        }
        var reg = new RegExp("[\\u4E00-\\u9FFF]+", "g");
        var name = '';
        if (reg.test(firstName) || reg.test(lastName)) {
            name = lastName + firstName;
        } else {
            name = firstName + " " + lastName;
        }
        $("#name").shrMultiLangBox("setValue", name, lang);
    },

});

2

package com.kingdee.shr.base.syssetting.web.handler;

import com.grapecity.documents.excel.S;
import com.kingdee.bos.BOSException;
import com.kingdee.bos.Context;
import com.kingdee.bos.dao.ormapping.ObjectUuidPK;
import com.kingdee.bos.util.BOSUuid;
import com.kingdee.eas.basedata.person.PersonFactory;
import com.kingdee.eas.basedata.person.PersonInfo;
import com.kingdee.eas.common.EASBizException;
import com.kingdee.eas.framework.CoreBaseInfo;
import com.kingdee.eas.hr.emp.PersonPositionCollection;
import com.kingdee.eas.hr.emp.PersonPositionFactory;
import com.kingdee.eas.hr.emp.PersonPositionInfo;
import com.kingdee.eas.util.app.DbUtil;
import com.kingdee.jdbc.rowset.IRowSet;
import com.kingdee.shr.base.syssetting.context.SHRContext;
import com.kingdee.shr.base.syssetting.exception.SHRWebException;
import com.kingdee.shr.base.syssetting.web.handler.VO.CarriedVo;
import com.kingdee.shr.base.syssetting.web.handler.utils.PieceTimeUtils;
import com.kingdee.shr.base.syssetting.web.handler.utils.UserUtils;
import org.springframework.ui.ModelMap;

import com.kingdee.shr.base.syssetting.web.json.JSONUtils;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.math.BigDecimal;
import java.sql.SQLException;
import java.util.*;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;

public class CustomBillEditHandlerCarriedForward extends DEPCustomBillEditHandler {

    public void getPersonNamePositionInfoAction(HttpServletRequest request,
                                                HttpServletResponse response, ModelMap modelMap) throws SHRWebException, SQLException {
        Context ctx = SHRContext.getInstance().getContext();
        String name = "";
        List<Map<String, Object>> list = new ArrayList();
        Map<String, Object> data = new HashMap();
        JSONObject jsonObject = new JSONObject();
        Enumeration parameterNames = request.getParameterNames();
        while (parameterNames.hasMoreElements()) {
            String paramNames = (String) parameterNames.nextElement();
            String[] pv = request.getParameterValues(paramNames);
            StringBuffer stringBuffer = new StringBuffer();
            for (int i = 0; i < pv.length; i++) {
                if (i > 0) {
                    stringBuffer.append(",");
                }
                stringBuffer.append(pv[i]);
            }
            jsonObject.put(paramNames, stringBuffer.toString());
        }
        System.out.println(jsonObject);
        String personId = jsonObject.get("id").toString();
        try {
            PersonInfo personInfo = PersonFactory.getLocalInstance(ctx).getPersonInfo(new ObjectUuidPK(personId));
            String number = personInfo.getNumber();
            PersonPositionCollection personPositionCollection = PersonPositionFactory.getLocalInstance(ctx).getPersonPositionCollection("where person='" + personId + "'");
            PersonPositionInfo personPositionInfo = personPositionCollection.get(0);
            BOSUuid id = personPositionInfo.getId();
            String deptName = getPersonDep(ctx, id);
            data.put("personNumber", number);
            data.put("deptName", deptName);
            list.add(data);

        } catch (EASBizException e) {
            e.printStackTrace();
        } catch (BOSException e) {
            e.printStackTrace();
        }
        if (list != null) {
            String value = JSON.toJSONString(list);
            JSONUtils.writeJson(response, value);
        }
    }

    private String getPersonDep(Context ctx, BOSUuid id) {
        String sql = "select * from T_HR_PersonPosition where FID='" + id.toString() + "'";
        String positionName = null;
        try {
            IRowSet executeQuery = DbUtil.executeQuery(ctx, sql);
            if (executeQuery.next()) {
                String primaryPositionID = executeQuery.getString("FPrimaryPositionID");
                String primaryPositionSql = "select * from T_ORG_POSITION where FID='" + primaryPositionID + "'";
                IRowSet executeQuery1 = DbUtil.executeQuery(ctx, primaryPositionSql);
                if (executeQuery1.next()) {
                    positionName = executeQuery1.getString("FNAME_L2");
                    return positionName;
                }
            }
        } catch (BOSException e) {
            e.printStackTrace();
        } catch (SQLException throwables) {
            throwables.printStackTrace();
        }
        return positionName;
    }


    public void updateTheCarryoverAction(HttpServletRequest request,
                                         HttpServletResponse response, ModelMap modelMap) throws SHRWebException, SQLException {
        Context ctx = SHRContext.getInstance().getContext();
        List<CarriedVo> list = new ArrayList();
        Map<String, Object> pagerData = new HashMap();
        JSONObject jsonObject = new JSONObject();
        Enumeration parameterNames = request.getParameterNames();
        while (parameterNames.hasMoreElements()) {
            String paramNames = (String) parameterNames.nextElement();
            String[] pv = request.getParameterValues(paramNames);
            if (pv.equals("[getsupplierInfo]")) {
                return;
            }
            StringBuffer stringBuffer = new StringBuffer();
            for (int i = 0; i < pv.length; i++) {
                if (i > 0) {
                    stringBuffer.append(",");
                }
                stringBuffer.append(pv[i]);
            }
            jsonObject.put(paramNames, stringBuffer.toString());
        }
        System.out.println(jsonObject);
        //假如现在有一条罗伟的数据
        /**
         * 代码逻辑 点击更新结转信息 找到对应员工罗伟 并且找到对应罗伟改薪酬期间的计件工资明细表
         * 得到里面的产品  通过产品编码来区分不同的产品 可转数量为入库数量加起来的和
         */
        try {
            String personName = jsonObject.get("personName").toString();
            String personId = UserUtils.getPersonId(ctx, personName);
            String duringThePiece = jsonObject.get("duringThePiece").toString();
            //得到薪酬期间里面的开始时间和结束时间
            HashMap<String, Object> pieceTime = PieceTimeUtils.getPieceTime(ctx, duringThePiece);
            String beginTime = pieceTime.get("beginTime").toString();
            String endTime = pieceTime.get("endTime").toString();
            String pieceFid = pieceTime.get("FID").toString();
            //TODO 这里应该是表头 黄立程表建错了
            //得到这个人用几条产品
            String getSql = "SELECT CFProductNumber as packet,CFProductName,CFProcessNumber,CFProcessName,CFModulus,CFPieceType,CFPieceProcessPrice,sum(CFDayStorageCount) as numberpiece " +
                    " from  CT_SDL_PieceRateDetailentry where FPersonID='" + personId + "' and CFProductDate>='" + beginTime + "' and CFProductDate<='"
                    + endTime + "' group by CFProductNumber,CFProductName,CFProcessNumber,CFProcessName,CFModulus,CFPieceType,CFPieceProcessPrice";
            IRowSet productSet = DbUtil.executeQuery(ctx, getSql);
            if (productSet.size() == 0) {
                return;
            }
            while (productSet.next()) {
                //得到里面的数据
                //产品编号
                String packet = productSet.getString("PACKET");
                //产品名称
                String productName = productSet.getString("CFProductName");
                //工序编号
                String processNumber = productSet.getString("CFProcessNumber");
                //工序名称
                String processName = productSet.getString("CFProcessName");
                //模数
                BigDecimal modulus = productSet.getBigDecimal("CFModulus");
                //计件类型
                Integer pieceType = productSet.getInt("CFPieceType");
                //可转数量
                BigDecimal numberPiece = productSet.getBigDecimal("NUMBERPIECE");
                //计件单价
                BigDecimal pieceProcessPrice = productSet.getBigDecimal("CFPieceProcessPrice");
                //结转期间
                String surplusDuringForWard = pieceFid;
                list.add(new CarriedVo(packet, productName, processNumber, processName, modulus, pieceType, numberPiece, duringThePiece, pieceProcessPrice, personId, new BigDecimal(0)));
            }

            //TODO 需要得到该员工有没有往期没有结转完的数据
            /*
             业务逻辑
             1.如果该条数据发生了结转数量发生了改变,需要在我的结转薪酬单上对应这个月的结转数量需要反写(对应员工)
             */
            String balanceSql = "select * from CT_CT_CompensationForwardEntry where CFPersonID ='" + personId + "' and  CFSuprlusDuring!='" + duringThePiece + "' and CFSurplusCarryDownCount!='" + "0" + "'";
            IRowSet balanceSet = DbUtil.executeQuery(ctx, balanceSql);
            if (balanceSet.size() > 0) {
                while (balanceSet.next()) {
                    //得到里面的数据
                    //产品编码
                    String productNumber = balanceSet.getString("CFProductNumber");
                    //产品名称
                    String productName = balanceSet.getString("CFProductName");
                    //工序编号
                    String processesNo = balanceSet.getString("CFProcessesNo");
                    //工序名称
                    String processesName = balanceSet.getString("CFProcessesName");
                    //模数
                    BigDecimal modulus = balanceSet.getBigDecimal("CFModulus");
                    //计件类型
                    Integer piectType = balanceSet.getInt("CFPiectType");
                    //剩余结转期间
                    String suprlusDuring = balanceSet.getString("CFSuprlusDuring");
                    //可转数量
                    BigDecimal convertibleCount = balanceSet.getBigDecimal("CFSurplusCarryDownCount");
                    //剩余结转数量
                    BigDecimal surplusCarryDownCount = balanceSet.getBigDecimal("CFSurplusCarryDownCount");
                    //计件工序单价
                    BigDecimal processUnitPrice = balanceSet.getBigDecimal("CFProcessunitprice");
                    list.add(new CarriedVo(productNumber, productName, processesNo, processesName, modulus, piectType, convertibleCount, suprlusDuring, processUnitPrice, personId, surplusCarryDownCount));
                }
            }

        } catch (BOSException e) {
            e.printStackTrace();
        }
        if (list != null) {
            String value = JSON.toJSONString(list);
            JSONUtils.writeJson(response, value);
        }
    }


    @Override
    protected void afterSave(HttpServletRequest request, HttpServletResponse response, CoreBaseInfo model) throws SHRWebException {
        BOSUuid id = model.getId();
        Context ctx = SHRContext.getInstance().getContext();
        BigDecimal forwardNumber = BigDecimal.ZERO;
        BigDecimal totalAmount = BigDecimal.ZERO;
        String entrySql = "select * from CT_CT_CompensationForwardEntry where FBILLID='" + id + "'";
        try {
            IRowSet entrySet = DbUtil.executeQuery(ctx, entrySql);
            if (entrySet.size() == 0) {
            	String update="update CT_CT_CompensationForward set CFJzslhj='"+BigDecimal.ZERO+"',CFPayroll='"+BigDecimal.ZERO+"' where FID='" + id + "'";
            	DbUtil.execute(ctx, update);
                return;
            } else {
                while (entrySet.next()) {
                    //这次的结转数量
                    BigDecimal carryDownCount = entrySet.getBigDecimal("CFCarryDownCount");
                    //计件单价
                    BigDecimal processUnitPrice = entrySet.getBigDecimal("CFProcessunitprice");
                    BigDecimal multiply = carryDownCount.multiply(processUnitPrice);
                    totalAmount = totalAmount.add(multiply);
                    forwardNumber = forwardNumber.add(carryDownCount);
                    String suprlusDuring = entrySet.getString("CFSuprlusDuring");
                    //产品编号
                    String productNumber = entrySet.getString("CFProductNumber");
                    String personID = entrySet.getString("CFPersonID");
                    String sql = "select * from CT_CT_CompensationForwardEntry " +
                            "where CFPersonID='" + personID + "' and CFSuprlusDuring='" + suprlusDuring + "' and CFProductNumber='" + productNumber + "'" +
                            "and FBillID!='" + id + "'";
                    IRowSet executeQuery = DbUtil.executeQuery(ctx, sql);
                    //更新往期未结转分录的数据
                    if (executeQuery.next()) {
                        String fid = executeQuery.getString("FID");
                        String billID = executeQuery.getString("FBillID");
                        //得到以前的结转数量
                        BigDecimal carryDownCounts = executeQuery.getBigDecimal("CFCarryDownCount");
                        //以前的结转数量+这次的结转数量
                        BigDecimal closing = carryDownCounts.add(carryDownCount);
                        //得到以前的剩余结转数量
                        BigDecimal surplusCarryDownCount = executeQuery.getBigDecimal("CFSurplusCarryDownCount");
                        //以前的剩余结转数量-这次结转数量
                        BigDecimal remainCount = surplusCarryDownCount.subtract(carryDownCount);
                        int r = remainCount.compareTo(BigDecimal.ZERO);
                        if (r < 0) {
                            continue;
                        }
                        //得到以前的计件工资
                        BigDecimal cfPieceRate = executeQuery.getBigDecimal("CFPieceRate");
                        //以前的计件工资+这次的计件工资
                        BigDecimal pieceWage = cfPieceRate.add(multiply);
                        String updateSql = "update CT_CT_CompensationForwardEntry" +
                                " set CFCarryDownCount='" + closing + "',CFSurplusCarryDownCount='" + remainCount + "'" +
                                ",CFPieceRate='" + pieceWage + "' where FID='" + fid + "'";
                        DbUtil.execute(ctx, updateSql);
                        String billSql = "select * from CT_CT_CompensationForward where FID='" + billID + "'";
                        IRowSet billSet = DbUtil.executeQuery(ctx, billSql);
                        if (billSet.size() == 0) {
                            return;
                        } else {
                            //更新往期为结转表头数据
                            if (billSet.next()) {
                                //得到表头的数量合计
                                String ID = billSet.getString("FID");
                                BigDecimal jzslhj = billSet.getBigDecimal("CFJzslhj");
                                BigDecimal total = jzslhj.add(carryDownCount);
                                //得到表头的工资总额
                                BigDecimal CFPayroll = billSet.getBigDecimal("CFPayroll");
                                BigDecimal totalSum = CFPayroll.add(multiply);
                                String billUpdateSql = "update CT_CT_CompensationForward Set CFJzslhj='" + total + "',CFPayroll='" + totalSum + "' where FID='" + ID + "'";
                                DbUtil.execute(ctx, billUpdateSql);
                            }
                        }
                    }
                }
                //更新表头的数据
                String updateSql = "update CT_CT_CompensationForward Set CFJzslhj='" + forwardNumber + "',CFPayroll='" + totalAmount + "' where FID='" + id + "'";
                DbUtil.execute(ctx, updateSql);
            }
        } catch (BOSException e) {
            e.printStackTrace();
        } catch (SQLException throwables) {
            throwables.printStackTrace();
        }
        System.out.println(id);
        super.afterSave(request, response, model);
    }
}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值