atsLeaveBillBatchEditForPerExt.js 10 KB

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