rpt_custom.js 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  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, id) {
  13. const html = [];
  14. html.push('<select style="width: 80%" id="' + id + '" sf-title="' + select.title + '">');
  15. for (const sf of stageFlow) {
  16. html.push('<option>' + sf.name + '-' + sf.role +'</option>');
  17. }
  18. html.push('</select>');
  19. return html.join('');
  20. };
  21. const checkAsSelectValid = function (validFlow, asSelect) {
  22. for (const s of asSelect) {
  23. const f = validFlow.find(function (x) {
  24. return x.aid === s.aid && x.order === s.order;
  25. });
  26. if (!f) {
  27. $('#audit-select-hint').html('本期审批流程发生变动,原审批人选择不适配,需重新选择').show();
  28. return false;
  29. }
  30. }
  31. $('#audit-select-hint').hide();
  32. return true;
  33. };
  34. const initAuditSelect = function (asSetting, asSelect) {
  35. const setting = JSON.parse(asSetting), select = asSelect;
  36. $('#audit-select-title').html(setting.title);
  37. const html = [];
  38. for (const [i, s] of setting.select.entries()) {
  39. html.push('<tr>');
  40. html.push('<td>', s.title, '</td>');
  41. html.push('<td>', getStageFlowSelectHtml(s, 'sf-' + i), '</td>');
  42. html.push('</tr>');
  43. }
  44. $('#audit-select-list').html(html.join(''));
  45. for (const [i, s] of setting.select.entries()) {
  46. const obj = $('#sf-' + i);
  47. const s = select[i];
  48. const sf = s ? stageFlow.find(function (x) {
  49. return x.order === s.order && x.aid === s.aid;
  50. }) : null;
  51. obj[0].selectedIndex = sf ? sf.order : -1;
  52. }
  53. if (asSelect.length === 0 || !checkAsSelectValid(stageFlow, asSelect)) {
  54. $('#audit-select').modal('show');
  55. }
  56. };
  57. const init = function (cDefine, sfData, cSelect) {
  58. stageFlow = sfData;
  59. if (cDefine && cDefine[sAuditSelect] && cDefine[sAuditSelect].enable && cDefine[sAuditSelect].setting) {
  60. $('#pnl_audit_select').show();
  61. initAuditSelect(cDefine[sAuditSelect].setting, cSelect ? cSelect.audit_select : []);
  62. } else {
  63. $('#pnl_audit_select').hide();
  64. }
  65. };
  66. const reloadReportData = function (result) {
  67. // hintBox.unWaitBox();
  68. let pageRst = result.data;
  69. if (result.signatureRelInfo && result.signatureRelInfo.length > 0) {
  70. CURRENT_ROLE_REL_ID = result.signatureRelInfo[0].id;
  71. ROLE_REL_LIST = zTreeOprObj._parseRoleRelList(result.signatureRelInfo[0].rel_content);
  72. STAGE_AUDIT = result.stageAudit;
  73. rptSignatureHelper.originalRoleRelList = zTreeOprObj._parseRoleRelList(result.signatureRelInfo[0].rel_content);
  74. if (current_stage_status === 3) {
  75. rptSignatureHelper.mergeSignDate(pageRst);
  76. rptSignatureHelper.mergeSignature(pageRst);
  77. }
  78. } else {
  79. CURRENT_ROLE_REL_ID = -1;
  80. ROLE_REL_LIST = [];
  81. }
  82. // if (ROLE_REL_LIST)
  83. let canvas = zTreeOprObj.canvas;
  84. if (pageRst && pageRst.items && pageRst.items.length > 0) {
  85. zTreeOprObj.resetAfter(pageRst);
  86. zTreeOprObj.currentRptPageRst = pageRst;
  87. zTreeOprObj.maxPages = pageRst.items.length;
  88. zTreeOprObj.currentPage = 1;
  89. zTreeOprObj.displayPageValue();
  90. let size = JpcCanvasOutput.getReportSizeInPixel(zTreeOprObj.currentRptPageRst, getScreenDPI());
  91. canvas.width = size[0] + 20;
  92. if (size[1] > size[0]) {
  93. canvas.height = size[1] + 100;
  94. } else {
  95. canvas.height = size[1] + 50;
  96. }
  97. // zTreeOprObj.resetESignature(zTreeOprObj.currentRptPageRst);
  98. rptSignatureHelper.buildSelectableAccount();
  99. rptSignatureHelper.buildSelectableAccountUsed();
  100. rptSignatureHelper.buildRoleDom(ROLE_LIST);
  101. zTreeOprObj.showPage(1, canvas);
  102. } else {
  103. //返回了无数据表
  104. JpcCanvasOutput.cleanCanvas(canvas);
  105. JpcCanvasOutput.drawPageBorder(zTreeOprObj.currentRptPageRst, canvas, getScreenDPI());
  106. }
  107. rptCustomObj.init(result.customDefine, result.stageFlow, result.customSelect);
  108. try {
  109. if (is_debug && result.debugInfo) {
  110. console.log('含有key的debug信息:');
  111. for (const k in result.debugInfo.key) {
  112. console.log(k + ':', ...result.debugInfo.key[k]);
  113. }
  114. //console.log(result.debugInfo.key);
  115. console.log('其他debug信息:');
  116. for (const di of result.debugInfo.other) {
  117. console.log(...di);
  118. }
  119. }
  120. } catch(err) {
  121. }
  122. };
  123. const resetAuditSelect = function () {
  124. const selObj = $('select', '#audit-select-list');
  125. const data = { audit_select: [] };
  126. data.pageSize = rptControlObj.getCurrentPageSize();
  127. data.orientation = rptControlObj.getCurrentOrientation();
  128. data.rpt_tpl_id = zTreeOprObj.currentNode.refId;
  129. data.custCfg = CUST_CFG;
  130. data.project_id = PROJECT_ID;
  131. data.tender_id = TENDER_ID;
  132. data.stage_id = getStageId();
  133. data.stage_status = getStageStatus();
  134. data.stage_order = getStageOrder();
  135. data.stage_times = getStageTimes();
  136. for (const s of selObj) {
  137. const sf = stageFlow[s.selectedIndex];
  138. if (!sf) {
  139. $('#audit-select-hint').html('未选择' + s.attributes['sf-title'].value).show();
  140. return;
  141. }
  142. data.audit_select.push(sf);
  143. }
  144. $('#audit-select-hint').hide();
  145. postData('/report/cDefine', data, function (result) {
  146. reloadReportData(result);
  147. $('#audit-select').modal('hide');
  148. });
  149. };
  150. return {init, resetAuditSelect};
  151. })();