Переглянути джерело

get preview page for multiple columns

TonyKang 6 роки тому
батько
коміт
dba388282d

+ 51 - 2
modules/reports/rpt_component/jpc_flow_tab.js

@@ -737,10 +737,59 @@ JpcFlowTabSrv.prototype.createNew = function(){
             vIdx.push([-1, JV.DISPLAY_VAL_TYPE_NORMAL, JV.BLANK_VALUE_INDEX]);
         }
         let unitFactor = JpcCommonHelper.getUnitFactor(rptTpl);
+        // me.multiCols = 1 * rptTpl[JV.NODE_FLOW_INFO][JV.PROP_MULTI_COLUMN];
+        let newMultiCols = 1 * rptTpl[JV.NODE_FLOW_INFO][JV.PROP_MULTI_COLUMN];
         // 2.2 Column tab
-        rst = rst.concat(me.outputColumn(rptTpl, null, 1, 0, bands, unitFactor, 0));
+        let private_colone_cells = function(orgCells) {
+            let newRst = [];
+            let newCopyCells = [];
+            newCopyCells.push(orgCells);
+            if (newMultiCols > 1) {
+                let minX = 10000, maxX = -10;
+                for (let cell of orgCells) {
+                    if (minX > parseInt(cell[JV.PROP_AREA][JV.PROP_LEFT])) minX = cell[JV.PROP_AREA][JV.PROP_LEFT];
+                    if (maxX < parseInt(cell[JV.PROP_AREA][JV.PROP_RIGHT])) maxX = cell[JV.PROP_AREA][JV.PROP_RIGHT];
+                }
+                let newW = maxX - minX, newSegW = newW / newMultiCols;
+                for (let i = 1; i < newMultiCols; i++) {
+                    let cells = [];
+                    for (let cell of orgCells) {
+                        let copyCell = {Value: cell.Value, area: {}, font: cell[JV.PROP_FONT], control: cell[JV.PROP_CONTROL], style: cell[JV.PROP_STYLE]};
+                        cells.push(copyCell);
+                        copyCell[JV.PROP_AREA][JV.PROP_LEFT] = cell[JV.PROP_AREA][JV.PROP_LEFT];
+                        copyCell[JV.PROP_AREA][JV.PROP_RIGHT] = cell[JV.PROP_AREA][JV.PROP_RIGHT];
+                        copyCell[JV.PROP_AREA][JV.PROP_TOP] = cell[JV.PROP_AREA][JV.PROP_TOP];
+                        copyCell[JV.PROP_AREA][JV.PROP_BOTTOM] = cell[JV.PROP_AREA][JV.PROP_BOTTOM];
+                    }
+                    newCopyCells.push(cells);
+                }
+                for (let ci = 0; ci < newCopyCells.length; ci++) {
+                    for (let cCell of newCopyCells[ci]) {
+                        cCell[JV.PROP_AREA][JV.PROP_LEFT] = Math.round(minX + newSegW * ci + (cCell[JV.PROP_AREA][JV.PROP_LEFT] - minX) / newMultiCols);
+                        cCell[JV.PROP_AREA][JV.PROP_RIGHT] = Math.round(minX + newSegW * ci + (cCell[JV.PROP_AREA][JV.PROP_RIGHT] - minX) / newMultiCols);
+                    }
+                }
+            }
+            for (let cCells of newCopyCells) {
+                for (let dCell of cCells) {
+                    newRst.push(dCell);
+                }
+            }
+            return newRst;
+        };
+        let tmpColCells = me.outputColumn(rptTpl, null, 1, 0, bands, unitFactor, 0);
+        if (newMultiCols > 1) {
+            tmpColCells = private_colone_cells(tmpColCells);
+        }
+        rst = rst.concat(tmpColCells);
         // 2.1 Content-Tab
-        rst = rst.concat(me.outputPreviewContent(rptTpl, bands, unitFactor, controls, pageStatus, maxRowRec));
+        let tmpContentCells = me.outputPreviewContent(rptTpl, bands, unitFactor, controls, pageStatus, maxRowRec);
+        if (newMultiCols > 1) {
+            tmpContentCells = private_colone_cells(tmpContentCells);
+        } else {
+            // rst = rst.concat(me.outputPreviewContent(rptTpl, bands, unitFactor, controls, pageStatus, maxRowRec));
+        }
+        rst = rst.concat(tmpContentCells);
         // 2.3 Sum Seg
         rst = rst.concat(me.outputPreviewSegSum(rptTpl, bands, unitFactor, controls, pageStatus));
         // 2.4 Sum Page

+ 1 - 0
web/maintain/report/js/rpt_tpl_helper.js

@@ -85,6 +85,7 @@ let tplHelper = {
             }
             if (rptTpl[JV.NODE_FLOW_INFO]) {
                 $("#multiColCnt")[0].style.display = "";
+                $("#rptTplMultiCols")[0].value = rptTpl[JV.NODE_FLOW_INFO][JV.PROP_MULTI_COLUMN];
             } else {
                 $("#multiColCnt")[0].style.display = "none";
             }