TonyKang 6 лет назад
Родитель
Сommit
8b4769584d

+ 51 - 38
modules/reports/controllers/rpt_controller.js

@@ -244,28 +244,34 @@ function getAllPagesCommon(user_id, prj_id, rpt_id, pageSize, orientation, custo
             rptTplDataFacade.prepareProjectData(user_id, prj_id, filter, function (err, msg, rawDataObj) {
                 if (!err) {
                     let buildPageData = function() {
-                        let tplData = rptDataUtil.assembleData(rawDataObj);
-                        let printCom = JpcEx.createNew();
-                        if (pageSize) rptTpl[JV.NODE_MAIN_INFO][JV.NODE_PAGE_INFO][JV.PROP_PAGE_SIZE] = pageSize;
-                        //console.log("orientation: " + (orientation === 'null'));
-                        if (orientation && (orientation !== 'null')) rptTpl[JV.NODE_MAIN_INFO][JV.NODE_PAGE_INFO][JV.PROP_ORIENTATION] = orientation;
-                        let defProperties = rptUtil.getReportDefaultCache();
-                        if (customizeCfg) setupCustomizeCfg(customizeCfg, rptTpl, defProperties);
-                        let dftOption = option||JV.PAGING_OPTION_NORMAL;
-                        printCom.initialize(rptTpl);
-                        printCom.analyzeData(rptTpl, tplData, defProperties, dftOption, outputType);
-                        let maxPages = printCom.totalPages;
-                        let pageRst = null;
-                        if (maxPages > 0) {
-                            pageRst = printCom.outputAsSimpleJSONPageArray(rptTpl, tplData, 1, maxPages, defProperties, customizeCfg);
-                        } else {
-                            pageRst = printCom.outputAsPreviewPage(rptTpl, defProperties);
-                        }
-                        if (pageRst) {
-                            // fsUtil.writeObjToFile(pageRst, "D:/GitHome/ConstructionCost/tmp/testBuiltPageResult.jsp");
-                            cb(null, pageRst);
-                        } else {
-                            cb('Have errors while on going...', null);
+                        try {
+                            let tplData = rptDataUtil.assembleData(rawDataObj);
+                            let printCom = JpcEx.createNew();
+                            if (pageSize) rptTpl[JV.NODE_MAIN_INFO][JV.NODE_PAGE_INFO][JV.PROP_PAGE_SIZE] = pageSize;
+                            //console.log("orientation: " + (orientation === 'null'));
+                            if (orientation && (orientation !== 'null')) rptTpl[JV.NODE_MAIN_INFO][JV.NODE_PAGE_INFO][JV.PROP_ORIENTATION] = orientation;
+                            let defProperties = rptUtil.getReportDefaultCache();
+                            if (customizeCfg) setupCustomizeCfg(customizeCfg, rptTpl, defProperties);
+                            let dftOption = option||JV.PAGING_OPTION_NORMAL;
+                            printCom.initialize(rptTpl);
+                            printCom.analyzeData(rptTpl, tplData, defProperties, dftOption, outputType);
+                            let maxPages = printCom.totalPages;
+                            let pageRst = null;
+                            if (maxPages > 0) {
+                                pageRst = printCom.outputAsSimpleJSONPageArray(rptTpl, tplData, 1, maxPages, defProperties, customizeCfg);
+                            } else {
+                                pageRst = printCom.outputAsPreviewPage(rptTpl, defProperties);
+                            }
+                            if (pageRst) {
+                                // fsUtil.writeObjToFile(pageRst, "D:/GitHome/ConstructionCost/tmp/testBuiltPageResult.jsp");
+                                cb(null, pageRst);
+                            } else {
+                                cb('Have errors while on going...', null);
+                            }
+                        } catch (ex) {
+                            console.log("报表数据异常: userId " + user_id + ", project id: " + prj_id);
+                            console.log(ex);
+                            cb('Exception occurs while on going...', null);
                         }
                     };
                     //*/
@@ -372,6 +378,18 @@ module.exports = {
             }
         })
     },
+    getMultiReportsEx: function (req, res) {
+        //原则说明:把所有报表模板集中获取,统一filter,只读一次数据!(有空再整)
+        let params = JSON.parse(req.body.params),
+            prj_id = params.prj_id,
+            rpt_ids = params.rpt_ids.split(','),
+            pageSize = params.pageSize,
+            orientation = params.orientation,
+            customizeCfg = params.custCfg,
+            option = params.option;
+        let user_id = req.session.sessionUser.id;
+        let dftOption = option||JV.PAGING_OPTION_NORMAL;
+    },
 
     getReportAllPagesSvg: function (req, res) {
         let params = JSON.parse(req.body.params),
@@ -578,22 +596,17 @@ module.exports = {
             let r_name = rpt_names[idx];
             parallelFunctions.push((function (rpt_id, rpt_name) {
                 return function (cb) {
-                    try {
-                        getAllPagesCommon(user_id, prj_id, rpt_id, pageSize, orientation, customizeCfg, dftOption, JV.OUTPUT_TYPE_PDF, function (err, pageRst) {
-                            if(err){
-                                cb(err);
-                            }
-                            else{
-                                rpt_pdf_util.export_pdf_file(pageRst, pageSize, rpt_name, function(uuidName){
-                                    let fileRst = {uuid: uuidName, reportName: rpt_name};
-                                    cb(err, fileRst);
-                                })
-                            }
-                        })
-                    } catch (ex) {
-                        console.log(ex);
-                        cb("Occurs exception while creating PDF file!");
-                    }
+                    getAllPagesCommon(user_id, prj_id, rpt_id, pageSize, orientation, customizeCfg, dftOption, JV.OUTPUT_TYPE_PDF, function (err, pageRst) {
+                        if(err){
+                            cb(err);
+                        }
+                        else{
+                            rpt_pdf_util.export_pdf_file(pageRst, pageSize, rpt_name, function(uuidName){
+                                let fileRst = {uuid: uuidName, reportName: rpt_name};
+                                cb(err, fileRst);
+                            })
+                        }
+                    })
                 }
             })(parseInt(r_id), r_name));
         }

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

@@ -819,6 +819,15 @@ JpcFlowTabSrv.prototype.createNew = function(){
         }
         return rst;
     };
+    JpcFlowTabResult.combinePageCells = function (rptTpl, pageCells) {
+        let me = this;
+        let FLOW_NODE_STR = me.isEx?JV.NODE_FLOW_INFO_EX:JV.NODE_FLOW_INFO;
+        let tab = rptTpl[FLOW_NODE_STR][JV.NODE_FLOW_CONTENT];
+        let tab_fields = tab[JV.PROP_FLOW_FIELDS];
+        for (let tabField of tab_fields) {
+            // tabField[JV.PROP_]
+        }
+    };
     JpcFlowTabResult.outputPreviewContent = function(rptTpl, bands, unitFactor, controls, pageStatus, maxRec) {
         let me = this, rst = [];
         let tab = rptTpl[JV.NODE_FLOW_INFO][JV.NODE_FLOW_CONTENT];

+ 15 - 4
modules/reports/util/rpt_excel_util.js

@@ -275,24 +275,35 @@ function writeStyles(stylesObj){
 }
 function writeSharedString(sharedStrList){
     let rst = [];
+    let pri_func_write = function(cellVal) {
+        if (cellVal !== null) {
+            if ((typeof cellVal === 'string') && cellVal.indexOf(' ') === 0) {
+                rst.push('<si><t xml:space="preserve">' + cellVal + '</t></si>');
+            } else {
+                rst.push('<si><t>' + cellVal + '</t></si>');
+            }
+        }
+    };
     if (sharedStrList && sharedStrList.length > 0) {
         rst.push(dftHeadXml + '\r\n');
         rst.push('<sst xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main" count="' + sharedStrList.length + '" uniqueCount="' + sharedStrList.length + '">');
         let regExp = new RegExp("<", "gm");
         for (let i = 0; i < sharedStrList.length; i++) {
-            //rst.push('<si><t>' + sharedStrList[i] + '</t></si>');
             if (typeof sharedStrList[i] === 'string') {
                 //转换特殊字符,如 < , 则需要转义一下
                 sharedStrList[i] = sharedStrList[i].replace(regExp, "&lt;");
                 if (sharedStrList[i].indexOf('|') >= 0) {
                     //rst.push('<si><t>' + sharedStrList[i].split('|').join('\r\n') + '</t></si>');
-                    rst.push('<si><t>' + sharedStrList[i].split('|').join('\n') + '</t></si>');
+                    // rst.push('<si><t>' + sharedStrList[i].split('|').join('\n') + '</t></si>');
+                    pri_func_write(sharedStrList[i].split('|').join('\n'));
                 } else {
-                    rst.push('<si><t>' + sharedStrList[i] + '</t></si>');
+                    // rst.push('<si><t>' + sharedStrList[i] + '</t></si>');
+                    pri_func_write(sharedStrList[i]);
                 }
                 // rst.push('<si><t>' + sharedStrList[i].replace('|','\r\n') + '</t></si>');
             } else {
-                rst.push('<si><t>' + sharedStrList[i] + '</t></si>');
+                // rst.push('<si><t>' + sharedStrList[i] + '</t></si>');
+                pri_func_write(sharedStrList[i]);
             }
         }
         rst.push('</sst>');

+ 1 - 0
public/web/rpt_value_define.js

@@ -120,6 +120,7 @@ const JV = {
     PROP_POSITION: "Position",
     PROP_HIDDEN: "Hidden",
     PROP_IS_SERIAL: "isSerial",
+    PROP_COMBINE_TYPE: "combineType",
     PROP_IS_AUTO_HEIGHT: "isAutoHeight",
     PROP_FONT: "font",
     PROP_CONTROL: "control",

+ 6 - 4
web/building_saas/report/html/rpt_print.html

@@ -78,6 +78,7 @@
 
     function showPreviewData(svgArr, actAreaArr, scaleFactor, pageSize, orientation, orgPixelSize) {
         let orgHeight = 793, orgWidth = 1122;
+        let DFT_MARGIN = 5;
         if (pageSize === 'A3') {
             orgHeight = 1122;
             orgWidth = 793 * 2;
@@ -95,12 +96,13 @@
         for (let i = 0; i < svgArr.length; i++) {
             let offsetHeight = 0, offsetWidth = 0;
             if (actAreaArr) {
-                offsetWidth = actAreaArr[i].Left + (pageWidth - actAreaArr[i].Right) - 5;
-                offsetHeight = actAreaArr[i].Top + (pageHeight - actAreaArr[i].Bottom) - 5;
+                offsetWidth = actAreaArr[i].Left + (pageWidth - actAreaArr[i].Right) - DFT_MARGIN;
+                offsetHeight = actAreaArr[i].Top + (pageHeight - actAreaArr[i].Bottom) - DFT_MARGIN;
                 if (orgPixelSize[0] > orgPixelSize[1]) {
                     //横向强制改纵向(系统是以纵向为准),那么计算offset的方式会有所不同
-                    offsetWidth = actAreaArr[i].Top + (pageWidth - actAreaArr[i].Bottom) - 5;
-                    offsetHeight = actAreaArr[i].Left + (pageHeight - actAreaArr[i].Right) - 5;
+                    offsetWidth = actAreaArr[i].Top + (pageWidth - actAreaArr[i].Bottom) - DFT_MARGIN;
+                    //横向转纵向时,还得考虑左上角转右上角的Left与Top之间的差,否则坐标还是会有偏差
+                    offsetHeight = actAreaArr[i].Left + (pageHeight - actAreaArr[i].Right) - (actAreaArr[i].Left - actAreaArr[i].Top) - DFT_MARGIN;
                 }
             }
             let div = $('<div class="pageBreak"></div>');

+ 4 - 1
web/building_saas/report/js/rpt_print.js

@@ -72,6 +72,7 @@ let rptPrintHelper = {
                 }
             }
             let svgPageArr = [];
+            console.log(pixelSize);
             svgPageArr.push("<svg width='" + pixelSize[0] + "' height='" + pixelSize[1] + "'>");
             // let adjustY = 0.5 * ((idx + 1) % 2);
             let adjustY = 0.5;
@@ -125,7 +126,9 @@ function buildCellSvg(cell, fonts, styles, controls, pageMergeBorder, rptMergeBo
     let HtoVStr = "";
     if (isHtoV) {
         //HtoVStr = ` transform="translate(`+ pixelSize[1] + `,0) rotate(90)"`;
-        HtoVStr = ` transform="translate(`+ (actArea.Bottom - actArea.Top + 5) + `,0) rotate(90)"`;
+        // HtoVStr = ` transform="translate(`+ (actArea.Bottom - actArea.Top + 5) + `,0) rotate(90)"`;
+        HtoVStr = ` transform="translate(`+ (actArea.Bottom - actArea.Top + 5) + `,` + (actArea.Left - actArea.Top ) + `) rotate(90)"`;
+        //console.log(actArea);
     }
     if (style) {
         let leftBS = getActualBorderStyle(cell, styles, mergeBandStyle, (pageMergeBorder)?pageMergeBorder:rptMergeBorder[JV.PROP_AREA], JV.PROP_LEFT);