rpt_change.js 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. /**
  2. * Created by Tony on 2024/02/07.
  3. * 这个跟 rpt_change_rela不同,那个不是我写的,不去干扰
  4. * 本文件处理跟变更令报表相关的操作
  5. */
  6. 'use strict'
  7. const rptChangeObj = {
  8. initBglList: function() {
  9. // 初始化变更令ID值 ALL_CHANGES bglKeyVals
  10. if (ALL_CHANGES) {
  11. const $bglDivDom = $('#bglKeyVals');
  12. $bglDivDom.empty();
  13. let content = [];
  14. ALL_CHANGES.forEach((change, index) => {
  15. // 审批通过的才显示
  16. if (change.status === 3) content.push(`<a class="dropdown-item" href="javascript: void(0)" onclick="rptChangeObj.changeBglId('${index}');">${change.code}</a>`);
  17. });
  18. $bglDivDom.append(content);
  19. }
  20. },
  21. changeBglId: function(index) {
  22. const change = ALL_CHANGES[index];
  23. alert(change.cid);
  24. if (zTreeOprObj.currentRptPageRst && zTreeOprObj.currentRptPageRst.splitArcPagesInfo && zTreeOprObj.currentRptPageRst.splitArcPages) {
  25. let pgAccAmt = 0;
  26. for (let idx = 0; idx < zTreeOprObj.currentRptPageRst.splitArcPages.length; idx++) {
  27. const pgArcVal = zTreeOprObj.currentRptPageRst.splitArcPages[idx];
  28. const pgInfoVals = zTreeOprObj.currentRptPageRst.splitArcPagesInfo.splitPageValues[idx];
  29. // 根据3种数据(id、code、name)来判断输出哪个页面
  30. if (pgInfoVals[0] === change.cid || pgInfoVals[0] === change.code || pgInfoVals[0] === change.name) {
  31. // 这里判断3种值(考虑到这3种值的差别极大,应该不会有重合的情况)
  32. const firstPage = pgArcVal;
  33. let lastPage = zTreeOprObj.currentRptPageRst.items.length;
  34. if (idx < zTreeOprObj.currentRptPageRst.splitArcPages.length - 1) {
  35. lastPage = zTreeOprObj.currentRptPageRst.splitArcPages[idx + 1];
  36. }
  37. this.sliceRptData(zTreeOprObj.currentRptPageRst, firstPage, lastPage);
  38. this.refreshPage(zTreeOprObj.currentRptPageRst);
  39. break;
  40. } else {
  41. pgAccAmt = pgArcVal;
  42. }
  43. }
  44. }
  45. },
  46. refreshPage: function(pageData) {
  47. // 刷新页面(重新调整页码数量)
  48. zTreeOprObj.maxPages = zTreeOprObj.currentRptPageRst.items.length;
  49. zTreeOprObj.currentPage = 1;
  50. zTreeOprObj.displayPageValue();
  51. zTreeOprObj.showPage(1, zTreeOprObj.canvas);
  52. },
  53. prepareRawData: function(pageDatas) {
  54. const _prepareRawData = function(pageData) {
  55. if (!pageData.bk_items) pageData.bk_items = pageData.items;
  56. };
  57. // 这里pageDatas可以是勾选多个的也可以是单个选择
  58. if (pageDatas instanceof Array) {
  59. _prepareRawData(pageDatas);
  60. } else {
  61. pageDatas.forEach(pageData => {
  62. _prepareRawData(pageData);
  63. });
  64. }
  65. },
  66. restoreRawData: function(pageDatas) {
  67. const _restoreRawData = function(pageData) {
  68. if (!pageData.bk_items) pageData.items = pageData.bk_items;
  69. };
  70. // 这里pageDatas可以是勾选多个的也可以是单个选择
  71. if (pageDatas instanceof Array) {
  72. _restoreRawData(pageDatas);
  73. } else {
  74. pageDatas.forEach(pageData => {
  75. _restoreRawData(pageData);
  76. });
  77. }
  78. },
  79. sliceRptData: function(pageData, firstPage, lastPage) {
  80. if (pageData.bk_items && firstPage > 0 && lastPage <= pageData.bk_items.length) {
  81. pageData.items = pageData.bk_items.slice(firstPage - 1, lastPage);
  82. return true;
  83. }
  84. return false;
  85. }
  86. };