atsOverTimeBillBatchEditEx.js 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617
  1. shr.defineClass("shr.ats.AtsOverTimeBillBatchEditEx", shr.ats.AtsOverTimeBillBatchEdit, {
  2. initalizeDOM: function () {
  3. shr.ats.AtsOverTimeBillBatchEditEx.superClass.initalizeDOM.call(this);
  4. // 编辑表格合计
  5. var _self = this;
  6. var that = this;
  7. $("#changeOTEntry").hide();
  8. $("#deleteOTEntry").hide();
  9. if (
  10. shr.getUrlParam("fromCalDetail") != null &&
  11. shr.getUrlParam("fromCalDetail") == "1"
  12. ) {
  13. $("#save").hide();
  14. $("#submit").hide();
  15. $("#cancelAll").hide();
  16. $("#import").hide();
  17. $("#orgfill").hide();
  18. $(".view_manager_header > div > div").eq(0).remove();
  19. $("#submitEffect").addClass("shrbtn-primary");
  20. $('#workAreaDiv .ui-jqgrid-bdiv').css('max-height','253px') // 当页面作为弹框时 表格过长则隐藏滑动
  21. }
  22. var billState = $("#billState").val();
  23. if ('3'===billState){
  24. $("#changeOTEntry").show();
  25. $("#deleteOTEntry").show();
  26. }
  27. var entries_cont = waf("#entries");
  28. entries_cont.jqGrid("option", {
  29. onChange: function (rowid, cellname, value, iRow, iCol) {
  30. console.log(rowid, cellname, value, iRow, iCol, 123123);
  31. },
  32. beforeSaveCell: function (
  33. rowid,
  34. cellname,
  35. value,
  36. iRow,
  37. iCol
  38. ) {
  39. },
  40. afterSaveCell: function (rowid, cellname, value, iRow, iCol) {
  41. if (value["adminOrgUnit.id"]) {
  42. $("#entries").jqGrid(
  43. "setCell",
  44. rowid,
  45. "adminOrgUnit.id",
  46. value["adminOrgUnit.id"]
  47. );
  48. }
  49. that.removePreShowError(rowid);
  50. if (cellname == "otDate") {
  51. var val = value;
  52. if (val.length <= 10) {
  53. val = val + " 00:00:00";
  54. }
  55. val &&
  56. $("#entries").jqGrid(
  57. "setCell",
  58. rowid,
  59. "startTime",
  60. val
  61. );
  62. val &&
  63. $("#entries").jqGrid(
  64. "setCell",
  65. rowid,
  66. "endTime",
  67. val
  68. );
  69. that.changeOverTimeType(rowid);
  70. that.calRestTimeLen(rowid);
  71. that.getOTContrlParams(rowid);
  72. }
  73. if (cellname == "otType") {
  74. that.changeOTCompens(rowid);
  75. }
  76. // 添加 开始时间 结束时间 休息时长(分钟) 响应时间
  77. if (
  78. cellname == "startTime" ||
  79. cellname == "endTime" ||
  80. cellname == "restTime"
  81. ) {
  82. if (cellname != "restTime") {
  83. that.calRestTimeLen(rowid);
  84. }
  85. that.calculateOTtimes(rowid);
  86. }
  87. if (cellname == "person") {
  88. that.calRestTimeLen(rowid);
  89. that.getOTContrlParams(rowid);
  90. }
  91. if (cellname == "applyOTTime") {
  92. _self.calculateTotal();
  93. // 加班小时数 发生改变就给予提示
  94. that.changOtTimeTipInfo(rowid);
  95. }
  96. if (
  97. cellname == "restStartTime" ||
  98. cellname == "restStartTime2" ||
  99. cellname == "restEndTime" ||
  100. cellname == "restEndTime2"
  101. ) {
  102. //计算休息时间,加班时间
  103. var startTime = $("#entries").jqGrid(
  104. "getCell",
  105. rowid,
  106. "startTime"
  107. );
  108. var endTime = $("#entries").jqGrid(
  109. "getCell",
  110. rowid,
  111. "endTime"
  112. );
  113. var restStartTime = $("#entries").jqGrid(
  114. "getCell",
  115. rowid,
  116. "restStartTime"
  117. );
  118. var restEndTime = $("#entries").jqGrid(
  119. "getCell",
  120. rowid,
  121. "restEndTime"
  122. );
  123. var restStartTime2 = $("#entries").jqGrid(
  124. "getCell",
  125. rowid,
  126. "restStartTime2"
  127. );
  128. var restEndTime2 = $("#entries").jqGrid(
  129. "getCell",
  130. rowid,
  131. "restEndTime2"
  132. );
  133. if (startTime == "" || endTime == "") {
  134. return;
  135. }
  136. var totalRestTime = 0;
  137. var totalRestTimeLong = 0;
  138. var restStartTimeOfDate;
  139. var restEndTimeOfDate;
  140. if (shr.getBowserInfo().browser === 'IE' || shr.getBowserInfo().browser === 'Safari') {
  141. restStartTime = restStartTime.replace(/-/g, '/');
  142. restEndTime = restEndTime.replace(/-/g, '/');
  143. restStartTime2 = restStartTime2.replace(/-/g, '/');
  144. restEndTime2 = restEndTime2.replace(/-/g, '/');
  145. }
  146. if (restStartTime != "" && restEndTime != "") {
  147. restStartTimeOfDate = new Date(restStartTime);
  148. restEndTimeOfDate = new Date(restEndTime);
  149. var times =
  150. restEndTimeOfDate.getTime() -
  151. restStartTimeOfDate.getTime();
  152. if (times < 0) {
  153. times = 0;
  154. }
  155. totalRestTimeLong += times;
  156. times = times / 1000 / 60;
  157. totalRestTime += times;
  158. }
  159. if (restStartTime2 != "" && restEndTime2 != "") {
  160. var restStartTime2OfDate = new Date(restStartTime2);
  161. var restEndTime2OfDate = new Date(restEndTime2);
  162. if (
  163. (restStartTime != "" &&
  164. restEndTime2OfDate.getTime() >
  165. restStartTimeOfDate.getTime() &&
  166. restStartTimeOfDate.getTime() >=
  167. restStartTime2OfDate.getTime()) ||
  168. (restEndTime != "" &&
  169. restEndTimeOfDate.getTime() <=
  170. restEndTime2OfDate.getTime() &&
  171. restStartTime2OfDate.getTime() <
  172. restEndTimeOfDate.getTime()) ||
  173. (restStartTime != "" &&
  174. restEndTime != "" &&
  175. restEndTimeOfDate.getTime() >=
  176. restEndTime2OfDate.getTime() &&
  177. restStartTime2OfDate.getTime() >=
  178. restStartTimeOfDate.getTime())
  179. ) {
  180. //时间有交叉
  181. $("#entries").jqGrid(
  182. "setCell",
  183. rowid,
  184. "restEndTime2",
  185. restStartTime2
  186. );
  187. } else {
  188. var times =
  189. restEndTime2OfDate.getTime() -
  190. restStartTime2OfDate.getTime();
  191. if (times < 0) {
  192. times = 0;
  193. }
  194. totalRestTimeLong += times;
  195. times = times / 1000 / 60;
  196. totalRestTime += times;
  197. }
  198. }
  199. var t1 = totalRestTime.toFixed(
  200. atsMlUtile.getSysDecimalPlace()
  201. );
  202. $("#entries").jqGrid("setCell", rowid, "restTime", t1);
  203. var startTime = NewDate(startTime + ":00");
  204. var endTime = NewDate(endTime + ":00");
  205. var se =
  206. endTime.getTime() -
  207. startTime.getTime() -
  208. totalRestTimeLong; // 毫秒
  209. var tfl = se / (3600 * 1000);
  210. $("#entries").jqGrid(
  211. "setCell",
  212. rowid,
  213. "applyOTTime",
  214. tfl
  215. );
  216. that.getOTContrlParams(rowid);
  217. }
  218. },
  219. afterEditCell: function (rowid, cellname, value, iRow, iCol) {
  220. _self.calculateTotal();
  221. if (
  222. cellname == "otType" &&
  223. that.OTContrlParams[rowid] &&
  224. that.OTContrlParams[rowid].isOtrolByDateType
  225. ) {
  226. $("#" + iRow + "_otType").shrPromptBox("disable");
  227. }
  228. if (cellname == "otCompens") {
  229. if (that.filter[rowid] == undefined) {
  230. // R20221006-0542 修复选择加班费后 再点击“补偿方式”F7就变成了调休的问题
  231. // that.changeOTCompens(rowid);
  232. }
  233. if (that.filter[rowid]) {
  234. // $("#"+rowid+"_otCompens").shrPromptBox("setFilter",that.filter[rowid]);
  235. $(
  236. "#" +
  237. $("#entries").jqGrid(
  238. "getCell",
  239. rowid,
  240. "rn"
  241. ) +
  242. "_otCompens"
  243. ).shrPromptBox("setFilter", that.filter[rowid]);
  244. }
  245. }
  246. if (cellname == "person") {
  247. var hrOrgUnitId = $("#hrOrgUnit_el").val();
  248. $("#" + rowid + "_person")
  249. .shrPromptBox()
  250. .attr("data-params", hrOrgUnitId);
  251. $("#" + iRow + "_person").shrPromptBox("option", {
  252. onchange: function (e, value) {
  253. $("#entries").jqGrid(
  254. "setCell",
  255. rowid,
  256. "person.number",
  257. value.current
  258. ? value.current["person.number"]
  259. : ""
  260. );
  261. }
  262. });
  263. }
  264. if (cellname == "attAdminOrgUnit") {
  265. var personId = $("#entries").jqGrid("getCell", rowid, "person").id;
  266. var attendanceDate = $("#entries").jqGrid("getCell", rowid, "otDate");
  267. if (!(personId && attendanceDate)) {
  268. shr.showInfo({message: jsBizMultLan.atsManager_atsOverTimeBillEdit_YM_999});
  269. return false;
  270. } else {
  271. //$("#"+rowid+"_attPosition").shrPromptBox().attr("data-params", adminOrg);
  272. $("#" + iRow + "_attAdminOrgUnit").shrPromptBox("setOtherParams", {
  273. personId: personId,
  274. attendanceDate: attendanceDate
  275. });
  276. }
  277. }
  278. }
  279. , footerrow: function (rowid, cellname, value, iRow, iCol) {
  280. }
  281. });
  282. $(".ui-jqgrid-sdiv").show();
  283. // $(".footrow-ltr td:first").html('合计').parent().css("border-color", "#EEE");
  284. $(".footrow-ltr").last().find("td:first").html('合计').parent().css("border-color", "#EEE");
  285. _self.calculateTotal();
  286. },
  287. calculateTotal() {
  288. var count = 0;
  289. var ids = $("#entries").jqGrid('getDataIDs');
  290. for (var i = 0; i < ids.length; i++) {
  291. var rowData = $('#entries').jqGrid('getRowData', ids[i]);
  292. count = count + Number(rowData.applyOTTime);
  293. }
  294. $("#count").val(count.toFixed(2));
  295. $("#entries").footerData("set", {"applyOTTime": count.toFixed(2)}); //
  296. }, //去除个性化展示,每次校验前去除
  297. removePreShowError: function (rowid) {
  298. var rnColNum = this.getColNumIndex();
  299. var rows = $("#entries").getGridParam("reccount");
  300. var td = $("#entries").find("tr[id='" + rowid + "'] td:eq(" + rnColNum + ")");
  301. td.attr(
  302. "title",
  303. ""
  304. );
  305. td.html(
  306. $("#entries").find("tr[id='" + rowid + "']")[0].rowIndex
  307. );
  308. td.css(
  309. "color",
  310. "rgb(153, 153, 153)"
  311. );
  312. $("#entries").find("tr[id='" + rowid + "']").css(
  313. "color",
  314. "rgb(153, 153, 153)"
  315. ); //如果设置成css("color","initial")会变成黑色,而原界面为灰色
  316. },
  317. changeOverTimeType: function (rowid) {
  318. var that = this;
  319. var otDate;
  320. var personId;
  321. if (!$("#entries").jqGrid("getCell", rowid, "otDate")) {
  322. return;
  323. } else {
  324. otDate = $("#entries").jqGrid("getCell", rowid, "otDate");
  325. }
  326. if (!$("#entries").jqGrid("getCell", rowid, "person")) {
  327. return;
  328. } else {
  329. personId = $("#entries").jqGrid("getCell", rowid, "person").id;
  330. }
  331. that.getOverTimeType(rowid, otDate, personId);
  332. },
  333. getOverTimeType: function (rowid, otDate, personId) {
  334. var _self = this;
  335. var tDate = otDate;
  336. var url =
  337. shr.getContextPath() +
  338. "/dynamic.do?method=getOverTimeTypeAndOtCompens";
  339. url +=
  340. "&otDate=" +
  341. encodeURIComponent(otDate) +
  342. "&personId=" +
  343. encodeURIComponent(personId) + "&uipk=" + shr.getUrlRequestParam('uipk');
  344. $.ajax({
  345. url: url,
  346. async: false,
  347. success: function (response) {
  348. if (
  349. response.otTypeValue != null &&
  350. response.otTypeValue != undefined &&
  351. response.otTypeValue != ""
  352. ) {
  353. var responseObejct = {
  354. id: response.otTypeValue,
  355. name: response.otTypeText
  356. };
  357. if (_self.isOtTypeEffective(response.otTypeValue)) {
  358. // $('#entries').restoreCell(rowid,4); // 先恢复单元格状态再重新赋值,可以避免
  359. $("#entries").jqGrid(
  360. "setCell",
  361. rowid,
  362. "otType",
  363. responseObejct
  364. );
  365. //设置该加班类型的补偿方式过滤
  366. var otCompensIds = _self.getOTCompensByOTType(
  367. personId,
  368. response.otTypeValue,
  369. tDate
  370. );
  371. if (otCompensIds) {
  372. var otCompensIdsStr = _self
  373. .getOTCompensByOTType(
  374. personId,
  375. response.otTypeValue,
  376. tDate
  377. )
  378. .replace(/(,)/g, "','");
  379. _self.filter[rowid] =
  380. "BaseInfo.id in ('" +
  381. otCompensIdsStr +
  382. "')";
  383. }
  384. var compens = response.compensInfo;
  385. if (compens != null) {
  386. var defaultJson = {
  387. id: compens.id,
  388. name: compens.name
  389. };
  390. $("#entries").jqGrid(
  391. "setCell",
  392. rowid,
  393. "otCompens",
  394. defaultJson
  395. );
  396. }
  397. } else {
  398. $("#entries").jqGrid(
  399. "setCell",
  400. rowid,
  401. "otType",
  402. null
  403. );
  404. }
  405. }
  406. },
  407. error: function (response) {
  408. }
  409. });
  410. },
  411. getOTContrlParams: function (rowid) {
  412. var personId;
  413. if (!$("#entries").jqGrid("getCell", rowid, "person")) {
  414. return;
  415. } else {
  416. personId = $("#entries").jqGrid("getCell", rowid, "person").id;
  417. }
  418. var otDate;
  419. if (!$("#entries").jqGrid("getCell", rowid, "otDate")) {
  420. return;
  421. } else {
  422. otDate = $("#entries").jqGrid("getCell", rowid, "otDate");
  423. }
  424. var that = this;
  425. var url =
  426. shr.getContextPath() +
  427. "/dynamic.do?handler=com.kingdee.shr.ats.bill.util.BillBizUtil&method=getOTContrlParam";
  428. shr.ajax({
  429. type: "post",
  430. async: false,
  431. url: url,
  432. data: {personId: personId, otDate: otDate},
  433. success: function (res) {
  434. if (res) {
  435. that.OTContrlParams[rowid] = res;
  436. // isOTControl=res.isOTControl;
  437. // isOtrolByDateType=res.isOtrolByDateType;
  438. }
  439. }
  440. });
  441. },
  442. /**
  443. * 选择条件
  444. */
  445. changeOTEntryAction: function () {
  446. var _self = this;
  447. var wafentries = waf("#entries");
  448. var billID = this.billId;
  449. var entryId = wafentries.jqGrid("getSelectedRows").toString();
  450. if (entryId) {
  451. var person = wafentries.jqGrid("getCell", entryId, 'person');
  452. var personName = (person.name ? person.name : person.name_l2);
  453. var startTime = wafentries.jqGrid("getCell", entryId, 'startTime');
  454. var endTime = wafentries.jqGrid("getCell", entryId, 'endTime');
  455. shr.showConfirm("是否變更&lt;" + personName + "&gt;,&lt;" + startTime + "&gt;至&lt;" + endTime + "&gt;加班單?", function () {
  456. _self.remoteCall({
  457. type: "post",
  458. method: "changeOTEntry",
  459. param: {
  460. billID: billID,
  461. entryId: entryId
  462. },
  463. async: true,
  464. success: function (res) {
  465. if (res && 'err' === res.code) {
  466. shr.showWarning({
  467. message: res.msg,
  468. hideAfter: 6
  469. });
  470. } else {
  471. var serviceId = shr.getUrlRequestParam("serviceId");
  472. var url = shr.getContextPath() +
  473. "/dynamic.do?&uipk=com.kingdee.eas.hr.ats.app.AtsOverTimeBillAllForm.change";
  474. url += "&serviceId=" + encodeURIComponent(serviceId);
  475. url += "&oldBillID=" + billID + "&oldEntryId=" + entryId;
  476. url += "&billId=" + res.billID+ "&entryId=" + res.entryId;
  477. url += "&method=edit&debug=true";
  478. $("#changeFillDiv").attr("src", url);
  479. $("#changeFillDiv").dialog({
  480. title: '變更' + personName + '加班單',
  481. width: 1020,
  482. height: 450,
  483. modal: true,
  484. resizable: false,
  485. position: {
  486. my: "center",
  487. at: "top+20%",
  488. of: window
  489. },
  490. open: function (event, ui) {
  491. },
  492. close: function(event, ui) {
  493. $("#changeFillDiv").empty();
  494. _self.unChangeOTEntry(_self,res.billID,res.entryId);
  495. window.document.location.reload();
  496. },
  497. buttons: [
  498. {
  499. text:
  500. "提交",
  501. click: function () {
  502. $(window.frames["changeFillDiv"].document).find("#save").click();
  503. }
  504. },
  505. {
  506. text:
  507. "取消",
  508. click: function () {
  509. $($(window.parent.document).find(".ui-button.ui-corner-all.ui-widget.ui-button-icon-only.ui-dialog-titlebar-close")).click()
  510. }
  511. }
  512. ]
  513. });
  514. $("#changeFillDiv").attr("style", "width:1020px;height:550px;");
  515. }
  516. }
  517. });
  518. });
  519. }else{
  520. shr.showWarning({
  521. message: "請選擇要變更的行",
  522. hideAfter: 3
  523. });
  524. }
  525. },
  526. unChangeOTEntry: function (_self,billID,entryId){
  527. _self.remoteCall({
  528. type: "post",
  529. method: "unChangeOTEntry",
  530. param: {
  531. billID: billID,
  532. entryId: entryId
  533. },
  534. async: true,
  535. success: function (res) {
  536. if (res) {
  537. // shr.showWarning({
  538. // message: res.msg,
  539. // hideAfter: 6
  540. // });
  541. }
  542. }
  543. });
  544. },
  545. /**
  546. * 选择条件
  547. */
  548. deleteOTEntryAction: function () {
  549. var _self = this;
  550. var wafentries = waf("#entries");
  551. var entryId = wafentries.jqGrid("getSelectedRows").toString();
  552. if (entryId) {
  553. var person = wafentries.jqGrid("getCell", entryId, 'person');
  554. var personName = (person.name ? person.name : person.name_l2);
  555. var startTime = wafentries.jqGrid("getCell", entryId, 'startTime');
  556. var endTime = wafentries.jqGrid("getCell", entryId, 'endTime');
  557. shr.showConfirm("是否取消&lt;" + personName + "&gt;,&lt;" + startTime + "&gt;至&lt;" + endTime + "&gt;加班單?", function () {
  558. _self.remoteCall({
  559. type: "post",
  560. method: "deleteOTEntry",
  561. param: {
  562. billID: this.billId,
  563. entryId: entryId
  564. },
  565. async: true,
  566. success: function (res) {
  567. if (res && 'err' === res.code) {
  568. shr.showWarning({
  569. message: res.msg,
  570. hideAfter: 6
  571. });
  572. }else {
  573. shr.showWarning({
  574. message: "刪除成功",
  575. hideAfter: 6
  576. });
  577. wafentries.jqGrid("delRowData",entryId)
  578. }
  579. }
  580. });
  581. });
  582. }else {
  583. shr.showWarning({
  584. message: "請選擇要刪除的行",
  585. hideAfter: 3
  586. });
  587. }
  588. },
  589. })