qingwu 2 tháng trước cách đây
mục cha
commit
f89fb3128a

+ 89 - 0
path/20251030/server/deploy/easweb.ear/shr_web.war/addon/custom/attendmanage/web/js/ats/atsLeaveBillEditEx.js

@@ -0,0 +1,89 @@
+
+
+shr.defineClass("shr.ats.AtsLeaveBillEditEx", shr.ats.AtsLeaveBillEdit, {
+    initalizeDOM: function () {
+        shr.ats.AtsLeaveBillEditEx.superClass.initalizeDOM.call(this);
+        var _self = this;
+        // 创建时隐藏当月请假情况
+        if (_self.getOperateState() != "ADDNEW") {
+            var id = $("#id").val()
+            setTimeout(() => {
+                _self.remoteCall({
+                    method: 'getLeaveSituation',
+                    param: {
+                        billId: id,
+                    },
+                    success: function (data) {
+                        if (data) {
+                            console.log(data);
+
+                            for (var i = 0, len = data.length; i < len; i++) {
+                                var info = data[i];
+                                var datarow = {
+                                    "personName": info.personName,
+                                    "personNumber": info.personNumber,
+                                    "applyDate": info.applyDate,
+                                    "realBeginTime": info.realBeginTime,
+                                    "realEndTime": info.realEndTime,
+                                    "realLeaveLength": info.realLeaveLength,
+                                    "realUnit": info.realUnit,
+                                    "reason": info.reason,
+                                    "billStatus": info.billStatus
+                                };
+                                waf("#entriesHis").jqGrid('addRow', { data: datarow });
+                            }
+                        }
+                        _self.calculateTotal();
+                    }, error: function (response) {
+                        shr.showError({
+                            message: response
+                        });
+                    }
+                }, 500); // 3000毫秒 = 3秒
+
+            });
+
+        }
+        // 编辑表格合计
+        var _self = this;
+        var entries_cont = waf("#entriesHis");
+        entries_cont.jqGrid("option", {
+            // onChange: function (rowid, cellname, value, iRow, iCol) {
+            // },
+            // beforeSaveCell: function (rowid, cellname, value, iRow, iCol) {
+
+            // },
+            // afterSaveCell: function (rowid, cellname, value, iRow, iCol) {
+
+            // },
+            // afterEditCell: function (rowid, cellname, value, iRow, iCol) {
+            //     _self.calculateTotal();
+            // },
+            // 加上这个方法才会出现合计
+            footerrow: function (rowid, cellname, value, iRow, iCol) {
+            }
+        });
+        $(".ui-jqgrid-sdiv").show();
+        // $(".footrow-ltr td:first").html('合计').parent().css("border-color", "#EEE");
+        $(".footrow-ltr").last().find("td:first").html('合计').parent().css("border-color", "#EEE");
+    },
+    /**
+     * 合计数据
+     */
+    calculateTotal() {
+        var count = 0;
+
+        var ids = $("#entriesHis").jqGrid('getDataIDs');
+        for (var i = 0; i < ids.length; i++) {
+            var rowData = $('#entriesHis').jqGrid('getRowData', ids[i]);
+            if(rowData.realUnit=="天"){
+                count = count + Number(rowData.realLeaveLength);
+            }else {
+                count = count + Number(rowData.realLeaveLength/8);
+            }
+        }
+        $("#count").val(count.toFixed(2));
+        $("#entriesHis").footerData("set", { "realLeaveLength": count.toFixed(2) }); //	合计列
+    },
+
+})

+ 617 - 0
path/20251030/server/deploy/easweb.ear/shr_web.war/addon/custom/attendmanage/web/js/ats/atsOverTimeBillBatchEditEx.js

