rpt_custom.js 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  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' + (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. };
  33. const init = function (cDefine, sfData, cSelect) {
  34. stageFlow = sfData;
  35. if (cDefine && cDefine.enable && cDefine[sAuditSelect] && cDefine[sAuditSelect] !== '') {
  36. $('#pnl_audit_select').show();
  37. initAuditSelect(cDefine[sAuditSelect].setting, cSelect.audit_select);
  38. } else {
  39. $('#pnl_audit_select').hide();
  40. }
  41. };
  42. const reloadReportData = function (result) {
  43. // hintBox.unWaitBox();
  44. let pageRst = result.data;
  45. if (result.signatureRelInfo && result.signatureRelInfo.length > 0) {
  46. CURRENT_ROLE_REL_ID = result.signatureRelInfo[0].id;
  47. ROLE_REL_LIST = zTreeOprObj._parseRoleRelList(result.signatureRelInfo[0].rel_content);
  48. STAGE_AUDIT = result.stageAudit;
  49. rptSignatureHelper.originalRoleRelList = zTreeOprObj._parseRoleRelList(result.signatureRelInfo[0].rel_content);
  50. if (current_stage_status === 3) {
  51. rptSignatureHelper.mergeSignDate(pageRst);
  52. rptSignatureHelper.mergeSignature(pageRst);
  53. }
  54. } else {
  55. CURRENT_ROLE_REL_ID = -1;
  56. ROLE_REL_LIST = [];
  57. }
  58. // if (ROLE_REL_LIST)
  59. let canvas = zTreeOprObj.canvas;
  60. if (pageRst && pageRst.items && pageRst.items.length > 0) {
  61. zTreeOprObj.resetAfter(pageRst);
  62. zTreeOprObj.currentRptPageRst = pageRst;
  63. zTreeOprObj.maxPages = pageRst.items.length;
  64. zTreeOprObj.currentPage = 1;
  65. zTreeOprObj.displayPageValue();
  66. let size = JpcCanvasOutput.getReportSizeInPixel(zTreeOprObj.currentRptPageRst, getScreenDPI());
  67. canvas.width = size[0] + 20;
  68. if (size[1] > size[0]) {
  69. canvas.height = size[1] + 100;
  70. } else {
  71. canvas.height = size[1] + 50;
  72. }
  73. // zTreeOprObj.resetESignature(zTreeOprObj.currentRptPageRst);
  74. rptSignatureHelper.buildSelectableAccount();
  75. rptSignatureHelper.buildSelectableAccountUsed();
  76. rptSignatureHelper.buildRoleDom(ROLE_LIST);
  77. zTreeOprObj.showPage(1, canvas);
  78. } else {
  79. //返回了无数据表
  80. JpcCanvasOutput.cleanCanvas(canvas);
  81. JpcCanvasOutput.drawPageBorder(zTreeOprObj.currentRptPageRst, canvas, getScreenDPI());
  82. }
  83. rptCustomObj.init(result.customDefine, result.stageFlow, result.customSelect);
  84. try {
  85. if (is_debug && result.debugInfo) {
  86. console.log('含有key的debug信息:');
  87. for (const k in result.debugInfo.key) {
  88. console.log(k + ':', ...result.debugInfo.key[k]);
  89. }
  90. //console.log(result.debugInfo.key);
  91. console.log('其他debug信息:');
  92. for (const di of result.debugInfo.other) {
  93. console.log(...di);
  94. }
  95. }
  96. } catch(err) {
  97. }
  98. };
  99. const resetAuditSelect = function () {
  100. const selObj = $('select', '#audit-select-list');
  101. const data = { audit_select: [] };
  102. data.pageSize = rptControlObj.getCurrentPageSize();
  103. data.orientation = rptControlObj.getCurrentOrientation();
  104. data.rpt_tpl_id = zTreeOprObj.currentNode.refId;
  105. data.custCfg = CUST_CFG;
  106. data.project_id = PROJECT_ID;
  107. data.tender_id = TENDER_ID;
  108. data.stage_id = getStageId();
  109. data.stage_status = getStageStatus();
  110. data.stage_order = getStageOrder();
  111. data.stage_times = getStageTimes();
  112. for (const s of selObj) {
  113. data.audit_select.push(stageFlow[s.selectedIndex]);
  114. }
  115. postData('/report/cDefine', data, function (result) {
  116. reloadReportData(result);
  117. $('#audit-select').modal('hide');
  118. });
  119. };
  120. return {init, resetAuditSelect};
  121. })();