| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617 |
- 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("是否變更<" + personName + ">,<" + startTime + ">至<" + endTime + ">加班單?", 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("是否取消<" + personName + ">,<" + startTime + ">至<" + endTime + ">加班單?", 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
- });
- }
- },
- })
|