@@ -0,0 +1,617 @@
+shr.defineClass("shr.ats.AtsOverTimeBillBatchEditEx", shr.ats.AtsOverTimeBillBatchEdit, {
+    initalizeDOM: function () {
+        shr.ats.AtsOverTimeBillBatchEditEx.superClass.initalizeDOM.call(this);
+        // 编辑表格合计
+        var _self = this;
+        var that = this;
+        $("#changeOTEntry").hide();
+        $("#deleteOTEntry").hide();
+        if (
+            shr.getUrlParam("fromCalDetail") != null &&
+            shr.getUrlParam("fromCalDetail") == "1"
+        ) {
+            $("#save").hide();
+            $("#submit").hide();
+            $("#cancelAll").hide();
+            $("#import").hide();
+            $("#orgfill").hide();
+            $(".view_manager_header > div > div").eq(0).remove();
+            $("#submitEffect").addClass("shrbtn-primary");
+            $('#workAreaDiv .ui-jqgrid-bdiv').css('max-height','253px') // 当页面作为弹框时 表格过长则隐藏滑动
+
+        }
+        var billState = $("#billState").val();
+        if ('3'===billState){
+            $("#changeOTEntry").show();
+            $("#deleteOTEntry").show();
+        }
+
+        var entries_cont = waf("#entries");
+        entries_cont.jqGrid("option", {
+            onChange: function (rowid, cellname, value, iRow, iCol) {
+                console.log(rowid, cellname, value, iRow, iCol, 123123);
+            },
+            beforeSaveCell: function (
+                rowid,
+                cellname,
+                value,
+                iRow,
+                iCol
+            ) {
+            },
+            afterSaveCell: function (rowid, cellname, value, iRow, iCol) {
+
+                if (value["adminOrgUnit.id"]) {
+                    $("#entries").jqGrid(
+                        "setCell",
+                        rowid,
+                        "adminOrgUnit.id",
+                        value["adminOrgUnit.id"]
+                    );
+                }
+
+                that.removePreShowError(rowid);
+                if (cellname == "otDate") {
+                    var val = value;
+                    if (val.length <= 10) {
+                        val = val + " 00:00:00";
+                    }
+                    val &&
+                    $("#entries").jqGrid(
+                        "setCell",
+                        rowid,
+                        "startTime",
+                        val
+                    );
+                    val &&
+                    $("#entries").jqGrid(
+                        "setCell",
+                        rowid,
+                        "endTime",
+                        val
+                    );
+                    that.changeOverTimeType(rowid);
+                    that.calRestTimeLen(rowid);
+                    that.getOTContrlParams(rowid);
+                }
+
+                if (cellname == "otType") {
+                    that.changeOTCompens(rowid);
+                }
+                // 添加 开始时间  结束时间   休息时长(分钟) 响应时间
+                if (
+                    cellname == "startTime" ||
+                    cellname == "endTime" ||
+                    cellname == "restTime"
+                ) {
+
+                    if (cellname != "restTime") {
+                        that.calRestTimeLen(rowid);
+                    }
+                    that.calculateOTtimes(rowid);
+                }
+                if (cellname == "person") {
+                    that.calRestTimeLen(rowid);
+                    that.getOTContrlParams(rowid);
+                }
+                if (cellname == "applyOTTime") {
+                    _self.calculateTotal();
+
+                    // 加班小时数  发生改变就给予提示
+                    that.changOtTimeTipInfo(rowid);
+                }
+                if (
+                    cellname == "restStartTime" ||
+                    cellname == "restStartTime2" ||
+                    cellname == "restEndTime" ||
+                    cellname == "restEndTime2"
+                ) {
+                    //计算休息时间,加班时间
+                    var startTime = $("#entries").jqGrid(
+                        "getCell",
+                        rowid,
+                        "startTime"
+                    );
+                    var endTime = $("#entries").jqGrid(
+                        "getCell",
+                        rowid,
+                        "endTime"
+                    );
+                    var restStartTime = $("#entries").jqGrid(
+                        "getCell",
+                        rowid,
+                        "restStartTime"
+                    );
+                    var restEndTime = $("#entries").jqGrid(
+                        "getCell",
+                        rowid,
+                        "restEndTime"
+                    );
+                    var restStartTime2 = $("#entries").jqGrid(
+                        "getCell",
+                        rowid,
+                        "restStartTime2"
+                    );
+                    var restEndTime2 = $("#entries").jqGrid(
+                        "getCell",
+                        rowid,
+                        "restEndTime2"
+                    );
+                    if (startTime == "" || endTime == "") {
+                        return;
+                    }
+
+                    var totalRestTime = 0;
+                    var totalRestTimeLong = 0;
+                    var restStartTimeOfDate;
+                    var restEndTimeOfDate;
+                    if (shr.getBowserInfo().browser === 'IE' || shr.getBowserInfo().browser === 'Safari') {
+                        restStartTime = restStartTime.replace(/-/g, '/');
+                        restEndTime = restEndTime.replace(/-/g, '/');
+                        restStartTime2 = restStartTime2.replace(/-/g, '/');
+                        restEndTime2 = restEndTime2.replace(/-/g, '/');
+                    }
+                    if (restStartTime != "" && restEndTime != "") {
+                        restStartTimeOfDate = new Date(restStartTime);
+                        restEndTimeOfDate = new Date(restEndTime);
+                        var times =
+                            restEndTimeOfDate.getTime() -
+                            restStartTimeOfDate.getTime();
+                        if (times < 0) {
+                            times = 0;
+                        }
+                        totalRestTimeLong += times;
+                        times = times / 1000 / 60;
+                        totalRestTime += times;
+                    }
+                    if (restStartTime2 != "" && restEndTime2 != "") {
+                        var restStartTime2OfDate = new Date(restStartTime2);
+                        var restEndTime2OfDate = new Date(restEndTime2);
+                        if (
+                            (restStartTime != "" &&
+                                restEndTime2OfDate.getTime() >
+                                restStartTimeOfDate.getTime() &&
+                                restStartTimeOfDate.getTime() >=
+                                restStartTime2OfDate.getTime()) ||
+                            (restEndTime != "" &&
+                                restEndTimeOfDate.getTime() <=
+                                restEndTime2OfDate.getTime() &&
+                                restStartTime2OfDate.getTime() <
+                                restEndTimeOfDate.getTime()) ||
+                            (restStartTime != "" &&
+                                restEndTime != "" &&
+                                restEndTimeOfDate.getTime() >=
+                                restEndTime2OfDate.getTime() &&
+                                restStartTime2OfDate.getTime() >=
+                                restStartTimeOfDate.getTime())
+                        ) {
+                            //时间有交叉
+                            $("#entries").jqGrid(
+                                "setCell",
+                                rowid,
+                                "restEndTime2",
+                                restStartTime2
+                            );
+                        } else {
+                            var times =
+                                restEndTime2OfDate.getTime() -
+                                restStartTime2OfDate.getTime();
+                            if (times < 0) {
+                                times = 0;
+                            }
+                            totalRestTimeLong += times;
+                            times = times / 1000 / 60;
+                            totalRestTime += times;
+                        }
+                    }
+                    var t1 = totalRestTime.toFixed(
+                        atsMlUtile.getSysDecimalPlace()
+                    );
+                    $("#entries").jqGrid("setCell", rowid, "restTime", t1);
+                    var startTime = NewDate(startTime + ":00");
+                    var endTime = NewDate(endTime + ":00");
+                    var se =
+                        endTime.getTime() -
+                        startTime.getTime() -
+                        totalRestTimeLong; // 毫秒
+                    var tfl = se / (3600 * 1000);
+                    $("#entries").jqGrid(
+                        "setCell",
+                        rowid,
+                        "applyOTTime",
+                        tfl
+                    );
+                    that.getOTContrlParams(rowid);
+                }
+            },
+            afterEditCell: function (rowid, cellname, value, iRow, iCol) {
+                _self.calculateTotal();
+                if (
+                    cellname == "otType" &&
+                    that.OTContrlParams[rowid] &&
+                    that.OTContrlParams[rowid].isOtrolByDateType
+                ) {
+                    $("#" + iRow + "_otType").shrPromptBox("disable");
+                }
+                if (cellname == "otCompens") {
+                    if (that.filter[rowid] == undefined) {
+                        // R20221006-0542 修复选择加班费后 再点击“补偿方式”F7就变成了调休的问题
+                        // that.changeOTCompens(rowid);
+                    }
+                    if (that.filter[rowid]) {
+                        //						$("#"+rowid+"_otCompens").shrPromptBox("setFilter",that.filter[rowid]);
+                        $(
+                            "#" +
+                            $("#entries").jqGrid(
+                                "getCell",
+                                rowid,
+                                "rn"
+                            ) +
+                            "_otCompens"
+                        ).shrPromptBox("setFilter", that.filter[rowid]);
+                    }
+                }
+                if (cellname == "person") {
+                    var hrOrgUnitId = $("#hrOrgUnit_el").val();
+                    $("#" + rowid + "_person")
+                        .shrPromptBox()
+                        .attr("data-params", hrOrgUnitId);
+                    $("#" + iRow + "_person").shrPromptBox("option", {
+                        onchange: function (e, value) {
+                            $("#entries").jqGrid(
+                                "setCell",
+                                rowid,
+                                "person.number",
+                                value.current
+                                    ? value.current["person.number"]
+                                    : ""
+                            );
+                        }
+                    });
+
+                }
+                if (cellname == "attAdminOrgUnit") {
+                    var personId = $("#entries").jqGrid("getCell", rowid, "person").id;
+                    var attendanceDate = $("#entries").jqGrid("getCell", rowid, "otDate");
+
+                    if (!(personId && attendanceDate)) {
+                        shr.showInfo({message: jsBizMultLan.atsManager_atsOverTimeBillEdit_YM_999});
+                        return false;
+                    } else {
+                        //$("#"+rowid+"_attPosition").shrPromptBox().attr("data-params", adminOrg);
+                        $("#" + iRow + "_attAdminOrgUnit").shrPromptBox("setOtherParams", {
+                            personId: personId,
+                            attendanceDate: attendanceDate
+                        });
+                    }
+                }
+            }
+            , footerrow: function (rowid, cellname, value, iRow, iCol) {
+            }
+        });
+        $(".ui-jqgrid-sdiv").show();
+        // $(".footrow-ltr td:first").html('合计').parent().css("border-color", "#EEE");
+        $(".footrow-ltr").last().find("td:first").html('合计').parent().css("border-color", "#EEE");
+        _self.calculateTotal();
+
+    },
+
+    calculateTotal() {
+        var count = 0;
+        var ids = $("#entries").jqGrid('getDataIDs');
+        for (var i = 0; i < ids.length; i++) {
+            var rowData = $('#entries').jqGrid('getRowData', ids[i]);
+            count = count + Number(rowData.applyOTTime);
+        }
+        $("#count").val(count.toFixed(2));
+        $("#entries").footerData("set", {"applyOTTime": count.toFixed(2)}); //
+    }, //去除个性化展示,每次校验前去除
+    removePreShowError: function (rowid) {
+        var rnColNum = this.getColNumIndex();
+        var rows = $("#entries").getGridParam("reccount");
+        var td = $("#entries").find("tr[id='" + rowid + "'] td:eq(" + rnColNum + ")");
+        td.attr(
+            "title",
+            ""
+        );
+        td.html(
+            $("#entries").find("tr[id='" + rowid + "']")[0].rowIndex
+        );
+        td.css(
+            "color",
+            "rgb(153, 153, 153)"
+        );
+        $("#entries").find("tr[id='" + rowid + "']").css(
+            "color",
+            "rgb(153, 153, 153)"
+        ); //如果设置成css("color","initial")会变成黑色,而原界面为灰色
+    },
+    changeOverTimeType: function (rowid) {
+        var that = this;
+        var otDate;
+        var personId;
+        if (!$("#entries").jqGrid("getCell", rowid, "otDate")) {
+            return;
+        } else {
+            otDate = $("#entries").jqGrid("getCell", rowid, "otDate");
+        }
+
+        if (!$("#entries").jqGrid("getCell", rowid, "person")) {
+            return;
+        } else {
+            personId = $("#entries").jqGrid("getCell", rowid, "person").id;
+        }
+        that.getOverTimeType(rowid, otDate, personId);
+    },
+    getOverTimeType: function (rowid, otDate, personId) {
+        var _self = this;
+        var tDate = otDate;
+        var url =
+            shr.getContextPath() +
+            "/dynamic.do?method=getOverTimeTypeAndOtCompens";
+        url +=
+            "&otDate=" +
+            encodeURIComponent(otDate) +
+            "&personId=" +
+            encodeURIComponent(personId) + "&uipk=" + shr.getUrlRequestParam('uipk');
+        $.ajax({
+            url: url,
+            async: false,
+            success: function (response) {
+                if (
+                    response.otTypeValue != null &&
+                    response.otTypeValue != undefined &&
+                    response.otTypeValue != ""
+                ) {
+                    var responseObejct = {
+                        id: response.otTypeValue,
+                        name: response.otTypeText
+                    };
+                    if (_self.isOtTypeEffective(response.otTypeValue)) {
+                        // $('#entries').restoreCell(rowid,4); // 先恢复单元格状态再重新赋值,可以避免
+                        $("#entries").jqGrid(
+                            "setCell",
+                            rowid,
+                            "otType",
+                            responseObejct
+                        );
+                        //设置该加班类型的补偿方式过滤
+                        var otCompensIds = _self.getOTCompensByOTType(
+                            personId,
+                            response.otTypeValue,
+                            tDate
+                        );
+                        if (otCompensIds) {
+                            var otCompensIdsStr = _self
+                                .getOTCompensByOTType(
+                                    personId,
+                                    response.otTypeValue,
+                                    tDate
+                                )
+                                .replace(/(,)/g, "','");
+                            _self.filter[rowid] =
+                                "BaseInfo.id in ('" +
+                                otCompensIdsStr +
+                                "')";
+                        }
+
+                        var compens = response.compensInfo;
+                        if (compens != null) {
+                            var defaultJson = {
+                                id: compens.id,
+                                name: compens.name
+                            };
+                            $("#entries").jqGrid(
+                                "setCell",
+                                rowid,
+                                "otCompens",
+                                defaultJson
+                            );
+                        }
+                    } else {
+                        $("#entries").jqGrid(
+                            "setCell",
+                            rowid,
+                            "otType",
+                            null
+                        );
+                    }
+                }
+            },
+            error: function (response) {
+            }
+        });
+    },
+    getOTContrlParams: function (rowid) {
+        var personId;
+        if (!$("#entries").jqGrid("getCell", rowid, "person")) {
+            return;
+        } else {
+            personId = $("#entries").jqGrid("getCell", rowid, "person").id;
+        }
+        var otDate;
+        if (!$("#entries").jqGrid("getCell", rowid, "otDate")) {
+            return;
+        } else {
+            otDate = $("#entries").jqGrid("getCell", rowid, "otDate");
+        }
+        var that = this;
+
+        var url =
+            shr.getContextPath() +
+            "/dynamic.do?handler=com.kingdee.shr.ats.bill.util.BillBizUtil&method=getOTContrlParam";
+        shr.ajax({
+            type: "post",
+            async: false,
+            url: url,
+            data: {personId: personId, otDate: otDate},
+            success: function (res) {
+                if (res) {
+                    that.OTContrlParams[rowid] = res;
+                    //					isOTControl=res.isOTControl;
+                    //					isOtrolByDateType=res.isOtrolByDateType;
+                }
+            }
+        });
+    },
+
+    /**
+     * 选择条件
+     */
+    changeOTEntryAction: function () {
+        var _self = this;
+        var wafentries = waf("#entries");
+        var billID = this.billId;
+        var entryId = wafentries.jqGrid("getSelectedRows").toString();
+        if (entryId) {
+
+            var person = wafentries.jqGrid("getCell", entryId, 'person');
+            var personName = (person.name ? person.name : person.name_l2);
+            var startTime = wafentries.jqGrid("getCell", entryId, 'startTime');
+            var endTime = wafentries.jqGrid("getCell", entryId, 'endTime');
+
+            shr.showConfirm("是否變更&lt;" + personName + "&gt;,&lt;" + startTime + "&gt;至&lt;" + endTime + "&gt;加班單?", function () {
+                _self.remoteCall({
+                    type: "post",
+                    method: "changeOTEntry",
+                    param: {
+                        billID: billID,
+                        entryId: entryId
+                    },
+                    async: true,
+                    success: function (res) {
+                        if (res && 'err' === res.code) {
+                            shr.showWarning({
+                                message: res.msg,
+                                hideAfter: 6
+                            });
+                        } else {
+
+                            var serviceId = shr.getUrlRequestParam("serviceId");
+                            var url = shr.getContextPath() +
+                                "/dynamic.do?&uipk=com.kingdee.eas.hr.ats.app.AtsOverTimeBillAllForm.change";
+                            url += "&serviceId=" + encodeURIComponent(serviceId);
+                            url += "&oldBillID=" + billID + "&oldEntryId=" + entryId;
+                            url += "&billId=" + res.billID+ "&entryId=" + res.entryId;
+                            url += "&method=edit&debug=true";
+                            $("#changeFillDiv").attr("src", url);
+
+                            $("#changeFillDiv").dialog({
+                                title: '變更' + personName + '加班單',
+                                width: 1020,
+                                height: 450,
+                                modal: true,
+                                resizable: false,
+                                position: {
+                                    my: "center",
+                                    at: "top+20%",
+                                    of: window
+                                },
+                                open: function (event, ui) {
+                                },
+                                close: function(event, ui) {
+                                    $("#changeFillDiv").empty();
+                                    _self.unChangeOTEntry(_self,res.billID,res.entryId);
+
+                                    window.document.location.reload();
+                                },
+                                buttons: [
+                                    {
+                                        text:
+                                            "提交",
+                                        click: function () {
+                                            $(window.frames["changeFillDiv"].document).find("#save").click();
+                                        }
+                                    },
+                                    {
+                                        text:
+                                            "取消",
+                                        click: function () {
+                                            $($(window.parent.document).find(".ui-button.ui-corner-all.ui-widget.ui-button-icon-only.ui-dialog-titlebar-close")).click()
+                                        }
+                                    }
+                                ]
+                            });
+
+                            $("#changeFillDiv").attr("style", "width:1020px;height:550px;");
+                        }
+                    }
+                });
+            });
+        }else{
+            shr.showWarning({
+                message: "請選擇要變更的行",
+                hideAfter: 3
+            });
+        }
+    },
+
+    unChangeOTEntry: function (_self,billID,entryId){
+        _self.remoteCall({
+            type: "post",
+            method: "unChangeOTEntry",
+            param: {
+                billID: billID,
+                entryId: entryId
+            },
+            async: true,
+            success: function (res) {
+                if (res) {
+                    // shr.showWarning({
+                    //     message: res.msg,
+                    //     hideAfter: 6
+                    // });
+
+                }
+            }
+        });
+    },
+    /**
+     * 选择条件
+     */
+    deleteOTEntryAction: function () {
+        var _self = this;
+        var wafentries = waf("#entries");
+        var entryId = wafentries.jqGrid("getSelectedRows").toString();
+        if (entryId) {
+
+            var person = wafentries.jqGrid("getCell", entryId, 'person');
+            var personName = (person.name ? person.name : person.name_l2);
+            var startTime = wafentries.jqGrid("getCell", entryId, 'startTime');
+            var endTime = wafentries.jqGrid("getCell", entryId, 'endTime');
+            shr.showConfirm("是否取消&lt;" + personName + "&gt;,&lt;" + startTime + "&gt;至&lt;" + endTime + "&gt;加班單?", function () {
+
+                _self.remoteCall({
+                    type: "post",
+                    method: "deleteOTEntry",
+                    param: {
+                        billID: this.billId,
+                        entryId: entryId
+                    },
+                    async: true,
+                    success: function (res) {
+                        if (res && 'err' === res.code) {
+                            shr.showWarning({
+                                message: res.msg,
+                                hideAfter: 6
+                            });
+                        }else {
+                            shr.showWarning({
+                                message: "刪除成功",
+                                hideAfter: 6
+                            });
+                            wafentries.jqGrid("delRowData",entryId)
+                        }
+                    }
+                });
+            });
+        }else {
+            shr.showWarning({
+                message: "請選擇要刪除的行",
+                hideAfter: 3
+            });
+        }
+    },
+
+})
+