TonyKang 6 lat temu
rodzic
commit
c8a34487da

+ 15 - 9
modules/reports/rpt_component/jpc_cross_tab.js

@@ -195,6 +195,7 @@ JpcCrossTabSrv.prototype.createNew = function(){
         me.dispSumValueLst_Col = [];
         me.page_seg_map = [];
         me.row_fields_idx = [];
+        me.row_fields_adhoc_idx = [];
         me.col_fields_idx = [];
         me.content_fields_idx = [];
         me.row_extension_fields_idx = [];
@@ -207,6 +208,7 @@ JpcCrossTabSrv.prototype.createNew = function(){
         let me = this;
         //IMPORTANT: the data should be sorted in SQL/NoSQL level!
         me.sortedRowSequence = private_SortAndOptimize(rptTpl, dataObj, dataSeq, JV.NODE_CROSS_ROW, me.row_fields_idx, $CURRENT_RPT);
+        private_SortAndOptimize(rptTpl, dataObj, dataSeq, JV.NODE_CROSS_ROW_AD_HOC, me.row_fields_adhoc_idx, $CURRENT_RPT);
         me.sortedColSequence = private_SortAndOptimize(rptTpl, dataObj, dataSeq, JV.NODE_CROSS_COL, me.col_fields_idx, $CURRENT_RPT);
         me.sortedContentSequence = private_SortForDisplayContent(rptTpl, me.sortedRowSequence, me.sortedColSequence, me.content_fields_idx);
         JpcFieldHelper.findAndPutDataFieldIdx(rptTpl, rptTpl[JV.NODE_CROSS_INFO][JV.NODE_CROSS_COL_SUM][JV.PROP_CROSS_FIELDS], null, me.col_sum_fields_idx);
@@ -363,7 +365,9 @@ JpcCrossTabSrv.prototype.createNew = function(){
         return rst;
     };
     JpcCrossTabResult.outputPreviewRowTab = function(rptTpl, bands, controls, $CURRENT_RPT, customizeCfg, maxRowRec, unitFactor) {
-        return this.private_OutputPreviewCommon(rptTpl, bands, controls, $CURRENT_RPT, customizeCfg, maxRowRec, 1, rptTpl[JV.NODE_CROSS_INFO][JV.NODE_CROSS_ROW], unitFactor);
+        let rst = this.private_OutputPreviewCommon(rptTpl, bands, controls, $CURRENT_RPT, customizeCfg, maxRowRec, 1, rptTpl[JV.NODE_CROSS_INFO][JV.NODE_CROSS_ROW], unitFactor);
+        rst = rst.concat(this.private_OutputPreviewCommon(rptTpl, bands, controls, $CURRENT_RPT, customizeCfg, maxRowRec, 1, rptTpl[JV.NODE_CROSS_INFO][JV.NODE_CROSS_ROW_AD_HOC], unitFactor));
+        return rst;
     };
     JpcCrossTabResult.outputPreviewColTab = function(rptTpl, bands, controls, $CURRENT_RPT, customizeCfg, maxColRec, unitFactor) {
         return this.private_OutputPreviewCommon(rptTpl, bands, controls, $CURRENT_RPT, customizeCfg, 1, maxColRec, rptTpl[JV.NODE_CROSS_INFO][JV.NODE_CROSS_COL], unitFactor);
@@ -384,7 +388,7 @@ JpcCrossTabSrv.prototype.createNew = function(){
     };
     JpcCrossTabResult.private_OutputPreviewCommon = function(rptTpl, bands, controls, $CURRENT_RPT, customizeCfg, maxRowRec, maxColRec, tab, unitFactor) {
         let me = this, rst = [];
-        let band = bands[tab[JV.PROP_BAND_NAME]];
+        let band = (tab)?bands[tab[JV.PROP_BAND_NAME]]:null;
         if (band) {
             let tab_fields = tab[JV.PROP_CROSS_FIELDS];
             for (let rowIdx = 0; rowIdx < maxRowRec; rowIdx++) {
@@ -449,7 +453,9 @@ JpcCrossTabSrv.prototype.createNew = function(){
             JpcBandHelper.setBandArea(bands, rptTpl, me.pageStatusLst[page - 1]);
             //2. start to output detail-part
             //2.1 Row-Tab
-            tabRstLst.push(me.outputRowTab(rptTpl, dataObj, page, bands, unitFactor, controls, $CURRENT_RPT, customizeCfg));
+            //tabRstLst.push(me.outputRowTab(rptTpl, dataObj, page, bands, unitFactor, controls, $CURRENT_RPT, customizeCfg));
+            tabRstLst.push(me.outputRowTabCommon(rptTpl, dataObj, page, bands, JV.NODE_CROSS_ROW, me.row_fields_idx, unitFactor, controls, $CURRENT_RPT, customizeCfg));
+            tabRstLst.push(me.outputRowTabCommon(rptTpl, dataObj, page, bands, JV.NODE_CROSS_ROW_AD_HOC, me.row_fields_adhoc_idx, unitFactor, controls, $CURRENT_RPT, customizeCfg));
             //2.2 Col-Tab
             tabRstLst.push(me.outputColTab(rptTpl, dataObj, page, bands, unitFactor, controls, $CURRENT_RPT, customizeCfg));
             //2.3 Content-Tab
@@ -469,10 +475,10 @@ JpcCrossTabSrv.prototype.createNew = function(){
         }
         return rst;
     };
-    JpcCrossTabResult.outputRowTab = function(rptTpl, dataObj, page, bands, unitFactor, controls, $CURRENT_RPT, customizeCfg) {
+    JpcCrossTabResult.outputRowTabCommon = function(rptTpl, dataObj, page, bands, tabStr, rowFieldsIdxArr, unitFactor, controls, $CURRENT_RPT, customizeCfg) {
         let me = this, rst = [];
-        let tab = rptTpl[JV.NODE_CROSS_INFO][JV.NODE_CROSS_ROW];
-        let band = bands[tab[JV.PROP_BAND_NAME]];
+        let tab = rptTpl[JV.NODE_CROSS_INFO][tabStr];
+        let band = (tab)?bands[tab[JV.PROP_BAND_NAME]]:null;
         if (band) {
             let pageStatus = me.pageStatusLst[page - 1];
             if (pageStatus[band[JV.BAND_PROP_DISPLAY_TYPE]] === true) {
@@ -481,13 +487,13 @@ JpcCrossTabSrv.prototype.createNew = function(){
                 let valuesIdx = me.dispValueIdxLst_Row[page - 1];
                 let serialsIdx = me.dispSerialIdxLst_Row[page - 1];
                 let flexiblePrecisionRefObj = null, flexibleRefField = null, precision_ref_data = null;
-                for (let i = 0; i < me.row_fields_idx.length; i++) {
+                for (let i = 0; i < rowFieldsIdxArr.length; i++) {
                     let tab_field = tab_fields[i];
                     if (!(tab_field[JV.PROP_HIDDEN])) {
                         let data_field = null;
                         let map_data_field = JE.F(tab_field[JV.PROP_FIELD_ID], $CURRENT_RPT);
-                        if (typeof me.row_fields_idx[i] !== 'object') {
-                            data_field = data_details[me.row_fields_idx[i]];
+                        if (typeof rowFieldsIdxArr[i] !== 'object') {
+                            data_field = data_details[rowFieldsIdxArr[i]];
                         } else {
                             if (map_data_field) {
                                 data_field = map_data_field[JV.PROP_AD_HOC_DATA];

+ 23 - 7
modules/reports/rpt_component/jpc_ex.js

@@ -249,6 +249,18 @@ JpcExSrv.prototype.createNew = function(){
         rst.items = [];
         let bands = JpcBand.createNew(rptTpl, defProperties);
         try {
+            function getPageMergeBorder() {
+                let mergeRst = null;
+                if (bands[JV.BAND_PROP_MERGE_BAND]) {
+                    let mergedBand = bands[JV.BAND_PROP_MERGE_BAND];
+                    mergeRst = {};
+                    mergeRst[JV.PROP_LEFT] = parseInt(mergedBand[JV.PROP_LEFT].toFixed(0));
+                    mergeRst[JV.PROP_RIGHT] = parseInt(mergedBand[JV.PROP_RIGHT].toFixed(0));
+                    mergeRst[JV.PROP_TOP] = parseInt(mergedBand[JV.PROP_TOP].toFixed(0));
+                    mergeRst[JV.PROP_BOTTOM] = parseInt(mergedBand[JV.PROP_BOTTOM].toFixed(0));
+                }
+                return mergeRst;
+            }
             //1.
             let rstPage = {};
             rstPage[JV.PROP_PAGE_SEQ] = 1;
@@ -259,6 +271,10 @@ JpcExSrv.prototype.createNew = function(){
             } else if (me.billTab) {
                 rstPage[JV.PROP_CELLS] = me.billTab.outputAsPreviewPage(rptTpl, bands, rst[JV.NODE_CONTROL_COLLECTION], me);
             }
+            let pageMergeBorder = getPageMergeBorder();
+            if (pageMergeBorder) {
+                rstPage[JV.PROP_PAGE_MERGE_BORDER] = pageMergeBorder;
+            }
             rst.items.push(rstPage);
             //2.
             if (bands[JV.BAND_PROP_MERGE_BAND]) {
@@ -315,16 +331,16 @@ JpcExSrv.prototype.createNew = function(){
     JpcResult.outputAsSimpleJSONPage = function(rptTpl, dataObj, bands, page, controls, customizeCfg) {
         let me = this, rst = null;
         function getPageMergeBorder() {
-            let rst = null;
+            let mergeRst = null;
             if (bands[JV.BAND_PROP_MERGE_BAND]) {
                 let mergedBand = bands[JV.BAND_PROP_MERGE_BAND];
-                rst = {};
-                rst[JV.PROP_LEFT] = parseInt(mergedBand[JV.PROP_LEFT].toFixed(0));
-                rst[JV.PROP_RIGHT] = parseInt(mergedBand[JV.PROP_RIGHT].toFixed(0));
-                rst[JV.PROP_TOP] = parseInt(mergedBand[JV.PROP_TOP].toFixed(0));
-                rst[JV.PROP_BOTTOM] = parseInt(mergedBand[JV.PROP_BOTTOM].toFixed(0));
+                mergeRst = {};
+                mergeRst[JV.PROP_LEFT] = parseInt(mergedBand[JV.PROP_LEFT].toFixed(0));
+                mergeRst[JV.PROP_RIGHT] = parseInt(mergedBand[JV.PROP_RIGHT].toFixed(0));
+                mergeRst[JV.PROP_TOP] = parseInt(mergedBand[JV.PROP_TOP].toFixed(0));
+                mergeRst[JV.PROP_BOTTOM] = parseInt(mergedBand[JV.PROP_BOTTOM].toFixed(0));
             }
-            return rst;
+            return mergeRst;
         }
         if (me.totalPages >= page) {
             rst = {};