rpt_change.js 3.8 KB

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