jpc_bill_tab.js 4.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. let JV = require('./jpc_value_define');
  2. let JpcFieldHelper = require('./helper/jpc_helper_field');
  3. let JpcBandHelper = require('./helper/jpc_helper_band');
  4. let JpcBand = require('./jpc_band');
  5. let JpcFlowTabHelper = require('./helper/jpc_helper_flow_tab');
  6. let JpcCommonHelper = require('./helper/jpc_helper_common');
  7. let JpcDiscreteHelper = require('./helper/jpc_helper_discrete');
  8. let JpcTextHelper = require('./helper/jpc_helper_text');
  9. let JpcCommonOutputHelper = require('./helper/jpc_helper_common_output');
  10. let JpcAreaHelper = require('./helper/jpc_helper_area');
  11. let JpcBillTabSrv = function(){};
  12. JpcBillTabSrv.prototype.createNew = function(){
  13. let JpcBillTabResult = {};
  14. JpcBillTabResult.initialize = function() {
  15. let me = this;
  16. me.disp_fields_idx = [];
  17. };
  18. JpcBillTabResult.sorting = function(rptTpl) {
  19. let me = this;
  20. JpcFieldHelper.findAndPutDataFieldIdx(rptTpl, rptTpl[JV.NODE_BILL_INFO][JV.NODE_BILL_CONTENT][JV.PROP_BILL_FIELDS], null, me.disp_fields_idx);
  21. };
  22. JpcBillTabResult.paging = function(rptTpl) {
  23. let me = this, rst = 0;
  24. let detail_fields = rptTpl[JV.NODE_FIELD_MAP][JV.NODE_DETAIL_FIELDS];
  25. if (detail_fields && detail_fields.length > 0) {
  26. rst = detail_fields[0].length;
  27. }
  28. return rst;
  29. };
  30. JpcBillTabResult.outputAsSimpleJSONPage = function (rptTpl, dataObj, page, bands, controls, $CURRENT_RPT) {
  31. let me = this, rst = [], tabRstLst = [];
  32. //1 calculate the band position
  33. let pageStatus = [true, false, false, false, false, false, false, false];
  34. JpcBandHelper.setBandArea(bands, rptTpl, pageStatus);
  35. //2. start to output detail-part
  36. let unitFactor = JpcCommonHelper.getUnitFactor(rptTpl);
  37. //2.1 output content
  38. tabRstLst.push(me.outputContent(rptTpl, dataObj, page, bands, unitFactor, controls, pageStatus));
  39. //2.2 output discrete
  40. tabRstLst.push(JpcDiscreteHelper.outputDiscreteInfo(rptTpl[JV.NODE_BILL_INFO][JV.NODE_DISCRETE_INFO], bands, dataObj, unitFactor, pageStatus, page - 1, 1, 0, $CURRENT_RPT));
  41. }
  42. JpcBillTabResult.outputContent = function(rptTpl, dataObj, page, bands, unitFactor, controls, pageStatus) {
  43. let me = this, rst = [];
  44. let tab = rptTpl[JV.NODE_BILL_INFO][JV.NODE_BILL_CONTENT];
  45. let band = bands[tab[JV.PROP_BAND_NAME]];
  46. if (band) {
  47. if (pageStatus[band[JV.BAND_PROP_DISPLAY_TYPE]] == true) {
  48. let tab_fields = tab[JV.PROP_BILL_FIELDS];
  49. let data_details = dataObj[JV.DATA_MASTER_DATA];
  50. for (let i = 0; i < tab_fields.length; i++) {
  51. let tab_field = tab_fields[i];
  52. let data_field = null;
  53. if (me.disp_fields_idx[i] != JV.BLANK_FIELD_INDEX) {
  54. data_field = data_details[me.disp_fields_idx[i]];
  55. } else {
  56. data_field = JE.F(tab_field[JV.PROP_FIELD_ID]);
  57. if (data_field) {
  58. data_field = data_field[JV.PROP_AD_HOC_DATA];
  59. }
  60. }
  61. if (!(tab_field[JV.PROP_HIDDEN])) {
  62. let cellItem = JpcCommonOutputHelper.createCommonOutput(tab_field, JpcFieldHelper.getValue(data_field, page - 1), controls);
  63. cellItem[JV.PROP_AREA] = JpcAreaHelper.outputArea(tab_field[JV.PROP_AREA], band, unitFactor, 1, 0, 1, 0, 1, 0, true, false);
  64. rst.push(cellItem);
  65. }
  66. }
  67. if (tab[JV.PROP_TEXT]) {
  68. rst.push(JpcTextHelper.outputText(tab[JV.PROP_TEXT], band, unitFactor, 1, 0, 1, 0, 1, 0));
  69. }
  70. if (tab[JV.PROP_TEXTS]) {
  71. for (let j = 0; j < tab[JV.PROP_TEXTS].length; j++) {
  72. rst.push(JpcTextHelper.outputText(tab[JV.PROP_TEXTS][j], band, unitFactor, 1, 0, 1, 0, 1, 0));
  73. }
  74. }
  75. if (tab[JV.NODE_DISCRETE_INFO]) {
  76. rst = rst.concat(JpcDiscreteHelper.outputDiscreteInfo(tab[JV.NODE_DISCRETE_INFO], bands, dataObj, unitFactor, pageStatus, page - 1, 1, 0));
  77. }
  78. }
  79. }
  80. return rst;
  81. }
  82. return JpcBillTabResult;
  83. }
  84. module.exports = new JpcBillTabSrv();