Browse Source

put 09-1 report

TonyKang 7 năm trước cách đây
mục cha
commit
e08172a924

+ 6 - 3
modules/reports/controllers/rpt_controller.js

@@ -110,9 +110,12 @@ function getAllPagesCommon(user_id, prj_id, rpt_id, pageSize, option, cb) {
 
 module.exports = {
     getReportAllPages: function (req, res) {
-        let rpt_id = req.body.rpt_tpl_id, prj_id = req.body.prj_id,
-            user_id = req.body.user_id, pageSize = req.body.pageSize;
-        getAllPagesCommon(rpt_id, prj_id, user_id, pageSize, function (err, pageRst) {
+        let params = JSON.parse(req.body.params),
+            rpt_id = params.rpt_tpl_id,
+            prj_id = params.prj_id,
+            user_id = params.user_id,
+            pageSize = params.pageSize;
+        getAllPagesCommon(user_id, prj_id, rpt_id, pageSize, null, function (err, pageRst) {
             callback(req, res, err, pageRst);
         });
     },

+ 337 - 0
test/unit/reports/rpt_cfg.js

@@ -0,0 +1,337 @@
+module.exports = {
+    "fonts" : [
+        {
+            "ID" : "ReportTitle_Main",
+            "CfgDispName" : "主标题",
+            "Name" : "smartSimSun",
+            "FontHeight" : "27",
+            "FontColor" : "BLACK",
+            "FontBold" : "T",
+            "FontItalic" : "F",
+            "FontUnderline" : "F",
+            "FontStrikeOut" : "F",
+            "FontAngle" : "0"
+        },
+        {
+            "ID" : "ReportTitle_Vice_1",
+            "CfgDispName" : "副标题",
+            "Name" : "smartSimSun",
+            "FontHeight" : "20",
+            "FontColor" : "BLACK",
+            "FontBold" : "T",
+            "FontItalic" : "F",
+            "FontUnderline" : "F",
+            "FontStrikeOut" : "F",
+            "FontAngle" : "0"
+        },
+        {
+            "ID" : "HeaderColumn",
+            "CfgDispName" : "栏头",
+            "Name" : "smartSimSun",
+            "FontHeight" : "12",
+            "FontColor" : "BLACK",
+            "FontBold" : "F",
+            "FontItalic" : "F",
+            "FontUnderline" : "F",
+            "FontStrikeOut" : "F",
+            "FontAngle" : "0"
+        },
+        {
+            "ID" : "Header",
+            "CfgDispName" : "表头",
+            "Name" : "smartSimSun",
+            "FontHeight" : "12",
+            "FontColor" : "BLACK",
+            "FontBold" : "F",
+            "FontItalic" : "F",
+            "FontUnderline" : "F",
+            "FontStrikeOut" : "F",
+            "FontAngle" : "0"
+        },
+        {
+            "ID" : "FooterColumn",
+            "CfgDispName" : "栏尾",
+            "Name" : "smartSimSun",
+            "FontHeight" : "12",
+            "FontColor" : "BLACK",
+            "FontBold" : "F",
+            "FontItalic" : "F",
+            "FontUnderline" : "F",
+            "FontStrikeOut" : "F",
+            "FontAngle" : "0"
+        },
+        {
+            "ID" : "Footer",
+            "CfgDispName" : "表尾",
+            "Name" : "smartSimSun",
+            "FontHeight" : "12",
+            "FontColor" : "BLACK",
+            "FontBold" : "F",
+            "FontItalic" : "F",
+            "FontUnderline" : "F",
+            "FontStrikeOut" : "F",
+            "FontAngle" : "0"
+        },
+        {
+            "ID" : "GramdTotal",
+            "CfgDispName" : "总合计",
+            "Name" : "smartSimSun",
+            "FontHeight" : "12",
+            "FontColor" : "BLACK",
+            "FontBold" : "F",
+            "FontItalic" : "F",
+            "FontUnderline" : "F",
+            "FontStrikeOut" : "F",
+            "FontAngle" : "0"
+        },
+        {
+            "ID" : "SectionTotal",
+            "CfgDispName" : "章合计",
+            "Name" : "smartSimSun",
+            "FontHeight" : "12",
+            "FontColor" : "BLACK",
+            "FontBold" : "F",
+            "FontItalic" : "F",
+            "FontUnderline" : "F",
+            "FontStrikeOut" : "F",
+            "FontAngle" : "0"
+        },
+        {
+            "ID" : "Content",
+            "CfgDispName" : "正文内容",
+            "Name" : "smartSimSun",
+            "FontHeight" : "12",
+            "FontColor" : "BLACK",
+            "FontBold" : "F",
+            "FontItalic" : "F",
+            "FontUnderline" : "F",
+            "FontStrikeOut" : "F",
+            "FontAngle" : "0"
+        },
+        {
+            "ID" : "Header_V1",
+            "Name" : "smartSimSun",
+            "FontHeight" : "12",
+            "FontColor" : "BLACK",
+            "FontBold" : "F",
+            "FontItalic" : "F",
+            "FontUnderline" : "F",
+            "FontStrikeOut" : "F",
+            "FontAngle" : "90"
+        },
+        {
+            "ID" : "Header_V2",
+            "Name" : "smartSimSun",
+            "FontHeight" : "12",
+            "FontColor" : "BLACK",
+            "FontBold" : "F",
+            "FontItalic" : "F",
+            "FontUnderline" : "F",
+            "FontStrikeOut" : "F",
+            "FontAngle" : "-90"
+        }
+    ],
+    "styles" : [
+        {
+            "ID" : "Default_None",
+            "CfgDispName" : "空白",
+            "border_style" : []
+        },
+        {
+            "ID" : "Default",
+            "CfgDispName" : "默认",
+            "border_style" : []
+        },
+        {
+            "ID" : "Default_Normal",
+            "CfgDispName" : "正常",
+            "border_style" : [
+                {
+                    "Position" : "Left",
+                    "LineWeight" : "1",
+                    "DashStyle" : "SOLID",
+                    "Color" : "BLACK"
+                },
+                {
+                    "Position" : "Right",
+                    "LineWeight" : "1",
+                    "DashStyle" : "SOLID",
+                    "Color" : "BLACK"
+                },
+                {
+                    "Position" : "Top",
+                    "LineWeight" : "1",
+                    "DashStyle" : "SOLID",
+                    "Color" : "BLACK"
+                },
+                {
+                    "Position" : "Bottom",
+                    "LineWeight" : "1",
+                    "DashStyle" : "SOLID",
+                    "Color" : "BLACK"
+                }
+            ]
+        },
+        {
+            "ID" : "Label_Underline",
+            "CfgDispName" : "字符底线",
+            "border_style" : [
+                {
+                    "Position" : "Left",
+                    "LineWeight" : "0",
+                    "DashStyle" : "SOLID",
+                    "Color" : "BLACK"
+                },
+                {
+                    "Position" : "Right",
+                    "LineWeight" : "0",
+                    "DashStyle" : "SOLID",
+                    "Color" : "BLACK"
+                },
+                {
+                    "Position" : "Top",
+                    "LineWeight" : "0",
+                    "DashStyle" : "SOLID",
+                    "Color" : "BLACK"
+                },
+                {
+                    "Position" : "Bottom",
+                    "LineWeight" : "1",
+                    "DashStyle" : "SOLID",
+                    "Color" : "BLACK"
+                }
+            ]
+        },
+        {
+            "ID" : "BORDER_ALL_AROUND",
+            "CfgDispName" : "报表边框",
+            "border_style" : [
+                {
+                    "Position" : "Left",
+                    "LineWeight" : "0.0",
+                    "DashStyle" : "SOLID",
+                    "Color" : "BLACK"
+                },
+                {
+                    "Position" : "Right",
+                    "LineWeight" : "0.0",
+                    "DashStyle" : "SOLID",
+                    "Color" : "BLACK"
+                },
+                {
+                    "Position" : "Top",
+                    "LineWeight" : "2.0",
+                    "DashStyle" : "SOLID",
+                    "Color" : "BLACK"
+                },
+                {
+                    "Position" : "Bottom",
+                    "LineWeight" : "2.0",
+                    "DashStyle" : "SOLID",
+                    "Color" : "BLACK"
+                }
+            ]
+        }
+    ],
+    "ctrls" : [
+        {
+            "ID" : "Default",
+            "CfgDispName" : "默认",
+            "Shrink" : "T",
+            "ShowZero" : "T",
+            "Horizon" : "left",
+            "Vertical" : "bottom",
+            "Wrap" : "false"
+        },
+        {
+            "ID" : "Title",
+            "CfgDispName" : "标题",
+            "Shrink" : "T",
+            "ShowZero" : "T",
+            "Horizon" : "center",
+            "Vertical" : "center",
+            "Wrap" : "false"
+        },
+        {
+            "ID" : "Header",
+            "CfgDispName" : "表头",
+            "Shrink" : "T",
+            "ShowZero" : "T",
+            "Horizon" : "left",
+            "Vertical" : "center",
+            "Wrap" : "false"
+        },
+        {
+            "ID" : "Footer",
+            "CfgDispName" : "表尾",
+            "Shrink" : "T",
+            "ShowZero" : "T",
+            "Horizon" : "left",
+            "Vertical" : "center",
+            "Wrap" : "false"
+        },
+        {
+            "ID" : "Column",
+            "CfgDispName" : "表栏",
+            "Shrink" : "T",
+            "ShowZero" : "T",
+            "Horizon" : "center",
+            "Vertical" : "center",
+            "Wrap" : "false",
+            "FillAfterWrap" : "true"
+        },
+        {
+            "ID" : "Column_Left",
+            "CfgDispName" : "表栏_左",
+            "Shrink" : "T",
+            "ShowZero" : "T",
+            "Horizon" : "left",
+            "Vertical" : "center",
+            "Wrap" : "false"
+        },
+        {
+            "ID" : "Column_Right",
+            "CfgDispName" : "表栏_右",
+            "Shrink" : "T",
+            "ShowZero" : "T",
+            "Horizon" : "right",
+            "Vertical" : "center",
+            "Wrap" : "false"
+        },
+        {
+            "ID" : "Content_Left",
+            "CfgDispName" : "正文内容",
+            "Shrink" : "T",
+            "ShowZero" : "F",
+            "Horizon" : "left",
+            "Vertical" : "bottom",
+            "Wrap" : "false"
+        },
+        {
+            "ID" : "Content_Right",
+            "CfgDispName" : "正文内容_右",
+            "Shrink" : "T",
+            "ShowZero" : "F",
+            "Horizon" : "right",
+            "Vertical" : "bottom",
+            "Wrap" : "false"
+        },
+        {
+            "ID" : "Content_Center",
+            "CfgDispName" : "正文内容_中",
+            "Shrink" : "T",
+            "ShowZero" : "F",
+            "Horizon" : "center",
+            "Vertical" : "bottom",
+            "Wrap" : "false"
+        },
+        {
+            "ID" : "Numeric",
+            "Shrink" : "T",
+            "ShowZero" : "F",
+            "Horizon" : "right",
+            "Vertical" : "bottom",
+            "Wrap" : "false"
+        }
+    ]
+}

Những thai đổi đã bị hủy bỏ vì nó quá lớn
+ 152 - 150
web/building_saas/main/html/main.html


+ 20 - 3
web/building_saas/report/html/rpt_main.html

@@ -75,9 +75,7 @@
             </div>
             <div class="print-view poj-list">
                 <div class="pageContainer">
-                    <div class="page">
-                        <img src="/web/building_saas/img/baobiao.png">
-                    </div>
+                    <canvas id="rptCanvas" height="820" width="920"></canvas>
                 </div>
             </div>
         </div>
@@ -141,3 +139,22 @@
         </div>
     </div>
 </div>
+<script>
+    const SCREEN_DPI = [];
+    function getScreenDPI() {
+        if (SCREEN_DPI.length === 0) {
+            if (window.screen.deviceXDPI != undefined) {
+                SCREEN_DPI.push(window.screen.deviceXDPI);
+                SCREEN_DPI.push(window.screen.deviceYDPI);
+            } else {
+                let tmpNode = document.createElement("DIV");
+                tmpNode.style.cssText = "width:1in;height:1in;position:absolute;left:0px;top:0px;z-index:99;visibility:hidden";
+                document.body.appendChild(tmpNode);
+                SCREEN_DPI.push(parseInt(tmpNode.offsetWidth));
+                SCREEN_DPI.push(parseInt(tmpNode.offsetHeight));
+                tmpNode.parentNode.removeChild(tmpNode);
+            }
+        }
+        return SCREEN_DPI;
+    }
+</script>

+ 209 - 0
web/building_saas/report/js/jpc_output.js

@@ -0,0 +1,209 @@
+/**
+ * Created by Tony on 2017/11/2.
+ */
+let JpcCanvasOutput = {
+    offsetX: 10,
+    offsetY: 10,
+    cleanCanvas: function (canvas) {
+        let ctx = canvas.getContext("2d");
+        ctx.save();
+        ctx.fillStyle="white";
+        ctx.clearRect(0,0, canvas.width, canvas.height);
+        ctx.restore();
+    },
+    drawToCanvas : function(pageObj, canvas, pageIdx) {
+        let me = this;
+        let ctx = canvas.getContext("2d");
+
+        function private_setupAreaH(area, type, fontAngle, dftFontHeight, outputPoint) {
+            let lType = type;
+            if (type != "left" && type != "right" && type != "center") lType = "left";
+            switch (lType) {
+                case "left":
+                    if (fontAngle == JV.VERTICAL_ANGLE) {
+                        outputPoint[1] = 1 * area[JV.IDX_TOP] + JV.OUTPUT_OFFSET[JV.OFFSET_IDX_LEFT];
+                    } else if (fontAngle == JV.ANTI_VERTICAL_ANGLE) {
+                        outputPoint[1] = 1 * area[JV.IDX_BOTTOM] - JV.OUTPUT_OFFSET[JV.OFFSET_IDX_LEFT];
+                    } else outputPoint[0] = 1 * area[JV.IDX_LEFT] + JV.OUTPUT_OFFSET[JV.OFFSET_IDX_LEFT];
+                    ctx.textAlign="start";
+                    break;
+                case "right":
+                    if (fontAngle == JV.VERTICAL_ANGLE) {
+                        outputPoint[1] = 1 * area[JV.IDX_BOTTOM] - JV.OUTPUT_OFFSET[JV.OFFSET_IDX_RIGHT];
+                    } else if (fontAngle == JV.ANTI_VERTICAL_ANGLE) {
+                        outputPoint[1] = 1 * area[JV.IDX_TOP] + JV.OUTPUT_OFFSET[JV.OFFSET_IDX_RIGHT];
+                    } else outputPoint[0] = 1 * area[JV.IDX_RIGHT] - JV.OUTPUT_OFFSET[JV.OFFSET_IDX_RIGHT];
+                    ctx.textAlign="end";
+                    break;
+                case "center":
+                    if (fontAngle == JV.VERTICAL_ANGLE || fontAngle == JV.ANTI_VERTICAL_ANGLE) {
+                        outputPoint[1] = (1 * area[JV.IDX_TOP] + 1 * area[JV.IDX_BOTTOM]) / 2;
+                    } else outputPoint[0] = (1 * area[JV.IDX_LEFT] + 1 * area[JV.IDX_RIGHT]) / 2;
+                    ctx.textAlign="center";
+                    break;
+            }
+        }
+        function private_setupAreaV(area, type, fontAngle, dftFontHeight, outputPoint) {
+            let lType = type;
+            if (type != "top" && type != "bottom" && type != "center") lType = "top";
+            switch (lType) {
+                case "top":
+                    if (fontAngle == JV.VERTICAL_ANGLE) {
+                        outputPoint[0] = 1 * area[JV.IDX_RIGHT] - dftFontHeight - JV.OUTPUT_OFFSET[JV.OFFSET_IDX_TOP];
+                    } else if (fontAngle == JV.ANTI_VERTICAL_ANGLE) {
+                        outputPoint[0] = 1 * area[JV.IDX_LEFT] + dftFontHeight + JV.OUTPUT_OFFSET[JV.OFFSET_IDX_TOP];
+                    } else outputPoint[1] = 1 * area[JV.IDX_TOP] + dftFontHeight + JV.OUTPUT_OFFSET[JV.OFFSET_IDX_TOP];
+                    break;
+                case "bottom":
+                    if (fontAngle == JV.VERTICAL_ANGLE) {
+                        outputPoint[0] = 1 * area[JV.IDX_LEFT] + JV.OUTPUT_OFFSET[JV.OFFSET_IDX_BOTTOM];
+                    } else if (fontAngle == JV.ANTI_VERTICAL_ANGLE) {
+                        outputPoint[0] = 1 * area[JV.IDX_RIGHT] - JV.OUTPUT_OFFSET[JV.OFFSET_IDX_BOTTOM];
+                    } else outputPoint[1] = 1 * area[JV.IDX_BOTTOM] - JV.OUTPUT_OFFSET[JV.OFFSET_IDX_BOTTOM];
+                    break;
+                case "center":
+                    if (fontAngle == JV.VERTICAL_ANGLE) {
+                        outputPoint[0] = (1 * area[JV.IDX_LEFT] + 1 * area[JV.IDX_RIGHT] - dftFontHeight) / 2;
+                    } else if (fontAngle == JV.ANTI_VERTICAL_ANGLE) {
+                        outputPoint[0] = (1 * area[JV.IDX_LEFT] + 1 * area[JV.IDX_RIGHT] + dftFontHeight) / 2;
+                    } else outputPoint[1] = (1 * area[JV.IDX_TOP] + 1 * area[JV.IDX_BOTTOM] + dftFontHeight) / 2;
+                    break;
+            }
+        }
+        function private_drawText(val, area, font, control) {
+            let dftFontHeight = 12;
+            let output = [];
+            if (font) {
+                dftFontHeight = 1 * font[JV.FONT_PROPS[1]];
+                let dftOthers = "";
+                let dftFontBold = font[JV.FONT_PROPS[3]];
+                if (dftFontBold && dftFontBold == 'T') {
+                    dftOthers = "bold " + dftOthers ;
+                }
+                let dftFontItalic = font[JV.FONT_PROPS[4]];
+                if (dftFontItalic && dftFontItalic == 'T') {
+                    dftOthers = dftOthers + "italic ";
+                }
+                ctx.font = dftOthers + dftFontHeight + "px " + font[JV.PROP_NAME];
+            }
+            if (control) {
+                private_setupAreaH(area, control.Horizon, font.FontAngle, dftFontHeight, output);
+                private_setupAreaV(area, control.Vertical, font.FontAngle, dftFontHeight, output);
+            } else {
+                private_setupAreaH(area, "left", font.FontAngle, dftFontHeight, output);
+                private_setupAreaV(area, "bottom", font.FontAngle, dftFontHeight, output);
+            }
+            let w = area[JV.IDX_RIGHT] - JV.OUTPUT_OFFSET[JV.OFFSET_IDX_RIGHT] - area[JV.IDX_LEFT] - JV.OUTPUT_OFFSET[JV.OFFSET_IDX_RIGHT];
+            if (font.FontAngle != "0") {
+                w = area[JV.IDX_BOTTOM] - JV.OUTPUT_OFFSET[JV.OFFSET_IDX_BOTTOM] - area[JV.IDX_TOP] - JV.OUTPUT_OFFSET[JV.OFFSET_IDX_TOP];
+            }
+            ctx.save();
+            ctx.translate(output[0], output[1]);
+            if (font.FontAngle === JV.VERTICAL_ANGLE) {
+                ctx.rotate(Math.PI/2);
+            } else if (font.FontAngle === JV.ANTI_VERTICAL_ANGLE) {
+                ctx.rotate(-Math.PI/2);
+            }
+            if (w >= ctx.measureText(val).width) {
+                ctx.fillText(val, 0, 0);
+            } else {
+                while (true) {
+                    dftFontHeight--;
+                    ctx.font = "" + dftFontHeight + "px " + font[JV.PROP_NAME];
+                    if (w >=  ctx.measureText(val).width || dftFontHeight < 6) {
+                        ctx.fillText(val, 0, 0);
+                        break;
+                    }
+                }
+            }
+            ctx.restore();
+        }
+        function private_drawCellText(cell, fonts, controls) {
+            if (cell[JV.PROP_VALUE]) {
+                let values = ("" + cell[JV.PROP_VALUE]).split('|');
+                let font = fonts[cell[JV.PROP_FONT]];
+                let control = controls[cell[JV.PROP_CONTROL]];
+                let height = cell[JV.PROP_AREA][JV.PROP_BOTTOM] - cell[JV.PROP_AREA][JV.PROP_TOP];
+                let area = [cell[JV.PROP_AREA][JV.PROP_LEFT] + me.offsetX, cell[JV.PROP_AREA][JV.PROP_TOP] + me.offsetY, cell[JV.PROP_AREA][JV.PROP_RIGHT] + me.offsetX, cell[JV.PROP_AREA][JV.PROP_BOTTOM] + me.offsetY];
+                for (let i = 0; i < values.length; i++) {
+                    area[JV.IDX_TOP] = cell[JV.PROP_AREA][JV.PROP_TOP] + i * (height / values.length) + me.offsetY;
+                    area[JV.IDX_BOTTOM] = cell[JV.PROP_AREA][JV.PROP_TOP] + (i + 1) * (height / values.length) + me.offsetY;
+                    private_drawText(values[i], area, font, control);
+                }
+            }
+        }
+        function private_drawLine(cell, ctx, style, styleBorderDest, startP, destP, mergedBand, styles, isNeedMergeBand) {
+            ctx.beginPath();
+            let destStyle = style;
+            if (mergedBand) {
+                if (isNeedMergeBand && mergedBand[styleBorderDest] == cell[JV.PROP_AREA][styleBorderDest]) {
+                    destStyle = styles[mergedBand[JV.PROP_STYLE][JV.PROP_ID]];
+                }
+            }
+            ctx.moveTo(cell[JV.PROP_AREA][startP[0]] + me.offsetX, cell[JV.PROP_AREA][startP[1]] + me.offsetY);
+            if (destStyle[styleBorderDest] && destStyle[styleBorderDest][JV.PROP_LINE_WEIGHT] != 0) {
+                ctx.lineWidth = 1.0 * destStyle[styleBorderDest][JV.PROP_LINE_WEIGHT];
+                ctx.strokeStyle = destStyle[styleBorderDest][JV.PROP_COLOR];
+                ctx.lineTo(cell[JV.PROP_AREA][destP[0]] + me.offsetX, cell[JV.PROP_AREA][destP[1]] + me.offsetY);
+            }
+            ctx.stroke();
+        }
+        function private_chkIfInMergedBand(mergedBand, cell) {
+            let rst = false;
+            if (mergedBand && cell) {
+                rst = mergedBand[JV.PROP_TOP] <= cell[JV.PROP_AREA][JV.PROP_TOP] && mergedBand[JV.PROP_BOTTOM] >= cell[JV.PROP_AREA][JV.PROP_BOTTOM] &&
+                    mergedBand[JV.PROP_LEFT] <= cell[JV.PROP_AREA][JV.PROP_LEFT] && mergedBand[JV.PROP_RIGHT] >= cell[JV.PROP_AREA][JV.PROP_RIGHT];
+            }
+            return rst;
+        }
+        function private_drawCell(cell, fonts, styles, controls, mergedBand) {
+            ctx.save();
+            ctx.translate(0.5,0.5);
+            let style = styles[cell[JV.PROP_STYLE]];
+            if (style) {
+                let isNeedMergeBand = private_chkIfInMergedBand(mergedBand, cell);
+                private_drawLine(cell, ctx, style, JV.PROP_TOP, [JV.PROP_LEFT, JV.PROP_TOP],[JV.PROP_RIGHT, JV.PROP_TOP], mergedBand, styles, isNeedMergeBand);
+                private_drawLine(cell, ctx, style, JV.PROP_RIGHT, [JV.PROP_RIGHT, JV.PROP_TOP],[JV.PROP_RIGHT, JV.PROP_BOTTOM], mergedBand, styles, isNeedMergeBand);
+                private_drawLine(cell, ctx, style, JV.PROP_BOTTOM, [JV.PROP_RIGHT, JV.PROP_BOTTOM],[JV.PROP_LEFT, JV.PROP_BOTTOM], mergedBand, styles, isNeedMergeBand);
+                private_drawLine(cell, ctx, style, JV.PROP_LEFT, [JV.PROP_LEFT, JV.PROP_BOTTOM],[JV.PROP_LEFT, JV.PROP_TOP], mergedBand, styles, isNeedMergeBand);
+            }
+            private_drawCellText(cell, fonts, controls);
+            ctx.restore();
+        }
+
+        if (pageObj && pageObj.items.length > 0 && canvas && pageObj.items.length >= pageIdx) {
+            let page = pageObj.items[pageIdx - 1],
+                fonts = pageObj[JV.NODE_FONT_COLLECTION],
+                styles = pageObj[JV.NODE_STYLE_COLLECTION],
+                controls = pageObj[JV.NODE_CONTROL_COLLECTION],
+                mergedBand = pageObj[JV.BAND_PROP_MERGE_BAND];
+            for (let j = 0; j < page.cells.length; j++) {
+                let cell = page.cells[j];
+                private_drawCell(cell, fonts, styles, controls, mergedBand);
+            }
+        }
+    },
+    drawPageBorder: function(rptTpl, canvas, resolution) {
+        let me = this;
+        let size = rptTpl[JV.NODE_PAGE_INFO][JV.NODE_PAGE_SIZE].slice(0);
+        size[0] = Math.round(resolution[0] * size[0]);
+        size[1] = Math.round(resolution[0] * size[1]);
+
+        let ctx = canvas.getContext("2d");
+        ctx.save();
+        ctx.beginPath();
+        ctx.translate(0.5,0.5);
+        ctx.lineWidth = 1;
+        ctx.moveTo(me.offsetX, me.offsetY);
+        ctx.lineTo(size[0] + me.offsetX, me.offsetY);
+        ctx.lineTo(size[0] + me.offsetX, size[1] + me.offsetY);
+        ctx.lineTo(me.offsetX, size[1] + me.offsetY);
+        ctx.lineTo(me.offsetX, me.offsetY);
+        ctx.stroke();
+        ctx.restore();
+
+        ctx.fillStyle="black";
+        ctx.fillRect(size[0] + me.offsetX,10 + me.offsetY,10,size[1]);
+        ctx.fillRect(10 + me.offsetX,size[1] + me.offsetY,size[0],10);
+    }
+};

+ 3 - 48
web/building_saas/report/js/rpt_cfg_const.js

@@ -2,6 +2,8 @@
  * Created by Tony on 2017/6/26.
  */
 
+const   TPL_TYPE_NODE = 1,
+        TPL_TYPE_TEMPLATE = 2;
 let rpt_tpl_setting = {
     view: {
         selectedMulti: false
@@ -24,53 +26,6 @@ let rpt_tpl_setting = {
     },
     callback: {
         //onCheck: zTreeOprObj.onCheck
+        onClick: zTreeOprObj.onClick
     }
 };
-
-const engineering = {
-    // 建筑工程
-    ARCHITECTURE: 1,
-    // 装饰工程
-    DECORATE: 2,
-    // 仿古建筑工程
-    ANTIQUE_ARCHITECTURE: 3,
-    // 安装工程
-    BUILD_IN: 4,
-    // 市政土建工程
-    MUNICIPAL_CONSTRUCTION: 5,
-    // 市政安装工程
-    MUNICIPAL_BUILD_IN: 6,
-    // 人工土石方工程
-    ARTIFICIAL_EARTHWORK: 7,
-    // 机械土石方工程
-    MECHANICAL_EARTHWORK: 8,
-    // 炉窖砌筑工程
-    KILN_MASONRY: 9,
-    // 园林工程
-    GARDEN: 10,
-    // 绿化工程
-    PLANTING: 11,
-    // 单拆除工程
-    DISMANTLE: 12,
-    // 建筑修缮工程
-    BUILDING_REPAIR: 13,
-    // 安装修缮工程
-    BUILD_IN_REPAIR: 14
-};
-
-const engineeringList = [
-    {name: "建筑工程", value: engineering.ARCHITECTURE},
-    {name: "装饰工程", value: engineering.DECORATE},
-    {name: "仿古建筑工程", value: engineering.ANTIQUE_ARCHITECTURE},
-    {name: "安装工程", value: engineering.BUILD_IN},
-    {name: "市政土建工程", value: engineering.MUNICIPAL_CONSTRUCTION},
-    {name: "市政安装工程", value: engineering.MUNICIPAL_BUILD_IN},
-    {name: "人工土石方工程", value: engineering.ARTIFICIAL_EARTHWORK},
-    {name: "机械土石方工程", value: engineering.MECHANICAL_EARTHWORK},
-    {name: "炉窖砌筑工程", value: engineering.KILN_MASONRY},
-    {name: "园林工程", value: engineering.GARDEN},
-    {name: "绿化工程", value: engineering.PLANTING},
-    {name: "单拆除工程", value: engineering.DISMANTLE},
-    {name: "建筑修缮工程", value: engineering.BUILDING_REPAIR},
-    {name: "安装修缮工程", value: engineering.BUILD_IN_REPAIR},
-];

+ 73 - 6
web/building_saas/report/js/rpt_main.js

@@ -10,6 +10,9 @@ let rptTplObj = {
         if (!me.hasInitialized) {
             zTreeOprObj.getReportTemplateTree(userID);
             me.hasInitialized = true;
+            let canvas = document.getElementById("rptCanvas");
+            canvas.onclick = canvasOprObj.cavansOnClick;
+            canvas.onmousemove = canvasOprObj.canvasOnMouseMove;
         }
     }
 }
@@ -17,16 +20,20 @@ let rptTplObj = {
 let zTreeOprObj = {
     treeObj: null,
     currentNode: null,
+    currentRptPageRst: null,
+    currentPage: 1,
+    maxPages: 0,
     getReportTemplateTree: function(userId) {
         let me = zTreeOprObj, params = {};
         params.userId = [];
         params.userId.push(userId);
         params.userId.push(-100);
-        let allEngIds = [];
-        for (let item of engineeringList) {
-            allEngIds.push(item.value);
-        }
-        params.engineerId = allEngIds;
+        // let allEngIds = [];
+        // for (let item of engineeringList) {
+        //     allEngIds.push(item.value);
+        // }
+        // params.engineerId = allEngIds;
+        params.engineerId = projectInfoObj.projectInfo.property.engineering;
         CommonAjax.postEx("report_tpl_api/getRptTplTree", params, 20000, true, function(result){
                 zTreeHelper.createTreeDirectly(result, rpt_tpl_setting, "rptTplTree", me);
                 me.refreshNodes();
@@ -56,6 +63,66 @@ let zTreeOprObj = {
         //}
     },
     onClick: function(event,treeId,treeNode) {
-        //
+        let me = zTreeOprObj;
+        let canvas = document.getElementById("rptCanvas");
+        if (treeNode.nodeType === TPL_TYPE_TEMPLATE && treeNode.refId > 0) {
+            let params = {};
+            let pageSize = "A4";
+            params.user_id = userID;
+            params.pageSize = pageSize;
+            params.rpt_tpl_id = treeNode.refId;
+            params.prj_id = projectInfoObj.projectInfo.ID;
+            CommonAjax.postEx("report_api/getReport", params, 5000, true, function(result){
+                    let pageRst = result;
+                    if (pageRst) {
+                        me.currentRptPageRst = pageRst;
+                        me.maxPages = pageRst.items.length;
+                        me.currentPage = 1;
+                        if (pageSize === "A4") {
+                            canvas.width = 1200;
+                            canvas.height = 900;
+                        } else if (pageSize === "A3") {
+                            canvas.width = 1880;
+                            canvas.height = 1200;
+                        }
+                        me.showPage(0, canvas);
+                    }
+                }, null, null
+            );
+        }
+    },
+    showPage: function (pageStep, canvas) {
+        let me = zTreeOprObj;
+        if (me.currentPage + pageStep >= 1 && me.currentPage + pageStep <= me.maxPages) {
+            me.currentPage = me.currentPage + pageStep;
+            JpcCanvasOutput.cleanCanvas(canvas);
+            JpcCanvasOutput.drawPageBorder(me.currentRptPageRst, canvas, getScreenDPI());
+            JpcCanvasOutput.drawToCanvas(me.currentRptPageRst, canvas, me.currentPage);
+        }
+    }
+};
+
+let canvasOprObj = {
+    canvasOnMouseMove: function (event) {
+        let x = event.offsetX - JpcCanvasOutput.offsetX,
+            canvas = event.originalTarget
+        ;
+        if (x < 300) {
+            canvas.style.cursor = "e-resize";
+        } else if ((canvas.width - x) < 300) {
+            canvas.style.cursor = "w-resize";
+        } else {
+            canvas.style.cursor = "";
+        }
+    },
+    cavansOnClick: function(event){
+        let x = event.offsetX - JpcCanvasOutput.offsetX,
+            //y = event.offsetY - JpcCanvasOutput.offsetY,
+            canvas = event.originalTarget;
+        if (x < 300) {
+            zTreeOprObj.showPage(-1, canvas);
+        } else if ((canvas.width - x) < 300) {
+            zTreeOprObj.showPage(1, canvas);
+        }
     }
 };