Browse Source

Merge branch 'master' of http://smartcost.f3322.net:3000/SmartCost/ConstructionOperation

zhongzewei 7 years ago
parent
commit
4bcde00e9b

+ 13 - 8
modules/reports/controllers/rpt_controller.js

@@ -29,7 +29,7 @@ let callback = function(req, res, err, data){
     }
 };
 
-function getAllPagesCommonOrg(rpt_id, pageSize, cb) {
+function getAllPagesCommonOrg(rpt_id, pageSize, option, cb) {
     let rptTpl = null;
     rptTplFacade.getRptTemplate(rpt_id).then(function(rst) {
         rptTpl = rst;
@@ -49,8 +49,9 @@ function getAllPagesCommonOrg(rpt_id, pageSize, cb) {
                 let printCom = JpcEx.createNew();
                 rptTpl[JV.NODE_MAIN_INFO][JV.NODE_PAGE_INFO][JV.PROP_PAGE_SIZE] = pageSize;
                 let defProperties = rptUtil.getReportDefaultCache();
+                let dftOption = option||JV.PAGING_OPTION_NORMAL;
                 printCom.initialize(rptTpl);
-                printCom.analyzeData(rptTpl, tplData, defProperties);
+                printCom.analyzeData(rptTpl, tplData, defProperties, dftOption);
                 let maxPages = printCom.totalPages;
                 let pageRst = printCom.outputAsSimpleJSONPageArray(rptTpl, tplData, 1, maxPages, defProperties);
                 if (pageRst) {
@@ -113,7 +114,7 @@ module.exports = {
     getReportAllPages: function(req, res){
         let rpt_id = req.body.ID;
         let pageSize = req.body.pageSize;
-        getAllPagesCommonOrg(rpt_id, pageSize, function(err, pageRst){
+        getAllPagesCommonOrg(rpt_id, pageSize, JV.PAGING_OPTION_NORMAL, function(err, pageRst){
             //fs.writeFileSync('D:/GitHome/ConstructionOperation/tmp/testRpt.js', JSON.stringify(pageRst));
             callback(req, res, err, pageRst);
         })
@@ -122,9 +123,11 @@ module.exports = {
         let rpt_id = req.params.id,
             pageSize = req.params.size,
             rptName = req.params.rptName,
-            isOneSheet = req.params.isOneSheet;
+            isOneSheet = req.params.isOneSheet,
+            option = req.params.option;
         ;
-        getAllPagesCommonOrg(rpt_id, pageSize, function(err, pageRst){
+        let dftOption = option||JV.PAGING_OPTION_NORMAL;
+        getAllPagesCommonOrg(rpt_id, pageSize, dftOption, function(err, pageRst){
             rpt_xl_util.exportExcel(pageRst, pageSize, rptName, isOneSheet, null, function(newName){
                 res.setHeader('Content-Type', 'application/vnd.openxmlformats');
                 res.setHeader("Content-Disposition", "attachment; filename=" + strUtil.getPinYinCamelChars(rptName) + ".xlsx");
@@ -141,13 +144,15 @@ module.exports = {
     getExcelInOneBook: function(req, res) {
         let rpt_ids = req.params.ids.split(','),
             pageSize = req.params.size,
-            rptName = req.params.rptName;
+            rptName = req.params.rptName,
+            option = req.params.option;
         ;
         let parallelFucs = [];
+        let dftOption = option||JV.PAGING_OPTION_NORMAL;
         for (let id of rpt_ids) {
             parallelFucs.push((function (rpt_id) {
                 return function (cb) {
-                    getAllPagesCommonOrg(rpt_id, pageSize, function (err, pageRst) {
+                    getAllPagesCommonOrg(rpt_id, pageSize, dftOption, function (err, pageRst) {
                         if(err){
                             cb(err);
                         }
@@ -182,7 +187,7 @@ module.exports = {
             pageSize = req.params.size,
             rptName = req.params.rptName;
 
-        getAllPagesCommonOrg(rpt_id, pageSize, function(err, pageRst){
+        getAllPagesCommonOrg(rpt_id, pageSize, JV.PAGING_OPTION_NORMAL, function(err, pageRst){
             rpt_pdf_util.export_pdf_file(pageRst, pageSize, rptName,function (newName) {
                 res.setHeader('Content-Type', 'application/vnd.openxmlformats');
                 res.setHeader("Content-Disposition", "attachment; filename=" + strUtil.getPinYinCamelChars(rptName) + ".pdf");

+ 2 - 2
modules/reports/routes/report_router.js

@@ -19,8 +19,8 @@ module.exports =function (app) {
     });
     rptRouter.post('/getReport', reportController.getReportAllPages);
 
-    rptRouter.get('/getExcel/:id/:size/:rptName/:isOneSheet', reportController.getExcel);
-    rptRouter.get('/getExcelInOneBook/:ids/:size/:rptName', reportController.getExcelInOneBook);
+    rptRouter.get('/getExcel/:id/:size/:rptName/:isOneSheet/:option', reportController.getExcel);
+    rptRouter.get('/getExcelInOneBook/:ids/:size/:rptName/:option', reportController.getExcelInOneBook);
 
     rptRouter.get('/getPDF/:id/:size/:rptName', reportController.getPDF);//2/A4/07-1表
     app.use("/report_api", rptRouter);

+ 24 - 0
modules/reports/rpt_component/helper/jpc_helper_band.js

@@ -82,6 +82,30 @@ let JpcBandHelper = {
                 }
             }
         }
+    },
+    resetBandPos: function (bandCollection, bands, contentBand, offsetY) {
+        let orgY = contentBand.Bottom;
+        function chkAndResetPos(targetBand) {
+            let band = bands[targetBand.Name];
+            if (band) {
+                if (band === contentBand) {
+                    band.Bottom += offsetY;
+                } else {
+                    if (band.Top >= orgY) {
+                        band.Top += offsetY;
+                        band.Bottom += offsetY;
+                    }
+                }
+                if (targetBand[JV.BAND_PROP_SUB_BANDS]) {
+                    for (let i = 0; i < targetBand[JV.BAND_PROP_SUB_BANDS].length; i++) {
+                        chkAndResetPos(targetBand[JV.BAND_PROP_SUB_BANDS][i]);
+                    }
+                }
+            }
+        }
+        for (let i = 0; i < bandCollection.length; i++) {
+            chkAndResetPos(bandCollection[i]);
+        }
     }
 };
 

+ 23 - 4
modules/reports/rpt_component/helper/jpc_helper_flow_tab.js

@@ -3,12 +3,12 @@ let JpcCommonHelper = require('./jpc_helper_common');
 
 let JpcFlowTabHelper = {
     getMaxRowsPerPage: function(bands, rptTpl) {
-        let me = this, rst = 1;
+        let rst = 1;
         let tab = rptTpl[JV.NODE_FLOW_INFO][JV.NODE_FLOW_CONTENT];
         let band = bands[tab[JV.PROP_BAND_NAME]];
         if (band) {
             let maxFieldMeasure = 1.0;
-            if (JV.CAL_TYPE_ABSTRACT == JpcCommonHelper.getPosCalculationType(tab[JV.PROP_CALCULATION])) {
+            if (JV.CAL_TYPE_ABSTRACT === JpcCommonHelper.getPosCalculationType(tab[JV.PROP_CALCULATION])) {
                 let unitFactor = JpcCommonHelper.getUnitFactor(rptTpl);
                 maxFieldMeasure = 1.0 * rptTpl[JV.NODE_FLOW_INFO][JV.NODE_FLOW_CONTENT][JV.PROP_CMN_HEIGHT] * unitFactor;
             } else {
@@ -18,6 +18,25 @@ let JpcFlowTabHelper = {
         }
         return rst;
     },
+    getActualContentAreaHeight: function(bands, rptTpl, segments, page) {
+        let rst = 1;
+        let tab = rptTpl[JV.NODE_FLOW_INFO][JV.NODE_FLOW_CONTENT];
+        let band = bands[tab[JV.PROP_BAND_NAME]];
+        if (band) {
+            let maxFieldMeasure = 1.0;
+            if (JV.CAL_TYPE_ABSTRACT === JpcCommonHelper.getPosCalculationType(tab[JV.PROP_CALCULATION])) {
+                let unitFactor = JpcCommonHelper.getUnitFactor(rptTpl);
+                maxFieldMeasure = 1.0 * rptTpl[JV.NODE_FLOW_INFO][JV.NODE_FLOW_CONTENT][JV.PROP_CMN_HEIGHT] * unitFactor;
+            } else {
+                maxFieldMeasure = (band.Bottom - band.Top) * rptTpl[JV.NODE_FLOW_INFO][JV.NODE_FLOW_CONTENT][JV.PROP_CMN_HEIGHT] / JV.HUNDRED_PERCENT;
+            }
+            //rst = Math.floor((band.Bottom - band.Top) / maxFieldMeasure);
+            if (segments.length >= page) {
+                rst = segments[page - 1].length * maxFieldMeasure;
+            }
+        }
+        return rst;
+    },
     chkSegEnd: function (bands, rptTpl, sortedSequence, segIdx, preRec, nextRec) {
         let me = this, rst = true;
         let remainAmt = preRec + nextRec - sortedSequence[segIdx].length;
@@ -30,10 +49,10 @@ let JpcFlowTabHelper = {
         let unitFactor = JpcCommonHelper.getUnitFactor(rptTpl);
         let tab = rptTpl[JV.NODE_FLOW_INFO][JV.NODE_FLOW_CONTENT];
         let band = bands[tab[JV.PROP_BAND_NAME]];
-        if (band != null && band != undefined) {
+        if (band !== null && band !== undefined) {
             measurement = 1.0 * tab[JV.PROP_CMN_HEIGHT] * unitFactor;
             let spareHeight = measurement * remainAmt;
-            let douH = 1.0 * (band.Bottom - band.Top);
+            let douH = band.Bottom - band.Top;
             rst = (spareHeight >= douH) || (spareHeight - douH <= douDiffForCompare);
         }
         return rst;

+ 2 - 2
modules/reports/rpt_component/jpc_cross_tab.js

@@ -226,8 +226,8 @@ JpcCrossTabSrv.prototype.createNew = function(){
 
         }
     };
-    JpcCrossTabResult.preSetupPages = function(rptTpl, defProperties) {
-        let rst = 0, me = this;
+    JpcCrossTabResult.preSetupPages = function(rptTpl, defProperties, option) {
+        let rst = 0, me = this, dftPagingOption = option||JV.PAGING_OPTION_NORMAL;
         //1. original initialize
         let maxRowRec = 1, maxColRec = 1, counterRowRec = 0, counterColRec = 0, pageIdx = 0, segCnt = me.sortedContentSequence.length;
         let pageStatus = [true, true, false, true, false, false, false, false];

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

@@ -109,8 +109,8 @@ JpcExSrv.prototype.createNew = function(){
         me.formulas = JpcFunc.createNew(rptTpl);
     };
 
-    JpcResult.analyzeData = function(rptTpl, dataObj, defProperties) {
-        let me = this;
+    JpcResult.analyzeData = function(rptTpl, dataObj, defProperties, option) {
+        let me = this, dftPagingOption = option||JV.PAGING_OPTION_NORMAL;
         //1. data object
         let dataHelper = JpcData.createNew();
         dataHelper.analyzeData(rptTpl, dataObj);
@@ -131,17 +131,17 @@ JpcExSrv.prototype.createNew = function(){
         //3. formulas
         me.executeFormulas(JV.RUN_TYPE_BEFORE_PAGING, rptTpl, dataObj, me);
         //4. paging
-        me.paging(rptTpl, dataObj, defProperties);
+        me.paging(rptTpl, dataObj, defProperties, dftPagingOption);
         //alert('analyzeData was completed!');
         //for garbage collection:
         dataHelper = null;
     };
-    JpcResult.paging = function(rptTpl, dataObj, defProperties) {
-        let me = this;
+    JpcResult.paging = function(rptTpl, dataObj, defProperties, option) {
+        let me = this, dftPagingOption = option||JV.PAGING_OPTION_NORMAL;
         if (me.flowTab) {
-            me.totalPages = me.flowTab.preSetupPages(rptTpl, dataObj, defProperties);
+            me.totalPages = me.flowTab.preSetupPages(rptTpl, dataObj, defProperties, dftPagingOption);
             if (me.flowTabEx) {
-                me.exTotalPages = me.flowTabEx.preSetupPages(rptTpl, dataObj, defProperties);
+                me.exTotalPages = me.flowTabEx.preSetupPages(rptTpl, dataObj, defProperties, dftPagingOption);
                 //console.log('ad-hoc flow pages: ' + me.exTotalPages);
             }
             me.totalPages += me.exTotalPages;

+ 93 - 54
modules/reports/rpt_component/jpc_flow_tab.js

@@ -28,6 +28,7 @@ JpcFlowTabSrv.prototype.createNew = function(){
     JpcFlowTabResult.initialize = function(isEx) {
         let me = this;
         me.isEx = isEx;
+        me.paging_option = JV.PAGING_OPTION_NORMAL;
         me.segments = [];
         me.dispValueIdxLst = [];
         me.page_seg_map = [];
@@ -73,69 +74,107 @@ JpcFlowTabSrv.prototype.createNew = function(){
 
         }
     };
-    JpcFlowTabResult.preSetupPages = function (rptTpl, dataOjb, defProperties) {
-        let rst = 0, me = this, counterRowRec = 0, maxRowRec = 1, pageIdx = 0;
+    JpcFlowTabResult.preSetupPages = function (rptTpl, dataOjb, defProperties, option) {
+        let me = this, rst = 1, counterRowRec = 0, maxRowRec = 1, pageIdx = 0;
+        me.paging_option = option||JV.PAGING_OPTION_NORMAL;
         let CURRENT_FLOW_INFO = (me.isEx)?JV.NODE_FLOW_INFO_EX:JV.NODE_FLOW_INFO;
         JpcFieldHelper.findAndPutDataFieldIdx(rptTpl, rptTpl[CURRENT_FLOW_INFO][JV.NODE_FLOW_CONTENT][JV.PROP_FLOW_FIELDS], null, me.disp_fields_idx, me.isEx);
-        let bands = JpcBand.createNew(rptTpl, defProperties);
-        let pageStatus = [true, true, false, false, false, false, false, false];
-        if (me.isEx) {
-            pageStatus[JV.STATUS_REPORT_START] = false;
-        }
-        if (rptTpl[CURRENT_FLOW_INFO][JV.PROP_MULTI_COLUMN]) {
-            me.multiCols = 1 * rptTpl[CURRENT_FLOW_INFO][JV.PROP_MULTI_COLUMN];
-        }
-        function private_resetBandArea() {
-            JpcBandHelper.setBandArea(bands, rptTpl, pageStatus, !me.isEx, me.isEx);
-            maxRowRec = JpcFlowTabHelper.getMaxRowsPerPage(bands, rptTpl);
-        }
-        for (let segIdx = 0; segIdx < me.segments.length; segIdx++) {
-            private_resetBandArea();
-            let orgMaxRowRec = maxRowRec;
-            let rowSplitCnt = Math.ceil(1.0 * me.segments[segIdx].length / orgMaxRowRec);
-            pageStatus[JV.STATUS_SEGMENT_END] = true;
-            private_resetBandArea();
-            let hasAdHocRow = !JpcFlowTabHelper.chkSegEnd(bands, rptTpl, me.segments, segIdx, (rowSplitCnt - 1) * orgMaxRowRec, maxRowRec);
-            if (hasAdHocRow) rowSplitCnt++;
-            if (rowSplitCnt % me.multiCols > 0) {
-                rowSplitCnt++
-            }
-            for (let rowIdx = 0; rowIdx < rowSplitCnt; rowIdx++) {
-                pageStatus[JV.STATUS_SEGMENT_END] = rowIdx == (rowSplitCnt - 1)?true:false;
-                if (pageIdx > 0) pageStatus[JV.STATUS_REPORT_START] = false;
-                private_resetBandArea();
+        if (me.paging_option === JV.PAGING_OPTION_INFINITY_VERTICAL) {
+            rst = me.segments.length;
+            let pageStatus = [true, true, false, true, true, true, false, false];
+            for (let segIdx = 0; segIdx < me.segments.length; segIdx++) {
+                if (segIdx === me.segments.length - 1) {
+                    pageStatus[JV.STATUS_REPORT_END] = true;
+                }
+                if (segIdx > 0) {
+                    pageStatus[JV.STATUS_REPORT_START] = false;
+                }
                 me.pageStatusLst.push(pageStatus.slice(0));
                 pageIdx++;
-                counterRowRec = orgMaxRowRec * rowIdx;
-                private_addPageValue(me.dispValueIdxLst, me.segments[segIdx], counterRowRec, maxRowRec,me.page_seg_map, segIdx, pageIdx);
+                private_addPageValue(me.dispValueIdxLst, me.segments[segIdx], 0, me.segments[segIdx].length, me.page_seg_map, segIdx, pageIdx);
+            }
+        } else {
+            let bands = JpcBand.createNew(rptTpl, defProperties);
+            let pageStatus = [true, true, false, true, false, false, false, false];
+            if (me.isEx) {
+                pageStatus[JV.STATUS_REPORT_START] = false;
+            }
+            if (rptTpl[CURRENT_FLOW_INFO][JV.PROP_MULTI_COLUMN]) {
+                me.multiCols = 1 * rptTpl[CURRENT_FLOW_INFO][JV.PROP_MULTI_COLUMN];
+            }
+            function private_resetBandArea() {
+                JpcBandHelper.setBandArea(bands, rptTpl, pageStatus, !me.isEx, me.isEx);
+                maxRowRec = JpcFlowTabHelper.getMaxRowsPerPage(bands, rptTpl);
             }
-            pageStatus[JV.STATUS_SEGMENT_END] = false;
-            pageStatus[JV.STATUS_REPORT_START] = false;
+            for (let segIdx = 0; segIdx < me.segments.length; segIdx++) {
+                private_resetBandArea();
+                let orgMaxRowRec = maxRowRec;
+                let rowSplitCnt = Math.ceil(1.0 * me.segments[segIdx].length / orgMaxRowRec);
+                pageStatus[JV.STATUS_SEGMENT_END] = true;
+                private_resetBandArea();
+                let hasAdHocRow = !JpcFlowTabHelper.chkSegEnd(bands, rptTpl, me.segments, segIdx, (rowSplitCnt - 1) * orgMaxRowRec, maxRowRec);
+                if (hasAdHocRow) rowSplitCnt++;
+                if (rowSplitCnt % me.multiCols > 0) {
+                    rowSplitCnt++
+                }
+                for (let rowIdx = 0; rowIdx < rowSplitCnt; rowIdx++) {
+                    pageStatus[JV.STATUS_SEGMENT_END] = (rowIdx === (rowSplitCnt - 1));
+                    if (pageIdx > 0) pageStatus[JV.STATUS_REPORT_START] = false;
+                    private_resetBandArea();
+                    me.pageStatusLst.push(pageStatus.slice(0));
+                    pageIdx++;
+                    counterRowRec = orgMaxRowRec * rowIdx;
+                    private_addPageValue(me.dispValueIdxLst, me.segments[segIdx], counterRowRec, maxRowRec,me.page_seg_map, segIdx, pageIdx);
+                }
+                pageStatus[JV.STATUS_SEGMENT_END] = false;
+                pageStatus[JV.STATUS_REPORT_START] = false;
+            }
+            rst = Math.ceil(pageIdx / me.multiCols);
         }
-        rst = Math.ceil(1.0 * pageIdx / me.multiCols);
         me.pagesAmt = rst;
         return rst;
     };
     JpcFlowTabResult.outputAsSimpleJSONPage = function (rptTpl, dataObj, page, bands, controls, $CURRENT_RPT) {
         let me = this, rst = [], tabRstLst = [];
         let FLOW_NODE_STR = me.isEx?JV.NODE_FLOW_INFO_EX:JV.NODE_FLOW_INFO;
-        let segIdx = JpcCommonHelper.getSegIdxByPageIdx(page, me.page_seg_map);
-        //1 calculate the band position
-        JpcBandHelper.setBandArea(bands, rptTpl, me.pageStatusLst[page - 1], !me.isEx, me.isEx);
-        //2. start to output detail-part
         let unitFactor = JpcCommonHelper.getUnitFactor(rptTpl);
-        for (let pi = 0; pi < me.multiCols; pi++) {
-            let actualPage = (page - 1) * me.multiCols + pi + 1;
-            //2.1 Content-Tab
-            tabRstLst.push(me.outputContent(rptTpl, dataObj, actualPage, bands, unitFactor, controls, pi, $CURRENT_RPT));
+        if (me.paging_option === JV.PAGING_OPTION_INFINITY_VERTICAL) {
+            let segIdx = page - 1;
+            //1 calculate the band position
+            JpcBandHelper.setBandArea(bands, rptTpl, me.pageStatusLst[page - 1], !me.isEx, me.isEx);
+            //2. then reset the band height
+            let tab = rptTpl[JV.NODE_FLOW_INFO][JV.NODE_FLOW_CONTENT];
+            let flowContentBand = bands[tab[JV.PROP_BAND_NAME]];
+            let actH = JpcFlowTabHelper.getActualContentAreaHeight(bands, rptTpl, me.segments, page);
+            let offsetY = actH - (flowContentBand.Bottom - flowContentBand.Top);
+            JpcBandHelper.resetBandPos(rptTpl[JV.NODE_BAND_COLLECTION], bands, flowContentBand, offsetY);
+
+            tabRstLst.push(me.outputContent(rptTpl, dataObj, page, bands, unitFactor, controls, 0, $CURRENT_RPT));
             //2.2 Column tab
-            tabRstLst.push(me.outputColumn(rptTpl, dataObj, actualPage, segIdx, bands, unitFactor, controls, pi));
+            tabRstLst.push(me.outputColumn(rptTpl, dataObj, page, segIdx, bands, unitFactor, controls, 0));
             //2.3 Sum Seg
-            tabRstLst.push(me.outputSegSum(rptTpl, dataObj, actualPage, segIdx, bands, unitFactor, controls));
+            tabRstLst.push(me.outputSegSum(rptTpl, dataObj, page, segIdx, bands, unitFactor, controls));
             //2.4 Sum Page
             //2.5 Discrete
-            if (pi == 0) {
-                tabRstLst.push(JpcDiscreteHelper.outputDiscreteInfo(rptTpl[FLOW_NODE_STR][JV.NODE_DISCRETE_INFO], bands, dataObj, unitFactor, me.pageStatusLst[actualPage - 1], segIdx, 1, pi, $CURRENT_RPT));
+            tabRstLst.push(JpcDiscreteHelper.outputDiscreteInfo(rptTpl[FLOW_NODE_STR][JV.NODE_DISCRETE_INFO], bands, dataObj, unitFactor, me.pageStatusLst[page - 1], segIdx, 1, 0, $CURRENT_RPT));
+        } else {
+            let segIdx = JpcCommonHelper.getSegIdxByPageIdx(page, me.page_seg_map);
+            //1 calculate the band position
+            JpcBandHelper.setBandArea(bands, rptTpl, me.pageStatusLst[page - 1], !me.isEx, me.isEx);
+            //2. start to output detail-part
+            for (let pi = 0; pi < me.multiCols; pi++) {
+                let actualPage = (page - 1) * me.multiCols + pi + 1;
+                //2.1 Content-Tab
+                tabRstLst.push(me.outputContent(rptTpl, dataObj, actualPage, bands, unitFactor, controls, pi, $CURRENT_RPT));
+                //2.2 Column tab
+                tabRstLst.push(me.outputColumn(rptTpl, dataObj, actualPage, segIdx, bands, unitFactor, controls, pi));
+                //2.3 Sum Seg
+                tabRstLst.push(me.outputSegSum(rptTpl, dataObj, actualPage, segIdx, bands, unitFactor, controls));
+                //2.4 Sum Page
+                //2.5 Discrete
+                if (pi === 0) {
+                    tabRstLst.push(JpcDiscreteHelper.outputDiscreteInfo(rptTpl[FLOW_NODE_STR][JV.NODE_DISCRETE_INFO], bands, dataObj, unitFactor, me.pageStatusLst[actualPage - 1], segIdx, 1, pi, $CURRENT_RPT));
+                }
             }
         }
         for (let i = 0; i < tabRstLst.length; i++) {
@@ -151,14 +190,14 @@ JpcFlowTabSrv.prototype.createNew = function(){
         let band = bands[tab[JV.PROP_BAND_NAME]];
         if (band) {
             let pageStatus = me.pageStatusLst[page - 1];
-            if (pageStatus[band[JV.BAND_PROP_DISPLAY_TYPE]] == true) {
+            if (pageStatus[band[JV.BAND_PROP_DISPLAY_TYPE]]) {
                 let tab_fields = tab[JV.PROP_FLOW_FIELDS];
                 let data_details = me.isEx?dataObj[JV.DATA_DETAIL_DATA_EX]:dataObj[JV.DATA_DETAIL_DATA];
                 let contentValuesIdx = me.dispValueIdxLst[page - 1];
                 for (let i = 0; i < tab_fields.length; i++) {
                     let tab_field = tab_fields[i];
                     let data_field = null;
-                    if (me.disp_fields_idx[i] != JV.BLANK_FIELD_INDEX) {
+                    if (me.disp_fields_idx[i] !== JV.BLANK_FIELD_INDEX) {
                         data_field = data_details[me.disp_fields_idx[i]];
                     } else {
                         data_field = JE.F(tab_field[JV.PROP_FIELD_ID], $CURRENT_RPT);
@@ -183,7 +222,7 @@ JpcFlowTabSrv.prototype.createNew = function(){
         let band = bands[tab[JV.PROP_BAND_NAME]];
         if (band) {
             let pageStatus = me.pageStatusLst[page - 1];
-            if (pageStatus[band[JV.BAND_PROP_DISPLAY_TYPE]] == true) {
+            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, me.multiCols, multiColIdx));
                 }
@@ -206,7 +245,7 @@ JpcFlowTabSrv.prototype.createNew = function(){
         let band = bands[tab[JV.PROP_BAND_NAME]];
         if (band) {
             let pageStatus = me.pageStatusLst[page - 1];
-            if (pageStatus[band[JV.BAND_PROP_DISPLAY_TYPE]] == true) {
+            if (pageStatus[band[JV.BAND_PROP_DISPLAY_TYPE]]) {
                 let tab_fields = me.seg_sum_tab_fields;
                 for (let i = 0; i < tab_fields.length; i++) {
                     let cellItem = JpcCommonOutputHelper.createCommonOutput(tab_fields[i], me.segSumValLst[segIdx][i], controls);
@@ -229,13 +268,13 @@ JpcFlowTabSrv.prototype.createNew = function(){
         return rst;
     };
     JpcFlowTabResult.outputTabField = function (band, tab_field, data_field, valueIdx, serialIdx, rows, rowIdx, cols, colIdx, unitFactor, isRow, controls, multiColIdx) {
-        let me = this, rst = null;
-        rst = JpcCommonOutputHelper.createCommonOutput(tab_field, JpcFieldHelper.getValue(data_field, valueIdx), controls);
+        let me = this,
+            rst = JpcCommonOutputHelper.createCommonOutput(tab_field, JpcFieldHelper.getValue(data_field, valueIdx), controls);
         rst[JV.PROP_AREA] = JpcAreaHelper.outputArea(tab_field[JV.PROP_AREA], band, unitFactor, rows, rowIdx, cols, colIdx, me.multiCols, multiColIdx, true, false);
         return rst;
-    }
+    };
 
     return JpcFlowTabResult;
-}
+};
 
 module.exports = new JpcFlowTabSrv();

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

@@ -794,6 +794,9 @@ function writeSheet(pageData, sheetData, paperSize, sharedStrList, stylesObj){
         pStr = 'paperSize="' + JV.PAGES_SIZE_IDX[paperSizeIdx] + '"';
     }
     let orientationStr = (pageData[JV.NODE_PAGE_INFO][JV.NODE_PAGE_SIZE][0] > pageData[JV.NODE_PAGE_INFO][JV.NODE_PAGE_SIZE][1])?'landscape':'portrait';
+    if (currentPageMergePos) {
+        orientationStr = (currentPageMergePos[JV.NODE_PAGE_SIZE][0] > currentPageMergePos[JV.NODE_PAGE_SIZE][1])?'landscape':'portrait';
+    }
     rst.push('<pageSetup ' + pStr + ' fitToWidth="0" fitToHeight="0" orientation="' + orientationStr + '" />');
     rst.push('<headerFooter alignWithMargins="0"/>');
     rst.push('</worksheet>');
@@ -967,6 +970,7 @@ module.exports = {
                         pageItem[JV.PROP_CELLS].push(pageDataArray[i].items[j].cells[k]);
                     }
                 }
+                newPagePos[i][JV.NODE_PAGE_SIZE] = pageDataArray[i][JV.NODE_PAGE_INFO][JV.NODE_PAGE_SIZE];
                 pageItem[JV.PAGE_SPECIAL_MERGE_POS] = newPagePos[i];
                 newPageData.items.push(pageItem);
             }

+ 5 - 3
modules/users/controllers/compilation_controller.js

@@ -429,7 +429,7 @@ class CompilationController extends BaseController {
      * @param {object} response
      * @return {void}
      */
-    async template(request, response) {
+    async billsTemplate(request, response) {
         let billList = {};
         let valuationList = {};
         let valuationData = {};
@@ -437,6 +437,7 @@ class CompilationController extends BaseController {
         let billsTemplateData = [];
 
         let selectedCompilation = request.session.selectedCompilation;
+        let engineering = request.params.engineering;
         let valuationId = request.params.id;
         let section = request.params.section;
 
@@ -458,6 +459,7 @@ class CompilationController extends BaseController {
         }
 
         let renderData = {
+            engineering: engineering,
             billList: JSON.stringify(billList),
             billsTemplateData: JSON.stringify(billsTemplateData),
             billsFixedFlagList: JSON.stringify(BillsFixedFlagList),
@@ -479,19 +481,19 @@ class CompilationController extends BaseController {
      * @param response
      */
     async updateBillsTemplate(request, response) {
+        let engineering = request.params.engineering;
         let valuationId = request.params.id;
         let section = request.params.section;
         let data = JSON.parse(request.body.data);
 
         let billsTemplateModel = new BillsTemplateModel();
-        let result = await billsTemplateModel.updateTemplate(valuationId, data);
+        let result = await billsTemplateModel.updateTemplate(valuationId, engineering, data);
 
         if (result) {
             response.json({error: 0, message: '', data: data});
         } else {
             response.json({error: 1, message: '更新数据错误', data: null});
         }
-
     }
 
 }

+ 9 - 6
modules/users/models/bills_template_model.js

@@ -20,12 +20,13 @@ class BillsTemplateModel extends BaseModel {
     /**
      * 获取计价类别对应的清单模板
      * @param valuationId
+     * @param engineering
      * @returns {*}
      */
-    async getTemplateData (valuationId) {
+    async getTemplateData (valuationId, engineering) {
         // 筛选字段
         let field = {_id: 1, valuationId: 1, ID: 1, ParentID: 1, NextSiblingID: 1, code: 1, name: 1, unit: 1, flags: 1};
-        let data = await this.findDataByCondition({valuationId: valuationId}, field, false);
+        let data = await this.findDataByCondition({valuationId: valuationId, engineering: engineering}, field, false);
 
         return data === null ? [] : data;
     }
@@ -33,20 +34,22 @@ class BillsTemplateModel extends BaseModel {
     /**
      * 新建项目时,获取计价类别对应的清单模板
      * @param valuationId
+     * @param engineering
      * @returns {*}
      */
-    async getTemplateDataForNewProj (valuationId) {
+    async getTemplateDataForNewProj (valuationId, engineering) {
         // 筛选字段
-        let field = {ID: 1, ParentID: 1, NextSiblingID: 1, code: 1, name: 1, unit: 1, flags: 1};
-        let data = await this.findDataByCondition({valuationId: valuationId}, field, false);
+        let field = {_id: 0, ID: 1, ParentID: 1, NextSiblingID: 1, code: 1, name: 1, unit: 1, flags: 1};
+        let data = await this.findDataByCondition({valuationId: valuationId, engineering: engineering}, field, false);
 
         return data === null ? [] : data;
     }
 
-    async updateTemplate (valuationId, datas) {
+    async updateTemplate (valuationId, engineering, datas) {
         try {
             for (let data of datas) {
                 data.data.valuationId = valuationId;
+                data.data.engineering = engineering;
                 let condition = {valuationId: valuationId, ID: data.data.ID}, result;
                 if (data.type === 'update') {
                     result = await this.db.update(condition, data.data);

+ 3 - 0
modules/users/models/compilation_model.js

@@ -96,6 +96,7 @@ class CompilationModel extends BaseModel {
             throw '计价规则名称为空';
         }
         if (this.sectionList.indexOf(section) < 0) {
+            console.log('2');
             throw '数据有误';
         }
 
@@ -156,6 +157,7 @@ class CompilationModel extends BaseModel {
      */
     _filterValuationData(data) {
         if (Object.keys(data).length <= 0) {
+            console.log('3');
             throw '数据有误';
         }
 
@@ -181,6 +183,7 @@ class CompilationModel extends BaseModel {
      */
     async getValuation(compilationId, id, section) {
         if (this.sectionList.indexOf(section) < 0) {
+            console.log('4');
             throw '数据有误';
         }
         let compilationData = await this.findDataByCondition({_id: compilationId});

+ 5 - 0
modules/users/models/engineering_lib_model.js

@@ -56,6 +56,10 @@ class EngineeringLibModel extends BaseModel {
      * @return {Promise}
      */
     async addLib(valuationId, data) {
+        if (data.main_tree_col) {
+            data.main_tree_col = JSON.parse(data.main_tree_col);
+        }
+
         let result = false;
         data = this.filterLibData(data);
         try {
@@ -106,6 +110,7 @@ class EngineeringLibModel extends BaseModel {
      */
     filterLibData(data) {
         if (Object.keys(data).length <= 0 || data.section === undefined) {
+            console.log('1');
             throw '数据有误';
         }
         // 检测专业工程是否合法

+ 3 - 1
modules/users/models/schemas/bills_template.js

@@ -28,7 +28,9 @@ let BillsTemplateSchema = {
         default: []
     },
     // 所属计价ID
-    valuationId: String
+    valuationId: String,
+    // 工程专业
+    engineering: Number
 };
 
 let model = mongoose.model(collectionName, new Schema(BillsTemplateSchema, {versionKey: false, collection: collectionName}));

+ 2 - 2
modules/users/routes/compilation_route.js

@@ -17,7 +17,7 @@ module.exports = function (app) {
     router.get('/valuation/:section/:id', compilationController.auth, compilationController.init, compilationController.editValuation);
     router.get('/:section/:id/:engineering', compilationController.auth, compilationController.init, compilationController.editEngineering);
     router.get('/valuation/:section/delete/:id', compilationController.auth, compilationController.init, compilationController.deleteValuation);
-    router.get('/template/:section/:id', compilationController.auth, compilationController.init, compilationController.template);
+    router.get('/template/:section/:id/:engineering', compilationController.auth, compilationController.init, compilationController.billsTemplate);
 
     router.post('/release', compilationController.auth, compilationController.init, compilationController.release);
     router.post('/add', compilationController.auth, compilationController.init, compilationController.addCompilation);
@@ -25,7 +25,7 @@ module.exports = function (app) {
     router.post('/save-valuation', compilationController.auth, compilationController.init, compilationController.saveValuation);
     router.post('/save-lib', compilationController.auth, compilationController.init, compilationController.saveEngineering);
     router.post('/valuation/:section/enable', compilationController.auth, compilationController.init, compilationController.enableSwitch);
-    router.post('/template/:section/:id/update', compilationController.auth, compilationController.init, compilationController.updateBillsTemplate)
+    router.post('/template/:section/:id/:engineering/update', compilationController.auth, compilationController.init, compilationController.updateBillsTemplate);
 
     app.use("/compilation", router);
 };

+ 5 - 0
public/web/rpt_value_define.js

@@ -195,6 +195,11 @@ let JV = {
     PROP_PAGE_SEQ: "page_seq",
     PROP_CELLS: "cells",
 
+    PAGING_OPTION_NORMAL: 'normal',
+    PAGING_OPTION_INFINITY_HORIZON: 'infinity_horizon',
+    PAGING_OPTION_INFINITY_VERTICAL: 'infinity_vertical',
+    PAGING_OPTION_INFINITY_BOTH: 'infinity_both',
+
     PAGE_SELF_DEFINE: "自定义",
     PAGE_SPECIAL_MERGE_POS: "page_merge_pos",
 

+ 21 - 20
test/calculation/testJSCalc.js

@@ -4,25 +4,26 @@
 
 var test = require('tape');
 
-// test('计算式测试', function(t){
-//     console.log(10 / 96 * 25.4 / 0.3612);
-//     t.pass('just pass for js calculation!');
-//     t.end();
-// })
-
-test('四舍五入测试', function(t){
-    let a1 = Math.round(17.4, 2);
-    let a2 = Math.round(17.5, 2);
-    let a3 = Math.round(17.6, 2);
-    let a4 = Math.round(18.4, 2);
-    let a5 = Math.round(18.5, 2);
-    let a6 = Math.round(18.6, 2);
-    console.log(a1);
-    console.log(a2);
-    console.log(a3);
-    console.log(a4);
-    console.log(a5);
-    console.log(a6);
+test('计算式测试', function(t){
+    //console.log(10 / 96 * 25.4 / 0.3612);
+    console.log(16 / 18);
     t.pass('just pass for js calculation!');
     t.end();
-})
+})
+
+// test('四舍五入测试', function(t){
+//     let a1 = Math.round(17.4, 2);
+//     let a2 = Math.round(17.5, 2);
+//     let a3 = Math.round(17.6, 2);
+//     let a4 = Math.round(18.4, 2);
+//     let a5 = Math.round(18.5, 2);
+//     let a6 = Math.round(18.6, 2);
+//     console.log(a1);
+//     console.log(a2);
+//     console.log(a3);
+//     console.log(a4);
+//     console.log(a5);
+//     console.log(a6);
+//     t.pass('just pass for js calculation!');
+//     t.end();
+// })

+ 7 - 2
web/maintain/report/rpt_test.html

@@ -39,6 +39,10 @@
                     <input type="checkbox" id="isOneSheetChk" onclick="isOneSheet = this.checked;">
                     Excel单页输出
                 </label>
+                <label>
+                    <input type="checkbox" id="outputOptionChk">
+                    连续输出
+                </label>
             </td>
         </tr>
     </table>
@@ -123,12 +127,13 @@
     function getExcel() {
         let rpt = document.getElementById("select_k1");
         let size = document.getElementById("select_k2");
+        let optionChk = document.getElementById("outputOptionChk");
         let rpt_name = rpt.options[rpt.selectedIndex].text;
         if (rpt.selectedIndex >= 0 && size.selectedIndex >= 0) {
             rpt_id = rpt.options[rpt.selectedIndex].value;
             rpt_size = size.options[size.selectedIndex].value;
         }
-        let url =  "/report_api/getExcel/" + rpt_id + "/" + rpt_size + "/" + rpt_name + "/" + isOneSheet;
+        let url =  "/report_api/getExcel/" + rpt_id + "/" + rpt_size + "/" + rpt_name + "/" + isOneSheet + "/" + (optionChk.checked?'infinity_vertical':'normal');
         window.location = url;//这里不能使用get方法跳转,否则下载不成功
     }
 
@@ -136,7 +141,7 @@
         let rptIds = "2,3";
         let size = "A4";
         let rpt_name = 'OneBook';
-        let url =  "/report_api/getExcelInOneBook/" + rptIds + "/" + size + "/" + rpt_name;
+        let url =  "/report_api/getExcelInOneBook/" + rptIds + "/" + size + "/" + rpt_name + "/normal";
         window.location = url;//这里不能使用get方法跳转,否则下载不成功
     }
 

+ 1 - 1
web/users/views/compilation/engineering.html

@@ -91,7 +91,7 @@
                         <legend>
                             清单模板 / 造价书列
                             <a href="javascript:void(0)" data-toggle="modal" data-target="#set-column" class="btn btn-primary btn-sm pull-right">设置</a>
-                            <a href="/compilation/template/<%= section %>/<%= valuationId %>" data-toggle="modal" data-target="" class="btn btn-primary btn-sm pull-right" style="margin-right:5px">模板设置</a>
+                            <a href="/compilation/template/<%= section %>/<%= valuationId %>/<%= engineeringInfo.id%>" data-toggle="modal" data-target="" class="btn btn-primary btn-sm pull-right" style="margin-right:5px">模板设置</a>
                             <input type="hidden" name="main_tree_col" value="<%= mainTreeCol %>">
                             <div id="main-tree-col">
                             </div>

+ 1 - 1
web/users/views/compilation/template.html

@@ -53,7 +53,7 @@
 <script>
     let billsTemplateData = '<%- billsTemplateData %>';
     let billsFixedFlagList = '<%- billsFixedFlagList %>';
-    let updateUrl = '/compilation/template/<%= section %>/<%= valuationId %>/update';
+    let updateUrl = '/compilation/template/<%= section %>/<%= valuationId %>/<%= engineering %>/update';
 </script>
 <script type="text/javascript" src="/public/web/id_tree.js"></script>
 <script type="text/javascript" src="/public/web/tree_sheet/tree_sheet_helper.js"></script>