Built files from Bizgaze WebServer
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

terminateemployee.component.js 24KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278
  1. var Bizgaze;
  2. (function (Bizgaze) {
  3. let Apps;
  4. (function (Apps) {
  5. let Hrms;
  6. (function (Hrms) {
  7. let Payroll;
  8. (function (Payroll) {
  9. let Controls;
  10. (function (Controls) {
  11. let PayRun;
  12. (function (PayRun) {
  13. class TerminateEmployee extends Unibase.Platform.Core.BaseComponent {
  14. constructor() {
  15. super(...arguments);
  16. this.strtxt = "0";
  17. this.strDeductionstxt = "0";
  18. this.t_VisibleContainerId = "";
  19. this.delete_Array = [];
  20. }
  21. init(formpropertyid, prop, callback) {
  22. var container = "control-container-" + formpropertyid;
  23. var instance = this;
  24. instance.fileCacheHelper.loadJsFiles(['platform/core/helpers/numberhelper/numberhelper.js'], function () {
  25. let listCount = +$('#addNewEarningBtn').attr('data-count');
  26. instance.calculatenetpay();
  27. });
  28. }
  29. loadControl(containerid, prop) {
  30. var instance = this;
  31. instance.transactionId = prop.FormPropertyId;
  32. instance.t_VisibleContainerId = Unibase.Platform.Helpers.NavigationHelper.ModalContainerIds[Unibase.Platform.Helpers.NavigationHelper.ModalContainerIds.length - 1];
  33. Bizgaze.Apps.Hrms.Payroll.Controls.PayRun.TerminateEmployee.Instance().delete_Array = [];
  34. var html = `<div class="ul_terminateemployeedetails">
  35. <div class="terminateemployeeearningdetails">
  36. <div class='row text-dark font-weight-600'>
  37. <div class='col-md-6'>Additional Earnings</div>
  38. <div class='col-md-6'>AMOUNT</div>
  39. </div>
  40. <ul id="earningTypesList"></ul>
  41. <ul id="transactionList"></ul>
  42. <a href="javascript:;" id="addNewEarningBtn" class="btn btn-primary btn-sm mt-10" onclick="Bizgaze.Apps.Hrms.Payroll.Controls.PayRun.TerminateEmployee.Instance().addearnings();" data-count="0"> + Add Earning</a>
  43. <input type="hidden" id="hdn_termenateemployeeearningcontrol" class="value-control"
  44. value="Bizgaze.Apps.Hrms.Payroll.Controls.PayRun.TerminateEmployee.Instance().employeeearningobject();"/></div>`;
  45. html += ` <div class="terminateemployeedeductiondetails">
  46. <div class='row text-dark font-weight-600'>
  47. <div class='col-md-6'>Deductions</div>
  48. <div class='col-md-6'>AMOUNT</div>
  49. </div>
  50. <ul id="DeductionList"></ul>
  51. <ul id="DeductiontransactionList"></ul>
  52. <a href="javascript:;" id="addNewDeductionBtn" class="btn btn-primary btn-sm mt-10" onclick="Bizgaze.Apps.Hrms.Payroll.Controls.PayRun.TerminateEmployee.Instance().addDeduction();" data-count="0">+ Add Deduction</a><input type="hidden" id="hdn_terminateemployeedeductioncontrol" class="value-control"
  53. value="Bizgaze.Apps.Hrms.Payroll.Controls.PayRun.TerminateEmployee.Instance().employeedeductionobject();"/></div></div></div>`;
  54. $("#" + containerid).html(html);
  55. Bizgaze.Apps.Hrms.Payroll.Controls.PayRun.TerminateEmployee.Instance().getPayRunEmployeedetails();
  56. Bizgaze.Apps.Hrms.Payroll.Controls.PayRun.TerminateEmployee.Instance().getpayrunemployeesalarycomponents();
  57. }
  58. loadControlSettings(controlsettingjson, formpropertyid) { }
  59. loadPropertySettings(propertysettings, formpropertyid, DocPropertyName) { }
  60. bindEditFormDetails(formpropertyid, propval, DocPropertyName) { }
  61. calculatenetpay() {
  62. $(".txt_lopdays").keyup(function () {
  63. var lopdays = Number($(".txt_lopdays").val());
  64. var payabledays = Number($(".txt_payabledays").val());
  65. var actualdays = Number($(".txt_actualpayabledays").val());
  66. var actual_days = actualdays - lopdays;
  67. $(".txt_actualpayabledays").val(actual_days);
  68. var netpay = Number($(".number_netpay").val());
  69. var totalnetpay = Math.round(netpay / payabledays);
  70. $(".number_netpay").val(Math.round(totalnetpay * actual_days));
  71. });
  72. }
  73. getPayRunEmployeedetails() {
  74. var instance = this;
  75. var payrunemployeeid = +$(".active-employee-item").find("#hf_widgetitem_Id").val();
  76. Unibase.Platform.Helpers.FileCacheHelper.Instance().loadJsFile("apps/hrms/payroll/managers/payrollmanager.js", function () {
  77. Bizgaze.Apps.Hrms.Payroll.Managers.PayRollManager.Instance().getemployee(payrunemployeeid).then(function (responce) {
  78. var employeeid = responce.result.EmployeeId;
  79. $("._employee").val(employeeid);
  80. var empname = responce.result.FirstName;
  81. var employee = new Option(empname, employeeid);
  82. $(".txtAutoComplete_employeeid").append(employee);
  83. $(".txtAutoComplete_employeeid").prop("disabled", true);
  84. $(".number_netpay").val(responce.result.NetPay);
  85. $(".txt_payabledays").val(responce.result.PayableDays);
  86. $(".txt_actualpayabledays").val(responce.result.ActualPayabledays);
  87. $(".txt_lopdays").val(responce.result.LOPDays);
  88. });
  89. });
  90. }
  91. getpayrunemployeesalarycomponents() {
  92. var instance = this;
  93. let listCount = +$('#addNewEarningBtn').attr('data-count');
  94. var payrunemployeeid = +$(".active-employee-item").find("#hf_widgetitem_Id").val();
  95. Unibase.Platform.Helpers.FileCacheHelper.Instance().loadJsFile("apps/hrms/payroll/managers/payrollmanager.js", function () {
  96. Bizgaze.Apps.Hrms.Payroll.Managers.PayRollManager.Instance().getemployeeterminatesalarycomponents(payrunemployeeid).then(function (response) {
  97. for (var i = 0; i < response.result.length; i++) {
  98. var data = response.result[i];
  99. var earningTypeId = data.SalaryComponentId;
  100. var html = `<li class="row my-10 liupdatepayrunearningdetails li_terminateemployeeearningdetails" id="earningTypeItem_${earningTypeId}">
  101. <input type="hidden" class='hf_earningtypeid' value='${earningTypeId}'/>
  102. <input type="hidden" class='hf_isactive' value='true'/>
  103. <input type="hidden" id="hfAutoCompleteId_SalaryComponents_${earningTypeId}" data-earningid=${earningTypeId} class="hf_earningtypeid" value="${earningTypeId}"/>
  104. <div class='col-md-5'><input type="text" class="form-control txt_earningname_${data.SalaryComponentId}" value='${response.result[i].PaySlipName}' /></div>
  105. <div class='col-md-5'><input type="text" id="txt_earningamount_${data.SalaryComponentId}" class="form-control txt_amount" value='${response.result[i].Amount}'></div>
  106. <div class='col-md-2 text-right'><a href="javascript:;" class="btn btn-sm btn-outline-danger btn-icon btn-with-icon" onclick="Bizgaze.Apps.Hrms.Payroll.Controls.PayRun.TerminateEmployee.Instance().${data.ComponentTypeId == 1 ? "deleteEarningType" : "deleteDeductionType"}(${data.SalaryComponentId})"><span class="btn-icon-wrap"><i class="las la-trash font-22"></i></span></a><input type="hidden" id="hdn_termenateemployeeearningcontrol" class="value-control"
  107. value="Bizgaze.Apps.Hrms.Payroll.Controls.PayRun.TerminateEmployee.Instance().employeeearningobject();"/></div>
  108. </li>`;
  109. var componenttypeid = data.ComponentTypeId;
  110. instance.strtxt = instance.strtxt.split('|');
  111. instance.strtxt.push(data.SalaryComponentId);
  112. instance.strtxt = instance.strtxt.join('|');
  113. $('#addNewDeductionBtn').attr('data-count', listCount + 1);
  114. if (componenttypeid == 1) {
  115. $("#transactionList").append(html);
  116. }
  117. else {
  118. $("#DeductionList").append(html);
  119. }
  120. }
  121. });
  122. });
  123. }
  124. addearnings() {
  125. const instance = this;
  126. let listCount = +$('#addNewEarningBtn').attr('data-count');
  127. var html = `<li class='row my-10 literminateemployeeearningdetails li_terminateemployeeearningdetails' id="earningTypeItem_${listCount}" >
  128. <div class='col-md-5'>
  129. <select class="form-control hf_salarycomponentid" class="txtAutoComplete_Salary" id ="txtAutoComplete_Salary_${listCount}" data-placeholder="Select"></select><input type="hidden" id="hfAutoCompleteId_SalaryComponents_${listCount}" class="hf_earningtypeid" /><input type="hidden" class='hf_isactive' value='true'/></div>
  130. <div class='col-md-5'><input type="text" id="txt_earningamount_${listCount}" class="form-control txt_amount" onpaste = "return Bizgaze.Apps.Hrms.Payroll.Controls.PayRun.TerminateEmployee.Instance().isNumberKey(event)" oninput = "return Bizgaze.Apps.Hrms.Payroll.Controls.PayRun.TerminateEmployee.Instance().isNumberKey(event)"/></div>
  131. <div class='col-md-2 text-right'><a href="javascript:;" class="btn btn-sm btn-outline-danger btn-icon btn-with-icon" onclick="Bizgaze.Apps.Hrms.Payroll.Controls.PayRun.TerminateEmployee.Instance().deleteEarningType(${listCount})"><span class="btn-icon-wrap"><i class="las la-trash font-22"></i></span></a></div>
  132. </li>`;
  133. $("#transactionList").append(html);
  134. instance.autocompleteEarningType(listCount);
  135. $('#addNewEarningBtn').attr('data-count', listCount + 1);
  136. }
  137. autocompleteEarningType(id) {
  138. const instance = this;
  139. var url = _appsettings.server_url() + '/apis/v4/bizgaze/hrms/payroll/getearningforterminationautocomplete/componenttypeid/' + 1 + '/salarycomponentids/' + instance.strtxt + '/earningtypeid/' + 0;
  140. AutoCompleteHelper.getHelper().Create(`#txtAutoComplete_Salary_${id}`, $(`#hfAutoCompleteId_SalaryComponents_${id}`), url, function () {
  141. $(`#txtAutoComplete_Salary_${id}`).off('select2:select').on('select2:select', function () {
  142. const earningTypeId = $(this).val();
  143. if (!$.isArray(instance.strtxt)) {
  144. instance.strtxt = instance.strtxt.split('|');
  145. instance.strtxt.push(earningTypeId);
  146. instance.strtxt = instance.strtxt.join('|');
  147. }
  148. });
  149. $(`#txtAutoComplete_Salary_${id}`).off('select2:clear').on('select2:clear', function () {
  150. instance.updateEarningsType(id);
  151. });
  152. });
  153. }
  154. deleteEarningType(SalaryComponentId) {
  155. const instance = this;
  156. let earamount = Number($('#txt_earningamount_' + SalaryComponentId).val());
  157. if (earamount == 0) {
  158. $(`#earningTypeItem_${SalaryComponentId}`).remove();
  159. }
  160. var item = {
  161. amount: earamount,
  162. SalaryComponentId: SalaryComponentId
  163. };
  164. Bizgaze.Apps.Hrms.Payroll.Controls.PayRun.TerminateEmployee.Instance().delete_Array.push(item);
  165. instance.updateEarningsType(SalaryComponentId);
  166. $(`#earningTypeItem_${SalaryComponentId}`).remove();
  167. }
  168. updateEarningsType(id) {
  169. const instance = this;
  170. const earningTypeId = $(`#hfAutoCompleteId_SalaryComponents_${id}`).val();
  171. instance.strtxt = instance.strtxt.split('|');
  172. instance.strtxt = instance.strtxt.filter(v => v != earningTypeId).join('|');
  173. }
  174. employeeearningobject() {
  175. var earningobject = new Array();
  176. var installedAppId = Unibase.Themes.Providers.DetailHelper.installedAppId;
  177. var payRunId = Unibase.Themes.Providers.Detail_Settings.Instance().InputParameters.find(x => x.Key == "hf_" + installedAppId + "_payrunid").Value;
  178. $(".ul_terminateemployeedetails").find(".li_terminateemployeeearningdetails").each(function () {
  179. var earningType = Number($(this).find('.hf_earningtypeid').val());
  180. earningobject.push({
  181. EarningName: $(this).find(".txtAutoComplete_Salary").text(),
  182. Amount: Number($(this).find(".txt_amount").val()),
  183. EarningType: earningType != null ? earningType : 0,
  184. PayRunId: payRunId,
  185. PayRunEmployeeId: +$(".active-employee-item").find("#hf_widgetitem_Id").val(),
  186. IsActive: $(this).find('.hf_isactive').val(),
  187. SalaryComponentId: Number($(this).find('.hf_earningtypeid').val()),
  188. deletedata: Bizgaze.Apps.Hrms.Payroll.Controls.PayRun.TerminateEmployee.Instance().delete_Array,
  189. });
  190. });
  191. return earningobject;
  192. }
  193. isNumberKey(evt) {
  194. let instance = this;
  195. if (evt.type == "paste") {
  196. let pastedData = evt.clipboardData.getData('text');
  197. let regExp = /[a-zA-Z]/g;
  198. if (regExp.test(pastedData)) {
  199. evt.preventDefault();
  200. return false;
  201. }
  202. }
  203. else if (evt.type == "input") {
  204. const inputVal = $("#" + instance.t_VisibleContainerId).find(evt.currentTarget).val();
  205. $("#" + instance.t_VisibleContainerId).find(evt.currentTarget).val(inputVal.replace(/\D/g, ''));
  206. }
  207. else {
  208. if (evt.which != 8 && evt.which != 0 && (evt.which < 48 || evt.which > 57)) {
  209. return false;
  210. }
  211. }
  212. return true;
  213. }
  214. addDeduction() {
  215. const instance = this;
  216. let listCount = +$('#addNewDeductionBtn').attr('data-count');
  217. var html = `<li class='row my-10 literminateemployeedeductiondetails li_terminateemployeeearningdetails' id="earningTypeItem_${listCount}">
  218. <input type="hidden" class='hf_isactive' value='true'/>
  219. <div class='col-md-5'>
  220. <select class="form-control hf_salarycomponentid" class="txtAutoComplete_deductionSalary" id ="txtAutoComplete_deductionSalary_${listCount}" data-placeholder="Select"></select><input type="hidden" id="hfAutoCompleteId_deductionSalaryComponents_${listCount}" class="hf_earningtypeid" /></div>
  221. <div class='col-md-5'><input type="text" id="txt_earningamount_${listCount}" class="form-control txt_deductionamount_${listCount} txt_amount" onpaste = "return Bizgaze.Apps.Hrms.Payroll.Controls.PayRun.TerminateEmployee.Instance().isNumberKey(event)" oninput = "return Bizgaze.Apps.Hrms.Payroll.Controls.PayRun.TerminateEmployee.Instance().isNumberKey(event)"/></div>
  222. <div class='col-md-2 text-right'><a href="javascript:;" class="btn btn-sm btn-outline-danger btn-icon btn-with-icon" onclick="Bizgaze.Apps.Hrms.Payroll.Controls.PayRun.TerminateEmployee.Instance().deleteDeductionType(${listCount})"><span class="btn-icon-wrap"><i class="las la-trash font-22"></i></span></a></div>
  223. </li>`;
  224. $("#DeductiontransactionList").append(html);
  225. instance.autocompleteDeductionType(listCount);
  226. $('#addNewDeductionBtn').attr('data-count', listCount + 1);
  227. }
  228. autocompleteDeductionType(id) {
  229. const instance = this;
  230. var url = _appsettings.server_url() + '/apis/v4/bizgaze/hrms/payroll/getearningforterminationautocomplete/componenttypeid/' + 3 + '/salarycomponentids/' + instance.strDeductionstxt + '/earningtypeid/' + 0;
  231. AutoCompleteHelper.getHelper().Create(`#txtAutoComplete_deductionSalary_${id}`, $(`#hfAutoCompleteId_deductionSalaryComponents_${id}`), url, function () {
  232. $(`#txtAutoComplete_deductionSalary_${id}`).off('select2:select').on('select2:select', function () {
  233. const deductionTypeId = $(this).val();
  234. if (!$.isArray(instance.strDeductionstxt)) {
  235. instance.strDeductionstxt = instance.strDeductionstxt.split('|');
  236. instance.strDeductionstxt.push(deductionTypeId);
  237. instance.strDeductionstxt = instance.strDeductionstxt.join('|');
  238. }
  239. });
  240. $(`#txtAutoComplete_deductionSalary_${id}`).off('select2:clear').on('select2:clear', function () {
  241. instance.updateDeductionsType(id);
  242. });
  243. });
  244. }
  245. deleteDeductionType(SalaryComponentId) {
  246. const instance = this;
  247. let earamount = Number($('#txt_earningamount_' + SalaryComponentId).val());
  248. if (earamount == 0) {
  249. $(`#earningTypeItem_${SalaryComponentId}`).remove();
  250. }
  251. var item = {
  252. amount: earamount,
  253. SalaryComponentId: SalaryComponentId
  254. };
  255. Bizgaze.Apps.Hrms.Payroll.Controls.PayRun.TerminateEmployee.Instance().delete_Array.push(item);
  256. instance.updateDeductionsType(SalaryComponentId);
  257. $(`#earningTypeItem_${SalaryComponentId}`).remove();
  258. }
  259. updateDeductionsType(id) {
  260. const instance = this;
  261. const deductionTypeId = $(`#hfAutoCompleteId_deductionSalaryComponents_${id}`).val();
  262. instance.strDeductionstxt = instance.strDeductionstxt.split('|');
  263. instance.strDeductionstxt = instance.strDeductionstxt.filter(v => v != deductionTypeId).join('|');
  264. }
  265. static Instance() {
  266. if (this.instance === undefined) {
  267. this.instance = new TerminateEmployee();
  268. }
  269. return this.instance;
  270. }
  271. }
  272. PayRun.TerminateEmployee = TerminateEmployee;
  273. })(PayRun = Controls.PayRun || (Controls.PayRun = {}));
  274. })(Controls = Payroll.Controls || (Payroll.Controls = {}));
  275. })(Payroll = Hrms.Payroll || (Hrms.Payroll = {}));
  276. })(Hrms = Apps.Hrms || (Apps.Hrms = {}));
  277. })(Apps = Bizgaze.Apps || (Bizgaze.Apps = {}));
  278. })(Bizgaze || (Bizgaze = {}));