Ver código fonte

code sync for preview

TonyKang 7 anos atrás
pai
commit
c8046b0ef0

+ 22 - 4
modules/reports/rpt_component/helper/jpc_helper_discrete.js

@@ -10,7 +10,7 @@ let JpcDiscreteHelper = {
         if (discreteArray && dataObj) {
             for (let i = 0; i < discreteArray.length; i++) {
                 let band = bands[discreteArray[i][JV.PROP_BAND_NAME]];
-                if (band && pageStatus[band[JV.BAND_PROP_DISPLAY_TYPE]] == true) {
+                if (band && pageStatus[band[JV.BAND_PROP_DISPLAY_TYPE]] === true) {
                     if (discreteArray[i][JV.PROP_TEXT]) {
                         rst.push(JpcTextHelper.outputText(discreteArray[i][JV.PROP_TEXT], band, unitFactor, 1, 0, 1, 0, multiCols, multiColIdx));
                     }
@@ -25,7 +25,7 @@ let JpcDiscreteHelper = {
                             let value = "";
                             if (df[JV.PROP_FIELD_ID]) {
                                 let field = JE.F(df[JV.PROP_FIELD_ID], $CURRENT_RPT);
-                                if (field.DataSeq != JV.BLANK_FIELD_INDEX) {
+                                if (field.DataSeq !== JV.BLANK_FIELD_INDEX) {
                                     let data = dataObj[field.DataNodeName][field.DataSeq];
                                     if (data && data.length > 0) {
                                         if (data.length > segIdx) {
@@ -35,8 +35,9 @@ let JpcDiscreteHelper = {
                                         }
                                     }
                                 } else {
-                                    if (field[JV.PROP_AD_HOC_DATA] && field[JV.PROP_AD_HOC_DATA].length > 0) value = field[JV.PROP_AD_HOC_DATA][0]
-                                    else value = "";
+                                    if (field[JV.PROP_AD_HOC_DATA] && field[JV.PROP_AD_HOC_DATA].length > 0) {
+                                        value = field[JV.PROP_AD_HOC_DATA][0]
+                                    } else value = "";
                                 }
                             } else if (df[JV.PROP_PARAM_ID]) {
                                 let param = JE.P(df[JV.PROP_PARAM_ID], $CURRENT_RPT);
@@ -52,6 +53,23 @@ let JpcDiscreteHelper = {
             }
         }
         return rst;
+    },
+    outputPreviewDiscreteInfo: function (discreteArray, bands, unitFactor, pageStatus) {
+        let rst = [];
+        for (let i = 0; i < discreteArray.length; i++) {
+            let band = bands[discreteArray[i][JV.PROP_BAND_NAME]];
+            if (band && pageStatus[band[JV.BAND_PROP_DISPLAY_TYPE]] === true) {
+                if (discreteArray[i][JV.PROP_TEXT]) {
+                    rst.push(JpcTextHelper.outputText(discreteArray[i][JV.PROP_TEXT], band, unitFactor, 1, 0, 1, 0, 1, 0));
+                }
+                if (discreteArray[i][JV.PROP_TEXTS]) {
+                    for (let j = 0; j < discreteArray[i][JV.PROP_TEXTS].length; j++) {
+                        rst.push(JpcTextHelper.outputText(discreteArray[i][JV.PROP_TEXTS][j], band, unitFactor, 1, 0, 1, 0, 1, 0));
+                    }
+                }
+            }
+        }
+        return rst;
     }
 }
 

+ 26 - 0
modules/reports/rpt_component/jpc_bill_tab.js

@@ -40,6 +40,32 @@ JpcBillTabSrv.prototype.createNew = function(){
         }
         return rst;
     };
+    JpcBillTabResult.outputAsPreviewPage = function (rptTpl, bands, controls, $CURRENT_RPT) {
+        let me = this, rst = [], vIdx = [];
+        //只预览第一页的数据
+        let pageStatus = [true, true, false, true, false, false, false, false];
+        JpcBandHelper.setBandArea(bands, rptTpl, pageStatus, true, false);
+        let unitFactor = JpcCommonHelper.getUnitFactor(rptTpl);
+        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]]) {
+                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.push(JpcDiscreteHelper.outputPreviewDiscreteInfo(tab[JV.NODE_DISCRETE_INFO], bands, unitFactor, pageStatus, page - 1, 1, 0));
+                }
+            }
+        }
+        rst.push(JpcDiscreteHelper.outputPreviewDiscreteInfo(rptTpl[JV.NODE_BILL_INFO][JV.NODE_DISCRETE_INFO], bands, unitFactor, pageStatus));
+        return rst;
+    };
     JpcBillTabResult.outputAsSimpleJSONPage = function (rptTpl, dataObj, page, bands, controls, $CURRENT_RPT) {
         let me = this, rst = [], tabRstLst = [];
         //1 calculate the band position

+ 5 - 0
modules/reports/rpt_component/jpc_cross_tab.js

@@ -320,6 +320,11 @@ JpcCrossTabSrv.prototype.createNew = function(){
         bands = null;
         return rst;
     };
+    JpcCrossTabResult.outputAsPreviewPage = function (rptTpl, bands, controls, $CURRENT_RPT) {
+        let me = this, rst = [];
+        //...
+        return rst;
+    };
     JpcCrossTabResult.outputAsSimpleJSONPage = function(rptTpl, dataObj, page, bands, controls, $CURRENT_RPT) {
         let me = this, rst = [], tabRstLst = [];
         let unitFactor = JpcCommonHelper.getUnitFactor(rptTpl);

+ 40 - 0
modules/reports/rpt_component/jpc_ex.js

@@ -227,6 +227,46 @@ JpcExSrv.prototype.createNew = function(){
             }
         }
     };
