atsLeaveBillEditNewExt.js 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306
  1. var personType = "";
  2. //员工自助--多人请假单(新增)
  3. shr.defineClass("shr.ats.atsLeaveBillEditNewExt", shr.ats.atsLeaveBillEditNew, {
  4. initalizeDOM: function () {
  5. shr.ats.atsLeaveBillEditNewExt.superClass.initalizeDOM.call(this);
  6. var that = this;
  7. $("#dowFile").hide();
  8. shr.callHandler({
  9. handler : "com.kingdee.shr.ats.web.handler.AtsLeaveBillEditHandlerEx",
  10. action : 'customerCheckParam',
  11. async : false,
  12. type : "POST",
  13. param : { "policyId" : "","personId" : $("#personId").val() },
  14. success:function(data){
  15. personType = data.personType;
  16. }
  17. });
  18. var entries_cont = waf("#entries");
  19. entries_cont.jqGrid("option", {
  20. beforeSaveCell: function (rowid, cellname, value, iRow, iCol) { // F7触发
  21. if (cellname == "policy") {
  22. action = "save";
  23. }
  24. }
  25. , afterSaveCell: function (rowid, cellname, value, iRow, iCol) { // F7 触发
  26. if(value["adminOrgUnit.id"]){
  27. $("#entries").jqGrid('setCell',rowid,"adminOrgUnit.id",value["adminOrgUnit.id"]);
  28. }
  29. if(cellname == "realLeaveLength"){
  30. if( "GTIIT_SAS" == personType || "GTIIT_PSS" == personType || "GTIIT_GAS" == personType){
  31. var rowData = $("#entries").jqGrid("getRowData");
  32. var flag = false;
  33. for(var i = 0; i < rowData.length; i++){
  34. var leaveLength = rowData[i].realLeaveLength;
  35. if(leaveLength >= 7){
  36. flag = true;
  37. }
  38. }
  39. if(flag){
  40. that.getField("remark").shrTextarea('option', 'required', true);
  41. $("#remark").parent().parent().parent().parent().find(".field-label").text("Request for leave:During my applied leave,the emergency contact will be :");
  42. }else{
  43. $("#remark").parent().parent().parent().parent().find(".field-label").text("Request for leave:");
  44. that.getField("remark").shrTextarea('option', 'required', false);
  45. }
  46. }
  47. }
  48. _self.afterSaveCellTrigger(rowid, cellname, value, iRow, iCol);
  49. }
  50. , beforeEditCell: function (rowid, cellname, value, iRow, iCol) { // 切换成文本的时候触发
  51. if(cellname == "isElasticCalLen"){
  52. var $entries_isElasticCalLen="#entries tr[id='" + rowid + "'] td[aria-describedby='entries_isElasticCalLen'] input";
  53. $($entries_isElasticCalLen).unbind("change");
  54. $($entries_isElasticCalLen).change(function(){
  55. that.countLeaveLength(rowid);
  56. });
  57. }
  58. if (cellname == "policy") {
  59. lastRowRemark = $("#entries tr[id='" + rowid + "'] td[aria-describedby='entries_policy']").attr('title');
  60. idROW = rowid;
  61. policyKey = $("#entries").jqGrid('getCell', rowid, "policy");
  62. action = "EDIT";
  63. }
  64. if (cellname == "leaveLength") {
  65. // setTimeout(function () {
  66. // $('#' + rowid + '_leaveLength').attr('readonly', true);
  67. // }, 1);
  68. //请假长度可否编辑
  69. var personId = $("#entries").jqGrid('getCell', rowid, "person").id;
  70. if (typeof personId === 'undefined') {
  71. return;
  72. }
  73. var hrOrgUnitId = $("#hrOrgUnit_el").val();
  74. if (hrOrgUnitId == null || hrOrgUnitId == "") {
  75. shr.showWarning({ message: jsBizMultLan.atsManager_atsLeaveBillBatchEdit_i18n_ZFY_1 });
  76. return;
  77. }
  78. that.remoteCall({
  79. type: "post",
  80. method: "isLeaveLengthEdit",
  81. param: { personId: personId, hrOrgUnitId: hrOrgUnitId },
  82. async: false,
  83. success: function (res) {
  84. var info = res;
  85. if (info.errorString) {
  86. shr.showWarning({ message: info.errorString });
  87. } else {
  88. if (info.editable == 'true') {
  89. $("#" + rowid).find("td").eq(iCol).removeClass("disabled");
  90. } else {
  91. $("#entries").jqGrid('setCell', rowid, "leaveLength", "", "disabled");
  92. $("#entries").jqGrid('setCell', rowid, "realLeaveLength", "", "disabled");
  93. setTimeout(function () {
  94. $("#entries").jqGrid('restoreCell', iRow, iCol);
  95. }, 1);
  96. }
  97. }
  98. }
  99. });
  100. }
  101. }
  102. , afterEditCell: function (rowid, cellname, value, iRow, iCol) {
  103. if(cellname=="person"){
  104. var hrOrgUnitId=$("#hrOrgUnit_el").val();
  105. $("#"+rowid+"_person").shrPromptBox().attr("data-params",hrOrgUnitId);
  106. }
  107. _self.saveEditCellValue(rowid, cellname, value, iRow, iCol);
  108. }
  109. , afterRestoreCell: function (rowid, value, iRow, iCol) {
  110. if (iCol == 3 && action != "save") { // 将说明 重新复制
  111. $("#entries tr[id='" + rowid + "'] td[aria-describedby='entries_policy']").attr('title', lastRowRemark);
  112. }
  113. }
  114. });
  115. },
  116. verify: function () {
  117. var that = this;
  118. var billerrorString="";
  119. //如果是查看页面提交工作流,不需要再次校验了
  120. if (that.getOperateState().toUpperCase() == 'ViEW') {
  121. return;
  122. }
  123. var obj = $("#entries").jqGrid("getRowData");
  124. if (obj.length == 0) {
  125. shr.showWarning({ message: jsBizMultLan.atsManager_atsLeaveBillBatchEdit_i18n_ZFY_6 });
  126. return false;
  127. }
  128. if (!that.checkRowIsOver()) {
  129. return false;
  130. }
  131. if (!that.checkEntry()) {
  132. return false;
  133. }
  134. if (!that.checkBilltime(obj)) {
  135. shr.showWarning({message: jsBizMultLan.atsManager_atsLeaveBillBatchEdit_i18n_NX_3});
  136. return false;
  137. }
  138. /*if(!that.checkEnoughRemain()){
  139. shr.showWarning({message: jsBizMultLan.atsManager_atsLeaveBillBatchEdit_i18n_NX_4});
  140. return false;
  141. }*/
  142. var errorString = "";
  143. var errorFlag = 0;
  144. jQuery(obj).each(function (n) {
  145. // info = that.validateLeaveBillCycle(this.person.id,this.beginTime,this.endTime,this.policy.id,this.leaveLength);
  146. var rowid = $("#entries tr:eq(" + (n + 1) + ")").attr('id')
  147. errorString = that.checkIsNullEveryRow(this);
  148. if (errorString == "") {
  149. errorString = that.checkEveryRow(this);
  150. }
  151. if (errorString == "" || errorString == undefined) { // 检测请假时长是不是大于计算时长
  152. errorString = that.checkCalLength(this);
  153. }
  154. if (errorString == undefined || errorString == null || errorString == "") {
  155. } else {
  156. billerrorString= billerrorString + shr.formatMsg(jsBizMultLan.atsManager_atsLeaveBillBatchEdit_i18n_ZFY_7, [n+1]) + errorString +"<br>";
  157. var showMes = ""
  158. showMes += errorString.replace(/<br>/g, "");
  159. // shr.showWarning({message: this.person.name + " "+ this.policy.name +" " + errorString});
  160. // return false;
  161. that.preShowError(rowid, this.person.name + " " + this.policy.name + " " + showMes);
  162. errorFlag = 1;
  163. }
  164. });
  165. //校验是否为同一个假期类型
  166. if( "GTIIT_SAS" == personType || "GTIIT_PSS" == personType || "GTIIT_GAS" == personType){
  167. for(var i = 0 ; i < obj.length ; i++){
  168. var realLeaveLength = obj[i].realLeaveLength;
  169. if(realLeaveLength >= 7 && (obj[i].reason == null || obj[i].reason == "")){
  170. shr.showWarning({message: "If the duration of leave is more than 7 days, the reason for leave cannot be empty !"});
  171. return false;
  172. }
  173. }
  174. }
  175. if (errorFlag == 0) {
  176. return true;
  177. } else {
  178. shr.showWarning({message: billerrorString});
  179. return false;
  180. }
  181. return false;
  182. },
  183. countLeaveLength: function (rowid, action) {
  184. var that = this;
  185. if ($("#entries").jqGrid('getCell', rowid, "person") == undefined
  186. || $("#entries").jqGrid('getCell', rowid, "person") == null) {
  187. return;
  188. } else {
  189. personId = $("#entries").jqGrid('getCell', rowid, "person").id;
  190. }
  191. if ($("#entries").jqGrid('getCell', rowid, "policy") == undefined
  192. || $("#entries").jqGrid('getCell', rowid, "policy") == null) {
  193. return;
  194. } else {
  195. holidayTypeId = $("#entries").jqGrid('getCell', rowid, "policy").id;
  196. }
  197. var personId = $("#entries").jqGrid('getCell', rowid, "person").id;
  198. var beginTime = $("#entries").jqGrid('getCell', rowid, "beginTime");
  199. var endTime = $("#entries").jqGrid('getCell', rowid, "endTime");
  200. var hrOrgUnitId = $("#hrOrgUnit_el").val();
  201. var isElasticCalLen = $("#entries").jqGrid('getCell', rowid, "isElasticCalLen")=="1";
  202. if (!strDateTime(beginTime) || !strDateTime(endTime)) {
  203. return;
  204. }
  205. var holidayTypeId = $("#entries").jqGrid('getCell', rowid, "policy").id;
  206. if (personId == undefined || personId == null
  207. || holidayTypeId == undefined || holidayTypeId == null
  208. || beginTime == undefined || beginTime == null
  209. || endTime == undefined || endTime == null) {
  210. return;
  211. }
  212. that.remoteCall({
  213. type: "post",
  214. async: false,
  215. method: "getRealLeaveLengthInfo",
  216. param: { personId: personId,
  217. beginTime: beginTime,
  218. endTime: endTime,
  219. holidayTypeId: holidayTypeId,
  220. action: action,
  221. hrOrgUnitId: hrOrgUnitId,
  222. isElasticCalLen:isElasticCalLen},
  223. success: function (res) {
  224. info = res;
  225. if (info.errorString) {
  226. that.preShowError(rowid, info.errorString);
  227. // shr.showError({message: info.errorString});
  228. } else {
  229. var day = parseFloat(info.leaveBillDays + info.segRest);
  230. var leaveLengDay = parseFloat(info.leaveBillDays);
  231. if (action != "EDIT") { // 第一次进入的时候重现计算先请假时长
  232. $("#entries").jqGrid('setCell', rowid, "leaveLength", leaveLengDay);
  233. $("#entries").jqGrid('setCell', rowid, "realLeaveLength", leaveLengDay);
  234. }
  235. // 每次触发之前都会记住这个 计算的时长
  236. $("#entries").jqGrid('setCell', rowid, "caleaveLength", day);
  237. }
  238. }
  239. });
  240. if( "GTIIT_SAS" == personType || "GTIIT_PSS" == personType || "GTIIT_GAS" == personType){
  241. var rowData = $("#entries").jqGrid("getRowData");
  242. var flag = false;
  243. for(var i = 0; i < rowData.length; i++){
  244. var leaveLength = rowData[i].realLeaveLength;
  245. if(leaveLength >= 7){
  246. flag = true;
  247. }
  248. }
  249. if(flag){
  250. that.getField("remark").shrTextarea('option', 'required', true);
  251. $("#remark").parent().parent().parent().parent().find(".field-label").text("Request for leave:During my applied leave,the emergency contact will be :");
  252. }else{
  253. $("#remark").parent().parent().parent().parent().find(".field-label").text("Request for leave:");
  254. that.getField("remark").shrTextarea('option', 'required', false);
  255. }
  256. }
  257. },
  258. dowFileAction:function(){
  259. shr.callHandler({
  260. handler : "com.kingdee.customer.util.handler.ConfigurationHandler",
  261. action : 'getCustomerConfig',
  262. async : false,
  263. param : { "fnumber" : "1001" },
  264. success:function(data){
  265. if(data){
  266. // 创建一个虚拟的链接元素
  267. var downloadLink = document.createElement('a');
  268. downloadLink.download = data.name;
  269. downloadLink.href = data.ip+"/leaveTemplate/"+data.name;
  270. document.body.appendChild(downloadLink);
  271. downloadLink.click();
  272. document.body.removeChild(downloadLink);
  273. }else{
  274. shr.showInfo({message: "No teacher fake template is configured !"});
  275. }
  276. }
  277. });
  278. },
  279. });