let JV = require('./jpc_value_define'); let JpcFieldHelper = require('./helper/jpc_helper_field'); let JpcBandHelper = require('./helper/jpc_helper_band'); let JpcBand = require('./jpc_band'); let JpcFlowTabHelper = require('./helper/jpc_helper_flow_tab'); let JpcCommonHelper = require('./helper/jpc_helper_common'); let JpcDiscreteHelper = require('./helper/jpc_helper_discrete'); let JpcTextHelper = require('./helper/jpc_helper_text'); let JpcCommonOutputHelper = require('./helper/jpc_helper_common_output'); let JpcAreaHelper = require('./helper/jpc_helper_area'); let JpcBillTabSrv = function(){}; JpcBillTabSrv.prototype.createNew = function(){ let JpcBillTabResult = {}; JpcBillTabResult.initialize = function() { let me = this; me.disp_fields_idx = []; }; JpcBillTabResult.sorting = function(rptTpl) { let me = this; JpcFieldHelper.findAndPutDataFieldIdx(rptTpl, rptTpl[JV.NODE_BILL_INFO][JV.NODE_BILL_CONTENT][JV.PROP_BILL_FIELDS], null, me.disp_fields_idx); }; JpcBillTabResult.outputAsSimpleJSONPage = function (rptTpl, dataObj, page, bands, controls, $CURRENT_RPT) { let me = this, rst = [], tabRstLst = []; //1 calculate the band position let pageStatus = [true, false, false, false, false, false, false, false]; JpcBandHelper.setBandArea(bands, rptTpl, pageStatus); //2. start to output detail-part let unitFactor = JpcCommonHelper.getUnitFactor(rptTpl); //2.1 output content tabRstLst.push(me.outputContent(rptTpl, dataObj, page, bands, unitFactor, controls, pageStatus)); //2.2 output discrete tabRstLst.push(JpcDiscreteHelper.outputDiscreteInfo(rptTpl[JV.NODE_BILL_INFO][JV.NODE_DISCRETE_INFO], bands, dataObj, unitFactor, pageStatus, page - 1, 1, 0, $CURRENT_RPT)); } JpcBillTabResult.outputContent = function(rptTpl, dataObj, page, bands, unitFactor, controls, pageStatus) { let me = this, rst = []; let tab = rptTpl[JV.NODE_BILL_INFO][JV.NODE_BILL_CONTENT]; let band = bands[tab[JV.PROP_BAND_NAME]]; if (band) { if (pageStatus[band[JV.BAND_PROP_DISPLAY_TYPE]] == true) { let tab_fields = tab[JV.PROP_BILL_FIELDS]; let data_details = dataObj[JV.DATA_MASTER_DATA]; for (let i = 0; i < tab_fields.length; i++) { let tab_field = tab_fields[i]; let data_field = null; if (me.disp_fields_idx[i] != JV.BLANK_FIELD_INDEX) { data_field = data_details[me.disp_fields_idx[i]]; } else { data_field = JE.F(tab_field[JV.PROP_FIELD_ID]); if (data_field) { data_field = data_field[JV.PROP_AD_HOC_DATA]; } } if (!(tab_field[JV.PROP_HIDDEN])) { let cellItem = JpcCommonOutputHelper.createCommonOutput(tab_field, JpcFieldHelper.getValue(data_field, page - 1), controls); cellItem[JV.PROP_AREA] = JpcAreaHelper.outputArea(tab_field[JV.PROP_AREA], band, unitFactor, 1, 0, 1, 0, 1, 0, true, false); rst.push(cellItem); } } if (tab[JV.PROP_TEXT]) { rst.push(JpcTextHelper.outputText(tab[JV.PROP_TEXT], band, unitFactor, 1, 0, 1, 0, 1, 0)); } if (tab[JV.PROP_TEXTS]) { for (let j = 0; j < tab[JV.PROP_TEXTS].length; j++) { rst.push(JpcTextHelper.outputText(tab[JV.PROP_TEXTS][j], band, unitFactor, 1, 0, 1, 0, 1, 0)); } } if (tab[JV.NODE_DISCRETE_INFO]) { rst = rst.concat(JpcDiscreteHelper.outputDiscreteInfo(tab[JV.NODE_DISCRETE_INFO], bands, dataObj, unitFactor, pageStatus, page - 1, 1, 0)); } } } return rst; } return JpcBillTabResult; } module.exports = new JpcBillTabSrv();