rpt_custom.js 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. 'use strict';
  2. /**
  3. *
  4. *
  5. * @author Mai
  6. * @date
  7. * @version
  8. */
  9. const rptCustomObj = (function () {
  10. const sAuditSelect = 'audit_select';
  11. let stageFlow = [];
  12. const getStageFlowSelectHtml = function (select) {
  13. const html = [];
  14. html.push('<select style="width: 80%">');
  15. for (const sf of stageFlow) {
  16. html.push('<option' + (select && sf.order === select.order ? ' selected' : '') + '>' + sf.name + '-' + sf.role +'</option>');
  17. }
  18. html.push('</select>');
  19. return html.join('');
  20. };
  21. const initAuditSelect = function (asSetting, asSelect) {
  22. const setting = JSON.parse(asSetting), select = asSelect;
  23. $('#audit-select-title').html(setting.title);
  24. const html = [];
  25. for (const [i, s] of setting.select.entries()) {
  26. html.push('<tr>');
  27. html.push('<td>', s.title, '</td>');
  28. html.push('<td>', getStageFlowSelectHtml(select[i]), '</td>');
  29. html.push('</tr>');
  30. }
  31. $('#audit-select-list').html(html.join(''));
  32. if (asSelect.length === 0) {
  33. $('#audit-select').modal('show');
  34. }
  35. };
  36. const init = function (cDefine, sfData, cSelect) {
  37. stageFlow = sfData;
  38. if (cDefine && cDefine[sAuditSelect] && cDefine[sAuditSelect].enable && cDefine[sAuditSelect].setting) {
  39. $('#pnl_audit_select').show();
  40. initAuditSelect(cDefine[sAuditSelect].setting, cSelect ? cSelect.audit_select : []);
  41. } else {
  42. $('#pnl_audit_select').hide();
  43. }
  44. };
  45. const reloadReportData = function (result) {
  46. // hintBox.unWaitBox();
  47. let pageRst = result.data;
  48. if (result.signatureRelInfo && result.signatureRelInfo.length > 0) {
  49. CURRENT_ROLE_REL_ID = result.signatureRelInfo[0].id;
  50. ROLE_REL_LIST = zTreeOprObj._parseRoleRelList(result.signatureRelInfo[0].rel_content);
  51. STAGE_AUDIT = result.stageAudit;
  52. rptSignatureHelper.originalRoleRelList = zTreeOprObj._parseRoleRelList(result.signatureRelInfo[0].rel_content);
  53. if (current_stage_status === 3) {
  54. rptSignatureHelper.mergeSignDate(pageRst);
  55. rptSignatureHelper.mergeSignature(pageRst);
  56. }
  57. } else {
  58. CURRENT_ROLE_REL_ID = -1;
  59. ROLE_REL_LIST = [];
  60. }
  61. // if (ROLE_REL_LIST)
  62. let canvas = zTreeOprObj.canvas;
  63. if (pageRst && pageRst.items && pageRst.items.length > 0) {
  64. zTreeOprObj.resetAfter(pageRst);
  65. zTreeOprObj.currentRptPageRst = pageRst;
  66. zTreeOprObj.maxPages = pageRst.items.length;
  67. zTreeOprObj.currentPage = 1;
  68. zTreeOprObj.displayPageValue();
  69. let size = JpcCanvasOutput.getReportSizeInPixel(zTreeOprObj.currentRptPageRst, getScreenDPI());
  70. canvas.width = size[0] + 20;
  71. if (size[1] > size[0]) {
  72. canvas.height = size[1] + 100;
  73. } else {
  74. canvas.height = size[1] + 50;
  75. }
  76. // zTreeOprObj.resetESignature(zTreeOprObj.currentRptPageRst);
  77. rptSignatureHelper.buildSelectableAccount();
  78. rptSignatureHelper.buildSelectableAccountUsed();
  79. rptSignatureHelper.buildRoleDom(ROLE_LIST);
  80. zTreeOprObj.showPage(1, canvas);
  81. } else {
  82. //返回了无数据表
  83. JpcCanvasOutput.cleanCanvas(canvas);
  84. JpcCanvasOutput.drawPageBorder(zTreeOprObj.currentRptPageRst, canvas, getScreenDPI());
  85. }
  86. rptCustomObj.init(result.customDefine, result.stageFlow, result.customSelect);
  87. try {
  88. if (is_debug && result.debugInfo) {
  89. console.log('含有key的debug信息:');
  90. for (const k in result.debugInfo.key) {
  91. console.log(k + ':', ...result.debugInfo.key[k]);
  92. }
  93. //console.log(result.debugInfo.key);
  94. console.log('其他debug信息:');
  95. for (const di of result.debugInfo.other) {
  96. console.log(...di);
  97. }
  98. }
  99. } catch(err) {
  100. }
  101. };
  102. const resetAuditSelect = function () {
  103. const selObj = $('select', '#audit-select-list');
  104. const data = { audit_select: [] };
  105. data.pageSize = rptControlObj.getCurrentPageSize();
  106. data.orientation = rptControlObj.getCurrentOrientation();
  107. data.rpt_tpl_id = zTreeOprObj.currentNode.refId;
  108. data.custCfg = CUST_CFG;
  109. data.project_id = PROJECT_ID;
  110. data.tender_id = TENDER_ID;
  111. data.stage_id = getStageId();
  112. data.stage_status = getStageStatus();
  113. data.stage_order = getStageOrder();
  114. data.stage_times = getStageTimes();
  115. for (const s of selObj) {
  116. data.audit_select.push(stageFlow[s.selectedIndex]);
  117. }
  118. postData('/report/cDefine', data, function (result) {
  119. reloadReportData(result);
  120. $('#audit-select').modal('hide');
  121. });
  122. };
  123. return {init, resetAuditSelect};
  124. })();