+    JpcResult.outputAsPreviewPage= function(rptTpl, defProperties) {
+        let me = this, rst = {};
+        rst[JV.NODE_CONTROL_COLLECTION] = private_buildDftControls(rptTpl, (defProperties === null)?null:defProperties.ctrls);
+        rst[JV.NODE_STYLE_COLLECTION] = private_buildDftStyles(rptTpl, (defProperties === null)?null:defProperties.styles);
+        rst[JV.NODE_FONT_COLLECTION] = private_buildDftFonts(rptTpl, (defProperties === null)?null:defProperties.fonts);
+        rst[JV.NODE_PAGE_INFO] = {};
+        rst[JV.NODE_PAGE_INFO][JV.NODE_MAIN_INFO_RPT_NAME] = rptTpl[JV.NODE_MAIN_INFO][JV.NODE_MAIN_INFO_RPT_NAME];
+        rst[JV.NODE_PAGE_INFO][JV.NODE_PAGE_SIZE] = JpcCommonHelper.getPageSize(rptTpl);
+        rst[JV.NODE_PAGE_INFO][JV.NODE_MARGINS] = rptTpl[JV.NODE_MAIN_INFO][JV.NODE_MARGINS];
+        rst.items = [];
+        let bands = JpcBand.createNew(rptTpl, defProperties);
+        try {
+            //1.
+            let rstPage = {};
+            rstPage[JV.PROP_PAGE_SEQ] = 1;
+            if (me.flowTab) {
+                rstPage[JV.PROP_CELLS] = me.flowTab.outputAsPreviewPage(rptTpl, bands, rst[JV.NODE_CONTROL_COLLECTION], me);
+            } else if (me.crossTab) {
+                rstPage[JV.PROP_CELLS] = me.crossTab.outputAsPreviewPage(rptTpl, bands, rst[JV.NODE_CONTROL_COLLECTION], me);
+            } else if (me.billTab) {
+                rstPage[JV.PROP_CELLS] = me.billTab.outputAsPreviewPage(rptTpl, bands, rst[JV.NODE_CONTROL_COLLECTION], me);
+            }
+            rst.items.push(rstPage);
+            //2.
+            if (bands[JV.BAND_PROP_MERGE_BAND]) {
+                let mergedBand = {}, band = bands[JV.BAND_PROP_MERGE_BAND];
+                mergedBand[JV.PROP_LEFT] = parseInt(band[JV.PROP_LEFT].toFixed(0));
+                mergedBand[JV.PROP_RIGHT] = parseInt(band[JV.PROP_RIGHT].toFixed(0));
+                mergedBand[JV.PROP_TOP] = parseInt(band[JV.PROP_TOP].toFixed(0));
+                mergedBand[JV.PROP_BOTTOM] = parseInt(band[JV.PROP_BOTTOM].toFixed(0));
+                mergedBand[JV.BAND_PROP_STYLE] = band[JV.BAND_PROP_STYLE];
+                rst[JV.BAND_PROP_MERGE_BAND] = mergedBand;
+            }
+        } catch(exception) {
+            console.log(exception);
+        } finally {
+            bands = null;
+        }
+        return rst;
+    };
     JpcResult.outputAsSimpleJSONPageArray = function(rptTpl, dataObj, startPage, endPage, defProperties) {
         let me = this, rst = {};
         if ((startPage > 0) && (startPage <= endPage) && (endPage <= me.totalPages)) {

+ 29 - 0
modules/reports/rpt_component/jpc_flow_tab.js

@@ -594,6 +594,35 @@ JpcFlowTabSrv.prototype.createNew = function(){
         return rst;
     };
 
+    JpcFlowTabResult.outputAsPreviewPage = function (rptTpl, bands, controls, $CURRENT_RPT) {
+        let me = this, rst = [], vIdx = [];
+        //只预览第一页的数据
+        let pageStatus = [true, true, false, true, false, false, false, false];
+        JpcBandHelper.setBandArea(bands, rptTpl, pageStatus, true, false);
+        let maxRowRec = JpcFlowTabHelper.getMaxRowsPerPage(bands, rptTpl, false);
+        for (let i = 0; i < maxRowRec; i++) {
+            vIdx.push([-1, JV.DISPLAY_VAL_TYPE_NORMAL, JV.BLANK_VALUE_INDEX]);
+        }
+        let bkdispValueIdxLst = me.dispValueIdxLst;
+        me.pageStatusLst = [];
+        me.pageStatusLst.push(pageStatus);
+        me.dispValueIdxLst = [];
+        me.dispValueIdxLst.push(vIdx);
+        let unitFactor = JpcCommonHelper.getUnitFactor(rptTpl);
+        // 2.2 Column tab
+        rst.push(me.outputColumn(rptTpl, null, 1, 0, bands, unitFactor, controls, 0));
+        // 2.1 Content-Tab
+        // rst.push(me.outputContent(rptTpl, null, 1, bands, unitFactor, controls, 0, $CURRENT_RPT));
+        // 2.3 Sum Seg
+        // rst.push(me.outputSegSum(rptTpl, dataObj, 1, 0, bands, unitFactor, controls));
+        // 2.4 Sum Page
+        // rst.push(me.outputPageSum(rptTpl, dataObj, 1, 0, bands, unitFactor, controls));
+        // 2.5 Group
+        // 2.6 Discrete
+        rst.push(JpcDiscreteHelper.outputPreviewDiscreteInfo(rptTpl[JV.NODE_FLOW_INFO][JV.NODE_DISCRETE_INFO], bands, unitFactor, pageStatus));
+        me.dispValueIdxLst = bkdispValueIdxLst;
+        return rst;
+    };
     JpcFlowTabResult.outputAsSimpleJSONPage = function (rptTpl, dataObj, page, bands, controls, adHocMergePos, $CURRENT_RPT) {
         let me = this, rst = [], tabRstLst = [];
         let FLOW_NODE_STR = me.isEx?JV.NODE_FLOW_INFO_EX:JV.NODE_FLOW_INFO;