atsOverTimeBillBatchEditEx.js 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487
  1. /*
  2. * 批量加班单拓展
  3. * 202412
  4. * 匡原志_coyle
  5. */
  6. shr.defineClass(
  7. "shr.ats.AtsOverTimeBillBatchEditEx", shr.ats.AtsOverTimeBillBatchEdit,
  8. {
  9. filter: {},
  10. OTContrlParams: {},
  11. initalizeDOM: function () {
  12. shr.ats.AtsOverTimeBillBatchEdit.superClass.initalizeDOM.call(this);
  13. var that = this;
  14. that.remoteCall({
  15. type: "post",
  16. method: "getDecimalPlace",
  17. //handler:
  18. // "com.kingdee.shr.ats.web.handler.AtsBillBaseEditHandler",
  19. success: function (res) {
  20. fixedNum = res;
  21. }
  22. });
  23. // that.getOTContrlParams();
  24. //按组织填充按钮
  25. $(
  26. '<button type="button" style="margin-left:4px;margin-right:4px" class="shrshrbtn-primary shrbtn" id="orgfill">' +
  27. jsBizMultLan.atsManager_atsOverTimeBillBatchEdit_i18n_17 +
  28. "</button>"
  29. ).insertAfter($("#addRow_entries"));
  30. var classfullNameService =
  31. "com.kingdee.shr.ats.web.formEditImport.AtsOverTimeBillFileEditFormService";
  32. //导入 按钮
  33. $(
  34. '<button type="button" style="margin-left:4px;margin-right:4px;display: none" class="shrshrbtn-primary shrbtn" id="import">' +
  35. jsBizMultLan.atsManager_atsOverTimeBillBatchEdit_i18n_3 +
  36. "</button>"
  37. ).insertAfter($("#addRow_entries"));
  38. $("#import").click(function () {
  39. that.importAction(null, classfullNameService);
  40. });
  41. $(".editGrid-toolbar").append(
  42. '<div style="display: inline;padding-left: 20px;">' +
  43. jsBizMultLan.atsManager_atsOverTimeBillBatchEdit_i18n_32 +
  44. '<div><div id="hasNum"></div>'
  45. );
  46. var serviceId = shr.getUrlRequestParam("serviceId");
  47. var url =
  48. shr.getContextPath() +
  49. "/dynamic.do?checkLicense=true&uipk=com.kingdee.eas.hr.ats.app.OverTimeOrgFillForm";
  50. url += "&serviceId=" + encodeURIComponent(serviceId);
  51. $("#orgfill").click(function () {
  52. $("#orgFillDiv").attr("src", url);
  53. var gridNum = $("#entries").getGridParam("reccount");
  54. $("#hasNum").val(gridNum);
  55. $("#orgFillDiv").dialog({
  56. title:
  57. jsBizMultLan.atsManager_atsOverTimeBillBatchEdit_i18n_17,
  58. width: 1020,
  59. height: 450,
  60. modal: true,
  61. resizable: false,
  62. position: {
  63. my: "center",
  64. at: "top+20%",
  65. of: window
  66. },
  67. open: function (event, ui) {},
  68. buttons: [
  69. {
  70. text:
  71. jsBizMultLan.atsManager_atsOverTimeBillBatchEdit_i18n_19,
  72. click: function () {
  73. //校验F7数据
  74. if (that.checkF7Data()) {
  75. var oldRowIds = $("#entries").getDataIDs();
  76. that.fillGrid();
  77. var newRowIds = $("#entries").getDataIDs();
  78. rowIds = that.getFillRowId(
  79. oldRowIds,
  80. newRowIds
  81. );
  82. $.each(rowIds, function (n, value) {
  83. //that.calRestTimeLen(value); 2015-11-03:组织填充不用自动计算时长
  84. that.changOtTimeTipInfo(value);
  85. });
  86. //检查不超过100条记录
  87. //that.checkRowIsOver();
  88. $(this).dialog("close");
  89. } else {
  90. return;
  91. }
  92. }
  93. },
  94. {
  95. text:
  96. jsBizMultLan.atsManager_atsOverTimeBillBatchEdit_i18n_5,
  97. click: function () {
  98. $(this).dialog("close");
  99. }
  100. }
  101. ]
  102. });
  103. $("#orgFillDiv").attr("style", "width:1020px;height:550px;");
  104. });
  105. var entries_cont = waf("#entries");
  106. entries_cont.jqGrid("option", {
  107. onChange: function (rowid, cellname, value, iRow, iCol) {
  108. console.log(rowid, cellname, value, iRow, iCol, 123123);
  109. },
  110. beforeSaveCell: function (
  111. rowid,
  112. cellname,
  113. value,
  114. iRow,
  115. iCol
  116. ) {},
  117. afterSaveCell: function (rowid, cellname, value, iRow, iCol) {
  118. if (value["adminOrgUnit.id"]) {
  119. $("#entries").jqGrid(
  120. "setCell",
  121. rowid,
  122. "adminOrgUnit.id",
  123. value["adminOrgUnit.id"]
  124. );
  125. }
  126. that.removePreShowError(rowid);
  127. if (cellname == "otDate") {
  128. var val = value;
  129. if (val.length <= 10) {
  130. val = val + " 00:00:00";
  131. }
  132. val &&
  133. $("#entries").jqGrid(
  134. "setCell",
  135. rowid,
  136. "startTime",
  137. val
  138. );
  139. val &&
  140. $("#entries").jqGrid(
  141. "setCell",
  142. rowid,
  143. "endTime",
  144. val
  145. );
  146. that.changeOverTimeType(rowid);
  147. that.calRestTimeLen(rowid);
  148. that.getOTContrlParams(rowid);
  149. }
  150. if (cellname == "otType") {
  151. that.changeOTCompens(rowid);
  152. }
  153. // 添加 开始时间 结束时间 休息时长(分钟) 响应时间
  154. if (
  155. cellname == "startTime" ||
  156. cellname == "endTime" ||
  157. cellname == "restTime"
  158. ) {
  159. if (cellname != "restTime") {
  160. that.calRestTimeLen(rowid);
  161. }
  162. that.calculateOTtimes(rowid);
  163. }
  164. if (cellname == "person") {
  165. that.calRestTimeLen(rowid);
  166. that.getOTContrlParams(rowid);
  167. }
  168. if (cellname == "applyOTTime") {
  169. // 加班小时数 发生改变就给予提示
  170. that.changOtTimeTipInfo(rowid);
  171. }
  172. if (
  173. cellname == "restStartTime" ||
  174. cellname == "restStartTime2" ||
  175. cellname == "restEndTime" ||
  176. cellname == "restEndTime2"
  177. ) {
  178. //计算休息时间,加班时间
  179. var startTime = $("#entries").jqGrid(
  180. "getCell",
  181. rowid,
  182. "startTime"
  183. );
  184. var endTime = $("#entries").jqGrid(
  185. "getCell",
  186. rowid,
  187. "endTime"
  188. );
  189. var restStartTime = $("#entries").jqGrid(
  190. "getCell",
  191. rowid,
  192. "restStartTime"
  193. );
  194. var restEndTime = $("#entries").jqGrid(
  195. "getCell",
  196. rowid,
  197. "restEndTime"
  198. );
  199. var restStartTime2 = $("#entries").jqGrid(
  200. "getCell",
  201. rowid,
  202. "restStartTime2"
  203. );
  204. var restEndTime2 = $("#entries").jqGrid(
  205. "getCell",
  206. rowid,
  207. "restEndTime2"
  208. );
  209. if (startTime == "" || endTime == "") {
  210. return;
  211. }
  212. var totalRestTime = 0;
  213. var totalRestTimeLong = 0;
  214. var restStartTimeOfDate;
  215. var restEndTimeOfDate;
  216. if(shr.getBowserInfo().browser === 'IE' || shr.getBowserInfo().browser === 'Safari'){
  217. restStartTime = restStartTime.replace(/-/g,'/');
  218. restEndTime = restEndTime.replace(/-/g,'/');
  219. restStartTime2 = restStartTime2.replace(/-/g,'/');
  220. restEndTime2 = restEndTime2.replace(/-/g,'/');
  221. }
  222. if (restStartTime != "" && restEndTime != "") {
  223. restStartTimeOfDate = new Date(restStartTime);
  224. restEndTimeOfDate = new Date(restEndTime);
  225. var times =
  226. restEndTimeOfDate.getTime() -
  227. restStartTimeOfDate.getTime();
  228. if (times < 0) {
  229. times = 0;
  230. }
  231. totalRestTimeLong += times;
  232. times = times / 1000 / 60;
  233. totalRestTime += times;
  234. }
  235. if (restStartTime2 != "" && restEndTime2 != "") {
  236. var restStartTime2OfDate = new Date(restStartTime2);
  237. var restEndTime2OfDate = new Date(restEndTime2);
  238. if (
  239. (restStartTime != "" &&
  240. restEndTime2OfDate.getTime() >
  241. restStartTimeOfDate.getTime() &&
  242. restStartTimeOfDate.getTime() >=
  243. restStartTime2OfDate.getTime()) ||
  244. (restEndTime != "" &&
  245. restEndTimeOfDate.getTime() <=
  246. restEndTime2OfDate.getTime() &&
  247. restStartTime2OfDate.getTime() <
  248. restEndTimeOfDate.getTime()) ||
  249. (restStartTime != "" &&
  250. restEndTime != "" &&
  251. restEndTimeOfDate.getTime() >=
  252. restEndTime2OfDate.getTime() &&
  253. restStartTime2OfDate.getTime() >=
  254. restStartTimeOfDate.getTime())
  255. ) {
  256. //时间有交叉
  257. $("#entries").jqGrid(
  258. "setCell",
  259. rowid,
  260. "restEndTime2",
  261. restStartTime2
  262. );
  263. } else {
  264. var times =
  265. restEndTime2OfDate.getTime() -
  266. restStartTime2OfDate.getTime();
  267. if (times < 0) {
  268. times = 0;
  269. }
  270. totalRestTimeLong += times;
  271. times = times / 1000 / 60;
  272. totalRestTime += times;
  273. }
  274. }
  275. var t1 = totalRestTime.toFixed(
  276. atsMlUtile.getSysDecimalPlace()
  277. );
  278. $("#entries").jqGrid("setCell", rowid, "restTime", t1);
  279. var startTime = NewDate(startTime + ":00");
  280. var endTime = NewDate(endTime + ":00");
  281. var se =
  282. endTime.getTime() -
  283. startTime.getTime() -
  284. totalRestTimeLong; // 毫秒
  285. // var tfl = se / (3600 * 1000);
  286. var tfl = Math.floor(se / (3600 * 1000)); // 向下取整
  287. $("#entries").jqGrid(
  288. "setCell",
  289. rowid,
  290. "applyOTTime",
  291. tfl
  292. );
  293. that.getOTContrlParams(rowid);
  294. }
  295. },
  296. afterEditCell: function (rowid, cellname, value, iRow, iCol) {
  297. if (
  298. cellname == "otType" &&
  299. that.OTContrlParams[rowid] &&
  300. that.OTContrlParams[rowid].isOtrolByDateType
  301. ) {
  302. $("#" + iRow + "_otType").shrPromptBox("disable");
  303. }
  304. if (cellname == "otCompens") {
  305. if (that.filter[rowid] == undefined) {
  306. // R20221006-0542 修复选择加班费后 再点击“补偿方式”F7就变成了调休的问题
  307. // that.changeOTCompens(rowid);
  308. }
  309. if (that.filter[rowid]) {
  310. // $("#"+rowid+"_otCompens").shrPromptBox("setFilter",that.filter[rowid]);
  311. $(
  312. "#" +
  313. $("#entries").jqGrid(
  314. "getCell",
  315. rowid,
  316. "rn"
  317. ) +
  318. "_otCompens"
  319. ).shrPromptBox("setFilter", that.filter[rowid]);
  320. }
  321. }
  322. if (cellname == "person") {
  323. var hrOrgUnitId = $("#hrOrgUnit_el").val();
  324. $("#" + rowid + "_person")
  325. .shrPromptBox()
  326. .attr("data-params", hrOrgUnitId);
  327. $("#" + iRow + "_person").shrPromptBox("option", {
  328. onchange: function (e, value) {
  329. $("#entries").jqGrid(
  330. "setCell",
  331. rowid,
  332. "person.number",
  333. value.current
  334. ? value.current["person.number"]
  335. : ""
  336. );
  337. }
  338. });
  339. }
  340. if(cellname == "attAdminOrgUnit"){
  341. var personId = $("#entries").jqGrid("getCell", rowid, "person").id;
  342. var attendanceDate = $("#entries").jqGrid("getCell", rowid, "otDate");
  343. if(!(personId && attendanceDate)){
  344. shr.showInfo({message: jsBizMultLan.atsManager_atsOverTimeBillEdit_YM_999});
  345. return false;
  346. }else{
  347. //$("#"+rowid+"_attPosition").shrPromptBox().attr("data-params", adminOrg);
  348. $("#"+iRow+"_attAdminOrgUnit").shrPromptBox("setOtherParams", {
  349. personId: personId,
  350. attendanceDate: attendanceDate
  351. });
  352. }
  353. }
  354. }
  355. });
  356. that.setButtonVisible(); //初始化页面安装状态,如果是已经提交的或者审批通过的单据编辑按钮不显示
  357. //隐藏提交生效按钮
  358. if (that.getOperateState() == "EDIT") {
  359. if (that.isFromWF()) {
  360. // 来自流程中心
  361. $("#submitEffect").hide();
  362. $("#submit").text(
  363. jsBizMultLan.atsManager_atsOverTimeBillBatchEdit_i18n_25
  364. );
  365. }
  366. }
  367. //审核编辑界面
  368. if (
  369. that.isFromWF() &&
  370. that.getOperateState() == "EDIT" &&
  371. $("#billState").val() != 0
  372. ) {
  373. $("#deleteRow_entries")
  374. .unbind("click")
  375. .attr("onclick", "")
  376. .css("cursor", "default");
  377. $("#addRow_entries")
  378. .unbind("click")
  379. .attr("onclick", "")
  380. .css("cursor", "default");
  381. $(".editGrid-toolbar").hide();
  382. $("#submit").hide();
  383. var lastRowNum = $("#entries").getGridParam("reccount");
  384. for (var i = 1; i <= lastRowNum; i++) {
  385. var temp_id = $("#entries tr:eq(" + i + ")").attr("id");
  386. $("#entries").jqGrid(
  387. "setCell",
  388. temp_id,
  389. "person",
  390. "",
  391. "not-editable-cell"
  392. );
  393. }
  394. }
  395. //考勤计算--已计算页签--明细显示模式--请假按钮进来,只显示提交生效按钮
  396. if (
  397. shr.getUrlParam("fromCalDetail") != null &&
  398. shr.getUrlParam("fromCalDetail") == "1"
  399. ) {
  400. $("#save").hide();
  401. $("#submit").hide();
  402. $("#cancelAll").hide();
  403. $("#import").hide();
  404. $("#orgfill").hide();
  405. $(".view_manager_header > div > div").eq(0).remove();
  406. $("#submitEffect").addClass("shrbtn-primary");
  407. $('#workAreaDiv .ui-jqgrid-bdiv').css('max-height','253px') // 当页面作为弹框时 表格过长则隐藏滑动
  408. }
  409. //增加业务组织处理
  410. that.processF7ChangeEventHrOrgUnit();
  411. var hrOrgUnitId = $("#hrOrgUnit_el").val();
  412. that.initCurrentHrOrgUnit(hrOrgUnitId);
  413. that.initCcPersonPrompt();
  414. },
  415. calculateOTtimes: function (rowid) {
  416. var startTime = $("#entries").jqGrid("getCell", rowid, "startTime");
  417. var endTime = $("#entries").jqGrid("getCell", rowid, "endTime");
  418. var restTime = $("#entries").jqGrid("getCell", rowid, "restTime");
  419. if (startTime == "[object Object]") {
  420. $("#" + rowid)
  421. .find("td")
  422. .eq("5")
  423. .text("");
  424. $("#" + rowid)
  425. .find("td")
  426. .eq("5")
  427. .attr("title", "");
  428. }
  429. if (endTime == "[object Object]") {
  430. $("#" + rowid)
  431. .find("td")
  432. .eq("6")
  433. .text("");
  434. $("#" + rowid)
  435. .find("td")
  436. .eq("6")
  437. .attr("title", "");
  438. }
  439. if (startTime != "" && endTime != "") {
  440. var restVal = 0;
  441. if (restTime != "" && /^[0-9]*$/.test(restTime)) {
  442. restVal = restTime; // 分钟数
  443. }
  444. var startTime = NewDate(startTime + ":00");
  445. var endTime = NewDate(endTime + ":00");
  446. var se =
  447. endTime.getTime() -
  448. startTime.getTime() -
  449. restVal * 1000 * 60; // 毫秒
  450. // var tfl = se / (3600 * 1000);
  451. var tfl = Math.floor(se / (3600 * 1000)); // 向下取整
  452. $("#entries").jqGrid(
  453. "setCell",
  454. rowid,
  455. "applyOTTime",
  456. tfl.toFixed(fixedNum)
  457. );
  458. }
  459. },
  460. }
  461. );