Просмотр исходного кода

01-1/01-2表单选一个标段报错问题 + 统一导出Excel/PDF/打印预览(如已选标段,无需重复再选)

TonyKang 6 лет назад
Родитель
Сommit
604c43d686

+ 1 - 1
modules/main/facade/project_facade.js

@@ -300,7 +300,7 @@ async function getBudgetSummayDatas(projectIDs){
         names.push(mp.name);
         prjTypeNames.push(mp.prjTypeName);
         compilationScopes.push(mp.compilationScope);
-        if(projects.length == 0) decimal = await decimal_facade.getProjectDecimal(mp.ParentID);//如果只有一个项目,则没走合并的那一步,decimal会为空,从面报错
+        if(projects.length == 1) decimal = await decimal_facade.getProjectDecimal(projectIDs[0]);//如果只有一个项目,则没走合并的那一步,decimal会为空,从面报错
         for(let i = 1;i<projects.length;i++){
             names.push(projects[i].name);
             prjTypeNames.push(projects[i].prjTypeName);

+ 33 - 10
modules/reports/controllers/rpt_controller.js

@@ -627,24 +627,40 @@ module.exports = {
         })
     },
     getMultiReportsEx: function (req, res) {
-        //原则说明:把所有报表模板集中获取,统一filter,只读一次数据!(有空再整)
+        //原则说明:把所有报表模板集中获取,统一filter,只读一次数据!
         let params = JSON.parse(req.body.params),
             prj_id = params.prj_id,
-            rpt_ids = params.rpt_ids.split(','),
+            rpt_ids = params.rpt_ids,
+            //--以下是汇总类数据----------
+            rpt_bill_tpl_ids = params.rpt_bill_tpl_ids,
+            rpt_glj_tpl_ids = params.rpt_glj_tpl_ids,
+            prjIds = params.prjIds,
+            //------------
             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;
-        getMultiRptsCommon(user_id, prj_id, rpt_ids, pageSize, orientation, customizeCfg, dftOption, JV.OUTPUT_TYPE_NORMAL, function (err, rptPageRstArray) {
-            if(err){
-                callback(req, res, '数据有误', null);
-            }
-            else{
-                callback(req, res, err, rptPageRstArray);
-            }
-        });
+        if (rpt_ids && rpt_ids.length > 0) {
+            getMultiRptsCommon(user_id, prj_id, rpt_ids, pageSize, orientation, customizeCfg, dftOption, JV.OUTPUT_TYPE_PDF, function (err, rptPageRstArray) {
+                if (err) {
+                    callback(req, res, '数据有误', null);
+                } else {
+                    if ((rpt_bill_tpl_ids && rpt_bill_tpl_ids.length > 0) || (rpt_glj_tpl_ids && rpt_glj_tpl_ids.length > 0)) {
+                        getSummaryComboPages(user_id, prjIds, rpt_bill_tpl_ids, rpt_glj_tpl_ids, pageSize, orientation, customizeCfg, option, JV.OUTPUT_TYPE_NORMAL, function (err, rptSumPageRstArray) {
+                            callback(req, res, err, rptSumPageRstArray.concat(rptPageRstArray));
+                        });
+                    } else {
+                        callback(req, res, err, rptPageRstArray);
+                    }
+                }
+            });
+        } else if ((rpt_bill_tpl_ids && rpt_bill_tpl_ids.length > 0) || (rpt_glj_tpl_ids && rpt_glj_tpl_ids.length > 0)) {
+            getSummaryComboPages(user_id, prjIds, rpt_bill_tpl_ids, rpt_glj_tpl_ids, pageSize, orientation, customizeCfg, option, JV.OUTPUT_TYPE_NORMAL, function (err, rptSumPageRstArray) {
+                callback(req, res, err, rptSumPageRstArray);
+            });
+        }
     },
 
     getBillSummaryReportPages: function (req, res) {
@@ -762,6 +778,7 @@ module.exports = {
         if (rpt_ids && rpt_ids.length > 0) {
             getMultiRptsCommon(user_id, prj_id, rpt_ids, pageSize, orientation, customizeCfg, dftOption, JV.OUTPUT_TYPE_NORMAL, function (err, rptPageRstArray) {
                 if(err){
+                    console.log('导出Excel错误(生成数据过程错误), userId: ' + user_id + ', prjId' + prj_id);
                     callback(req, res, '数据有误', null);
                 } else {
                     if ((rpt_bill_tpl_ids && rpt_bill_tpl_ids.length > 0) || (rpt_glj_tpl_ids && rpt_glj_tpl_ids.length > 0)) {
@@ -1050,6 +1067,7 @@ module.exports = {
             option = params.option;
         let user_id = req.session.sessionUser.id;
         let dftOption = option||JV.PAGING_OPTION_NORMAL;
+        console.log('start!');
         let pri_Add_Parallel_Functions = function (parallelFunctions, rptPageRstArray, paraRptNames, err) {
             for (let idx = 0; idx < rptPageRstArray.length; idx++) {
                 parallelFunctions.push((function (pageRst, rpt_name) {
@@ -1074,19 +1092,23 @@ module.exports = {
             });
         };
         if (rpt_ids && rpt_ids.length > 0) {
+            console.log(0);
             getMultiRptsCommon(user_id, prj_id, rpt_ids, pageSize, orientation, customizeCfg, dftOption, JV.OUTPUT_TYPE_PDF, function (err, rptPageRstArray) {
                 if (err) {
                     console.log('导出Excel错误(生成数据过程错误), userId: ' + user_id + ', prjId' + prj_id);
                     callback(req, res, '数据生成错误', null);
                 } else {
                     if ((rpt_bill_tpl_ids && rpt_bill_tpl_ids.length > 0) || (rpt_glj_tpl_ids && rpt_glj_tpl_ids.length > 0)) {
+                        console.log(1);
                         getSummaryComboPages(user_id, prjIds, rpt_bill_tpl_ids, rpt_glj_tpl_ids, pageSize, orientation, customizeCfg, option, JV.OUTPUT_TYPE_NORMAL, function (err, rptSumPageRstArray) {
                             let parallelFunctions = [];
+                            console.log(2);
                             pri_Add_Parallel_Functions(parallelFunctions, rptPageRstArray, rpt_names, err);
                             pri_Add_Parallel_Functions(parallelFunctions, rptSumPageRstArray, sum_rpt_names, err);
                             pri_Run_Parallel_Functions(parallelFunctions);
                         });
                     } else {
+                        console.log(3);
                         let parallelFunctions = [];
                         pri_Add_Parallel_Functions(parallelFunctions, rptPageRstArray, rpt_names, err);
                         pri_Run_Parallel_Functions(parallelFunctions);
@@ -1094,6 +1116,7 @@ module.exports = {
                 }
             });
         } else if ((rpt_bill_tpl_ids && rpt_bill_tpl_ids.length > 0) || (rpt_glj_tpl_ids && rpt_glj_tpl_ids.length > 0)) {
+            console.log(10);
             getSummaryComboPages(user_id, prjIds, rpt_bill_tpl_ids, rpt_glj_tpl_ids, pageSize, orientation, customizeCfg, option, JV.OUTPUT_TYPE_NORMAL, function (err, rptSumPageRstArray) {
                 let parallelFunctions = [];
                 pri_Add_Parallel_Functions(parallelFunctions, rptSumPageRstArray, sum_rpt_names, err);

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

@@ -26,7 +26,7 @@ module.exports =function (app) {
     //now is the real:
     rptRouter.post('/getReport', reportController.getReportAllPages);
     rptRouter.post('/getReportSvg', reportController.getReportAllPagesSvg);
-    rptRouter.post('/getMultiReports', reportController.getMultiReports);
+    rptRouter.post('/getMultiReports', reportController.getMultiReportsEx);
     rptRouter.post('/createExcelFiles', reportController.createExcelFilesEx);
     rptRouter.post('/createExcelFilesInOneBook', reportController.createExcelFilesInOneBookEx);
     rptRouter.post('/createPdfFiles', reportController.createPdfFilesEx);

+ 170 - 259
web/building_saas/report/js/rpt_main.js

@@ -8,6 +8,8 @@ const NEXT_PAGE_OFFSET = 160;
 const FIRST_PAGE_OFFSET = 50;
 const LAST_PAGE_OFFSET = 60;
 
+const WAIT_TIME_EXPORT = 12000;
+
 let fontSuffixMapObj = {"表标题": "title", "列标题": "column", "正文内容": "content", "合计": "summary", "表眉/表脚": "header_footer"};
 
 let rptTplObj = {
@@ -17,6 +19,7 @@ let rptTplObj = {
         if (!me.hasInitialized) {
             zTreeOprObj.getCustomerCfg();
             zTreeOprObj.getReportTemplateTree();
+            zTreeOprObj.selectedPrjIDs = [];
             me.hasInitialized = true;
             let canvas = document.getElementById("rptCanvas");
             canvas.onclick = canvasOprObj.canvasOnClick;
@@ -35,6 +38,7 @@ let zTreeOprObj = {
     defReportPageCfg: null,
     currentPage: 1,
     maxPages: 0,
+    selectedPrjIDs: [],
     countChkedRptTpl: function () {
         let me = zTreeOprObj;
         if (me.treeObj) {
@@ -367,8 +371,10 @@ let zTreeOprObj = {
             params.rpt_tpl_id = me.currentNode.refId;
             params.custCfg = me.reportPageCfg;
             params.prjIds = [];
+            me.selectedPrjIDs = [];
             for (let node of nodes) {
                 params.prjIds.push(node.ID);
+                me.selectedPrjIDs.push(node.ID);
             }
             CommonAjax.postEx("report_api/getBillsSummaryReport", params, 26000, true,
                 function(result){
@@ -412,8 +418,10 @@ let zTreeOprObj = {
             params.rpt_tpl_id = me.currentNode.refId;
             params.custCfg = me.reportPageCfg;
             params.prjIds = [];
+            zTreeOprObj.selectedPrjIDs = [];
             for (let node of nodes) {
                 params.prjIds.push(node.ID);
+                zTreeOprObj.selectedPrjIDs.push(node.ID);
             }
             CommonAjax.postEx("report_api/getGljSummaryReport", params, 26000, true,
                 function(result){
@@ -448,41 +456,15 @@ let zTreeOprObj = {
         }
     },
     requestSumAndNormalRptForPDF: function () {
-        let me = rptControlObj;
         let rpt_names = [], bill_rpt_names = [], glj_rpt_names = [];
         let refRptTplIds = [], refBillSumPrjsIds = [], refGljSumPrjsIds = [];
-        for (let node of zTreeOprObj.checkedRptTplNodes) {
-            if (node.hasOwnProperty('flags') && node.flags.hasOwnProperty('reportType') && node['flags']['reportType'] !== 'NA') {
-                if (node['flags']['reportType'] === 'billSummary') {
-                    refBillSumPrjsIds.push(node.refId);
-                    bill_rpt_names.push(node.name);
-                } else if (node['flags']['reportType'] === 'gljSummary') {
-                    refGljSumPrjsIds.push(node.refId);
-                    glj_rpt_names.push(node.name);
-                }
-            } else {
-                refRptTplIds.push(node.refId);
-                rpt_names.push(node.name);
-            }
-        }
-        let nodes = zTreeOprObj.prjFolderTreeObj.getCheckedNodes(true);
-        let params = {};
-        params.prj_id = projectObj.project.projectInfo.ID;
-        params.rpt_ids = refRptTplIds;
-        params.rpt_bill_tpl_ids = refBillSumPrjsIds;
-        params.rpt_glj_tpl_ids = refGljSumPrjsIds;
-        params.prjIds = [];
-        for (let node of nodes) {
-            params.prjIds.push(node.ID);
-        }
+        rptControlObj.getTplIdsCommon(refRptTplIds, refBillSumPrjsIds, refGljSumPrjsIds, rpt_names, bill_rpt_names, glj_rpt_names);
+        let params = rptControlObj.creatCommonExportParam(refRptTplIds, refBillSumPrjsIds, refGljSumPrjsIds);
         params.sum_rpt_names = bill_rpt_names.concat(glj_rpt_names);
         params.rpt_names = rpt_names;
         params.isOneSheet = true;
-        params.pageSize = me.getCurrentPageSize();
-        params.orientation = ((zTreeOprObj.checkedRptTplNodes.length > 1)?null:me.getCurrentOrientation());
-        params.custCfg = zTreeOprObj.reportPageCfg;
-        params.option = "normal";
-        CommonAjax.postEx("report_api/createPdfFiles", params, 120000, true, function(result){
+
+        CommonAjax.postEx("report_api/createPdfFiles", params, WAIT_TIME_EXPORT, true, function(result){
                 if (result) {
                     let uuIdUrls = [];
                     for (let uuIdObj of result) {
@@ -497,41 +479,15 @@ let zTreeOprObj = {
         );
     },
     requestSumAndNormalRptForMultiExcel: function () {
-        let me = rptControlObj;
         let rpt_names = [], bill_rpt_names = [], glj_rpt_names = [];
         let refRptTplIds = [], refBillSumPrjsIds = [], refGljSumPrjsIds = [];
-        for (let node of zTreeOprObj.checkedRptTplNodes) {
-            if (node.hasOwnProperty('flags') && node.flags.hasOwnProperty('reportType') && node['flags']['reportType'] !== 'NA') {
-                if (node['flags']['reportType'] === 'billSummary') {
-                    refBillSumPrjsIds.push(node.refId);
-                    bill_rpt_names.push(node.name);
-                } else if (node['flags']['reportType'] === 'gljSummary') {
-                    refGljSumPrjsIds.push(node.refId);
-                    glj_rpt_names.push(node.name);
-                }
-            } else {
-                refRptTplIds.push(node.refId);
-                rpt_names.push(node.name);
-            }
-        }
-        let nodes = zTreeOprObj.prjFolderTreeObj.getCheckedNodes(true);
-        let params = {};
-        params.prj_id = projectObj.project.projectInfo.ID;
-        params.rpt_ids = refRptTplIds;
-        params.rpt_bill_tpl_ids = refBillSumPrjsIds;
-        params.rpt_glj_tpl_ids = refGljSumPrjsIds;
-        params.prjIds = [];
-        for (let node of nodes) {
-            params.prjIds.push(node.ID);
-        }
+        rptControlObj.getTplIdsCommon(refRptTplIds, refBillSumPrjsIds, refGljSumPrjsIds, rpt_names, bill_rpt_names, glj_rpt_names);
+        let params = rptControlObj.creatCommonExportParam(refRptTplIds, refBillSumPrjsIds, refGljSumPrjsIds);
         params.sum_rpt_names = bill_rpt_names.concat(glj_rpt_names);
         params.rpt_names = rpt_names;
         params.isOneSheet = true;
-        params.pageSize = me.getCurrentPageSize();
-        params.orientation = ((zTreeOprObj.checkedRptTplNodes.length > 1)?null:me.getCurrentOrientation());
-        params.custCfg = zTreeOprObj.reportPageCfg;
-        params.option = "normal";
-        CommonAjax.postEx("report_api/createExcelFiles", params, 120000, true, function(result){
+
+        CommonAjax.postEx("report_api/createExcelFiles", params, WAIT_TIME_EXPORT, true, function(result){
                 if (result) {
                     let uuIdUrls = [];
                     for (let uuIdObj of result) {
@@ -546,36 +502,13 @@ let zTreeOprObj = {
         );
     },
     requestSumAndNormalRptForAllInOneExcel: function () {
-        let me = rptControlObj;
         let orgRptName = projectObj.project.projectInfo.name;
         let refRptTplIds = [], refBillSumPrjsIds = [], refGljSumPrjsIds = [];
-        for (let node of zTreeOprObj.checkedRptTplNodes) {
-            if (node.hasOwnProperty('flags') && node.flags.hasOwnProperty('reportType') && node['flags']['reportType'] !== 'NA') {
-                if (node['flags']['reportType'] === 'billSummary') {
-                    refBillSumPrjsIds.push(node.refId);
-                } else if (node['flags']['reportType'] === 'gljSummary') {
-                    refGljSumPrjsIds.push(node.refId);
-                }
-            } else {
-                refRptTplIds.push(node.refId);
-            }
-        }
-        let nodes = zTreeOprObj.prjFolderTreeObj.getCheckedNodes(true);
-        let params = {};
-        params.prj_id = projectObj.project.projectInfo.ID;
-        params.rpt_ids = refRptTplIds;
-        params.rpt_bill_tpl_ids = refBillSumPrjsIds;
-        params.rpt_glj_tpl_ids = refGljSumPrjsIds;
-        params.prjIds = [];
-        for (let node of nodes) {
-            params.prjIds.push(node.ID);
-        }
+        rptControlObj.getTplIdsCommon(refRptTplIds, refBillSumPrjsIds, refGljSumPrjsIds, null, null, null);
+        let params = rptControlObj.creatCommonExportParam(refRptTplIds, refBillSumPrjsIds, refGljSumPrjsIds);
         params.rptName = orgRptName;
-        params.pageSize = me.getCurrentPageSize();
-        params.orientation = ((zTreeOprObj.checkedRptTplNodes.length > 1)?null:me.getCurrentOrientation());
-        params.custCfg = zTreeOprObj.reportPageCfg;
-        params.option = "normal";
-        CommonAjax.postEx("report_api/createExcelFilesInOneBook", params, 120000, true, function(result){
+
+        CommonAjax.postEx("report_api/createExcelFilesInOneBook", params, WAIT_TIME_EXPORT, true, function(result){
                 if (result) {
                     let uuIdUrls = [];
                     let uuIdUrl =  "/report_api/getFileByUUID/" + result.uuid + "/" + stringUtil.replaceAll(result.reportName, "#", "_") + "/xlsx";
@@ -682,68 +615,55 @@ let rptControlObj = {
             //other types if needed.
         }
     },
-    getAllInOneBook_bk: function () {
-        if (zTreeOprObj.checkedRptTplNodes && zTreeOprObj.checkedRptTplNodes.length > 0) {
-            let me = rptControlObj;
-            let orgRptName = projectObj.project.projectInfo.name;
-            let refRptTplIds = [];
-            for (let node of zTreeOprObj.checkedRptTplNodes) {
+    getTplIdsCommon: function (refRptTplIds, refBillSumPrjsIds, refGljSumPrjsIds, rpt_names, bill_rpt_names, glj_rpt_names) {
+        for (let node of zTreeOprObj.checkedRptTplNodes) {
+            if (node.hasOwnProperty('flags') && node.flags.hasOwnProperty('reportType') && node['flags']['reportType'] !== 'NA') {
+                if (node['flags']['reportType'] === 'billSummary') {
+                    refBillSumPrjsIds.push(node.refId);
+                    if (bill_rpt_names) bill_rpt_names.push(node.name);
+                } else if (node['flags']['reportType'] === 'gljSummary') {
+                    refGljSumPrjsIds.push(node.refId);
+                    if (glj_rpt_names) glj_rpt_names.push(node.name);
+                }
+            } else {
                 refRptTplIds.push(node.refId);
+                if (rpt_names) rpt_names.push(node.name);
             }
-            let params = {};
-            params.prj_id = projectObj.project.projectInfo.ID;
-            params.rpt_ids = refRptTplIds;
-            params.rptName = orgRptName;
-            params.pageSize = me.getCurrentPageSize();
-            params.orientation = ((zTreeOprObj.checkedRptTplNodes.length > 1)?null:me.getCurrentOrientation());
-            params.custCfg = zTreeOprObj.reportPageCfg;
-            params.option = "normal";
-            CommonAjax.postEx("report_api/createExcelFilesInOneBook", params, 120000, true, function(result){
-                    if (result) {
-                        let uuIdUrls = [];
-                        let uuIdUrl =  "/report_api/getFileByUUID/" + result.uuid + "/" + stringUtil.replaceAll(result.reportName, "#", "_") + "/xlsx";
-                        uuIdUrls.push(uuIdUrl);
-                        downloadReport(uuIdUrls);
-                    } else {
-                        //
-                    }
-                }, null, null
-            );
         }
     },
+    creatCommonExportParam: function (refRptTplIds, refBillSumPrjsIds, refGljSumPrjsIds) {
+        let nodes = (zTreeOprObj.prjFolderTreeObj === null)?[]:zTreeOprObj.prjFolderTreeObj.getCheckedNodes(true);
+        let rst = {};
+        rst.prj_id = projectObj.project.projectInfo.ID;
+        rst.rpt_ids = refRptTplIds;
+        rst.rpt_bill_tpl_ids = refBillSumPrjsIds;
+        rst.rpt_glj_tpl_ids = refGljSumPrjsIds;
+        rst.prjIds = [];
+        zTreeOprObj.selectedPrjIDs = [];
+        for (let node of nodes) {
+            rst.prjIds.push(node.ID);
+            zTreeOprObj.selectedPrjIDs.push(node.ID);
+        }
+        // rst.sum_rpt_names = bill_rpt_names.concat(glj_rpt_names);
+        // rst.rpt_names = rpt_names;
+        // rst.isOneSheet = true;
+        rst.pageSize = rptControlObj.getCurrentPageSize();
+        rst.orientation = ((zTreeOprObj.checkedRptTplNodes.length > 1)?null:rptControlObj.getCurrentOrientation());
+        rst.custCfg = zTreeOprObj.reportPageCfg;
+        rst.option = "normal";
+        return rst;
+    },
     getAllInOneBook: function () {
         if (zTreeOprObj.checkedRptTplNodes && zTreeOprObj.checkedRptTplNodes.length > 0) {
             let me = rptControlObj;
             let orgRptName = projectObj.project.projectInfo.name;
             let refRptTplIds = [], refBillSumPrjsIds = [], refGljSumPrjsIds = [];
-            for (let node of zTreeOprObj.checkedRptTplNodes) {
-                if (node.hasOwnProperty('flags') && node.flags.hasOwnProperty('reportType') && node['flags']['reportType'] !== 'NA') {
-                    if (node['flags']['reportType'] === 'billSummary') {
-                        refBillSumPrjsIds.push(node.refId);
-                    } else if (node['flags']['reportType'] === 'gljSummary') {
-                        refGljSumPrjsIds.push(node.refId);
-                    }
-                } else {
-                    refRptTplIds.push(node.refId);
-                }
-            }
-            if (refBillSumPrjsIds.length > 0 || refGljSumPrjsIds.length > 0) {
-                $("#divReqBillSummary")[0].style.display = "none";
-                $("#divReqGljSummary")[0].style.display = "none";
-                $("#divReqCommonSummaryExcel")[0].style.display = "";
-                $("#divReqCommonSummaryMultiExcel")[0].style.display = "none";
-                $("#divReqCommonSummaryPDF")[0].style.display = "none";
-                zTreeOprObj.requestPrjFolderCommon(); //先处理需要汇总的报表,走另外一个分支
-            } else if (refRptTplIds.length > 0) {
-                let params = {};
-                params.prj_id = projectObj.project.projectInfo.ID;
-                params.rpt_ids = refRptTplIds;
+            rptControlObj.getTplIdsCommon(refRptTplIds, refBillSumPrjsIds, refGljSumPrjsIds);
+            if (zTreeOprObj.selectedPrjIDs.length > 0 && (refBillSumPrjsIds.length > 0 || refGljSumPrjsIds.length > 0)) {
+                let params = rptControlObj.creatCommonExportParam(refRptTplIds, refBillSumPrjsIds, refGljSumPrjsIds);
                 params.rptName = orgRptName;
-                params.pageSize = me.getCurrentPageSize();
-                params.orientation = ((zTreeOprObj.checkedRptTplNodes.length > 1)?null:me.getCurrentOrientation());
-                params.custCfg = zTreeOprObj.reportPageCfg;
-                params.option = "normal";
-                CommonAjax.postEx("report_api/createExcelFilesInOneBook", params, 120000, true, function(result){
+
+                CommonAjax.postEx("report_api/createExcelFilesInOneBook", params, WAIT_TIME_EXPORT, true, function(result){
                         if (result) {
                             let uuIdUrls = [];
                             let uuIdUrl =  "/report_api/getFileByUUID/" + result.uuid + "/" + stringUtil.replaceAll(result.reportName, "#", "_") + "/xlsx";
@@ -754,76 +674,52 @@ let rptControlObj = {
                         }
                     }, null, null
                 );
+            } else {
+                if (refBillSumPrjsIds.length > 0 || refGljSumPrjsIds.length > 0) {
+                    $("#divReqBillSummary")[0].style.display = "none";
+                    $("#divReqGljSummary")[0].style.display = "none";
+                    $("#divReqCommonSummaryExcel")[0].style.display = "";
+                    $("#divReqCommonSummaryMultiExcel")[0].style.display = "none";
+                    $("#divReqCommonSummaryPDF")[0].style.display = "none";
+                    zTreeOprObj.requestPrjFolderCommon(); //先处理需要汇总的报表,走另外一个分支
+                } else if (refRptTplIds.length > 0) {
+                    let params = {};
+                    params.prj_id = projectObj.project.projectInfo.ID;
+                    params.rpt_ids = refRptTplIds;
+                    params.rptName = orgRptName;
+                    params.pageSize = me.getCurrentPageSize();
+                    params.orientation = ((zTreeOprObj.checkedRptTplNodes.length > 1)?null:me.getCurrentOrientation());
+                    params.custCfg = zTreeOprObj.reportPageCfg;
+                    params.option = "normal";
+                    CommonAjax.postEx("report_api/createExcelFilesInOneBook", params, WAIT_TIME_EXPORT, true, function(result){
+                            if (result) {
+                                let uuIdUrls = [];
+                                let uuIdUrl =  "/report_api/getFileByUUID/" + result.uuid + "/" + stringUtil.replaceAll(result.reportName, "#", "_") + "/xlsx";
+                                uuIdUrls.push(uuIdUrl);
+                                downloadReport(uuIdUrls);
+                            } else {
+                                //
+                            }
+                        }, null, null
+                    );
+                }
             }
         }
     },
-    getAllIndividualExcelBook_bk: function () {
-        let me = rptControlObj;
-        if (zTreeOprObj.checkedRptTplNodes && zTreeOprObj.checkedRptTplNodes.length > 0) {
-            let rpt_ids = [], rpt_names = [];
-            for (let tplNode of zTreeOprObj.checkedRptTplNodes) {
-                rpt_ids.push(tplNode.refId);
-                rpt_names.push(tplNode.name)
-            }
-            let params = {};
-            params.prj_id = projectObj.project.projectInfo.ID;
-            params.rpt_ids = rpt_ids;
-            params.rpt_names = rpt_names;
-            params.pageSize = me.getCurrentPageSize();
-            params.orientation = ((zTreeOprObj.checkedRptTplNodes.length > 1)?null:me.getCurrentOrientation());
-            params.isOneSheet = true;
-            params.custCfg = zTreeOprObj.reportPageCfg;
-            params.option = "normal";
-            CommonAjax.postEx("report_api/createExcelFiles", params, 120000, true, function(result){
-                    if (result) {
-                        let uuIdUrls = [];
-                        for (let uuIdObj of result) {
-                            let uuIdUrl =  "/report_api/getFileByUUID/" + uuIdObj.uuid + "/" + stringUtil.replaceAll(uuIdObj.reportName, "#", "_") + "/xlsx";
-                            uuIdUrls.push(uuIdUrl);
-                        }
-                        downloadReport(uuIdUrls);
-                    } else {
-                        //
-                    }
-                }, null, null
-            );
-        }
-    },
     getAllIndividualExcelBook: function () {
         let me = rptControlObj;
         if (zTreeOprObj.checkedRptTplNodes && zTreeOprObj.checkedRptTplNodes.length > 0) {
-            let refRptTplIds = [], refBillSumPrjsIds = [], refGljSumPrjsIds = [], rpt_names = [];
-            for (let node of zTreeOprObj.checkedRptTplNodes) {
-                if (node.hasOwnProperty('flags') && node.flags.hasOwnProperty('reportType') && node['flags']['reportType'] !== 'NA') {
-                    if (node['flags']['reportType'] === 'billSummary') {
-                        refBillSumPrjsIds.push(node.refId);
-                    } else if (node['flags']['reportType'] === 'gljSummary') {
-                        refGljSumPrjsIds.push(node.refId);
-                    }
-                } else {
-                    refRptTplIds.push(node.refId);
-                    rpt_names.push(node.name);
-                }
-            }
-
-            if (refBillSumPrjsIds.length > 0 || refGljSumPrjsIds.length > 0) {
-                $("#divReqBillSummary")[0].style.display = "none";
-                $("#divReqGljSummary")[0].style.display = "none";
-                $("#divReqCommonSummaryExcel")[0].style.display = "none";
-                $("#divReqCommonSummaryMultiExcel")[0].style.display = "";
-                $("#divReqCommonSummaryPDF")[0].style.display = "none";
-                zTreeOprObj.requestPrjFolderCommon(); //先处理需要汇总的报表,走另外一个分支
-            } else if (refRptTplIds.length > 0) {
-                let params = {};
+            let refRptTplIds = [], refBillSumPrjsIds = [], refGljSumPrjsIds = [];
+            let rpt_names = [], bill_rpt_names = [], glj_rpt_names = [];
+            rptControlObj.getTplIdsCommon(refRptTplIds, refBillSumPrjsIds, refGljSumPrjsIds, rpt_names, bill_rpt_names, glj_rpt_names);
+            if (zTreeOprObj.selectedPrjIDs.length > 0 && (glj_rpt_names.length > 0 || bill_rpt_names.length > 0)) {
+                let params = rptControlObj.creatCommonExportParam(refRptTplIds, refBillSumPrjsIds, refGljSumPrjsIds);
                 params.prj_id = projectObj.project.projectInfo.ID;
-                params.rpt_ids = refRptTplIds;
+                params.sum_rpt_names = bill_rpt_names.concat(glj_rpt_names);
                 params.rpt_names = rpt_names;
-                params.pageSize = me.getCurrentPageSize();
-                params.orientation = ((zTreeOprObj.checkedRptTplNodes.length > 1)?null:me.getCurrentOrientation());
                 params.isOneSheet = true;
-                params.custCfg = zTreeOprObj.reportPageCfg;
-                params.option = "normal";
-                CommonAjax.postEx("report_api/createExcelFiles", params, 120000, true, function(result){
+                params.rptName = projectObj.project.projectInfo.name;
+                CommonAjax.postEx("report_api/createExcelFiles", params, WAIT_TIME_EXPORT, true, function(result){
                         if (result) {
                             let uuIdUrls = [];
                             for (let uuIdObj of result) {
@@ -836,6 +732,38 @@ let rptControlObj = {
                         }
                     }, null, null
                 );
+            } else {
+                if (refBillSumPrjsIds.length > 0 || refGljSumPrjsIds.length > 0) {
+                    $("#divReqBillSummary")[0].style.display = "none";
+                    $("#divReqGljSummary")[0].style.display = "none";
+                    $("#divReqCommonSummaryExcel")[0].style.display = "none";
+                    $("#divReqCommonSummaryMultiExcel")[0].style.display = "";
+                    $("#divReqCommonSummaryPDF")[0].style.display = "none";
+                    zTreeOprObj.requestPrjFolderCommon(); //先处理需要汇总的报表,走另外一个分支
+                } else if (refRptTplIds.length > 0) {
+                    let params = {};
+                    params.prj_id = projectObj.project.projectInfo.ID;
+                    params.rpt_ids = refRptTplIds;
+                    params.rpt_names = rpt_names;
+                    params.pageSize = me.getCurrentPageSize();
+                    params.orientation = ((zTreeOprObj.checkedRptTplNodes.length > 1)?null:me.getCurrentOrientation());
+                    params.isOneSheet = true;
+                    params.custCfg = zTreeOprObj.reportPageCfg;
+                    params.option = "normal";
+                    CommonAjax.postEx("report_api/createExcelFiles", params, WAIT_TIME_EXPORT, true, function(result){
+                            if (result) {
+                                let uuIdUrls = [];
+                                for (let uuIdObj of result) {
+                                    let uuIdUrl =  "/report_api/getFileByUUID/" + uuIdObj.uuid + "/" + stringUtil.replaceAll(uuIdObj.reportName, "#", "_") + "/xlsx";
+                                    uuIdUrls.push(uuIdUrl);
+                                }
+                                downloadReport(uuIdUrls);
+                            } else {
+                                //
+                            }
+                        }, null, null
+                    );
+                }
             }
         }
     },
@@ -857,71 +785,23 @@ let rptControlObj = {
             me.getAllIndividualExcelBook();
         }
     },
-    getPDF_bk: function() {
-        let me = rptControlObj;
-        if (zTreeOprObj.checkedRptTplNodes && zTreeOprObj.checkedRptTplNodes.length > 0) {
-            let rpt_ids = [], rpt_names = [];
-            for (let tplNode of zTreeOprObj.checkedRptTplNodes) {
-                rpt_ids.push(tplNode.refId);
-                rpt_names.push(tplNode.name)
-            }
-            let params = {};
-            params.prj_id = projectObj.project.projectInfo.ID;
-            params.rpt_ids = rpt_ids;
-            params.rpt_names = rpt_names;
-            params.pageSize = me.getCurrentPageSize();
-            params.orientation = ((zTreeOprObj.checkedRptTplNodes.length > 1)?null:me.getCurrentOrientation());
-            params.custCfg = zTreeOprObj.reportPageCfg;
-            params.option = "normal";
-            CommonAjax.postEx("report_api/createPdfFiles", params, 120000, true, function(result){
-                    if (result) {
-                        let uuIdUrls = [];
-                        for (let uuIdObj of result) {
-                            let uuIdUrl =  "/report_api/getFileByUUID/" + uuIdObj.uuid + "/" + stringUtil.replaceAll(uuIdObj.reportName, "#", "_") + "/pdf";
-                            uuIdUrls.push(uuIdUrl);
-                        }
-                        downloadReport(uuIdUrls);
-                    } else {
-                        //
-                    }
-                }, null, null
-            );
-        }
-    },
     getPDF: function () {
         let me = rptControlObj;
         if (zTreeOprObj.checkedRptTplNodes && zTreeOprObj.checkedRptTplNodes.length > 0) {
-            let refRptTplIds = [], refBillSumPrjsIds = [], refGljSumPrjsIds = [], rpt_names = [];
-            for (let node of zTreeOprObj.checkedRptTplNodes) {
-                if (node.hasOwnProperty('flags') && node.flags.hasOwnProperty('reportType') && node['flags']['reportType'] !== 'NA') {
-                    if (node['flags']['reportType'] === 'billSummary') {
-                        refBillSumPrjsIds.push(node.refId);
-                    } else if (node['flags']['reportType'] === 'gljSummary') {
-                        refGljSumPrjsIds.push(node.refId);
-                    }
-                } else {
-                    refRptTplIds.push(node.refId);
-                    rpt_names.push(node.name);
-                }
-            }
-
-            if (refBillSumPrjsIds.length > 0 || refGljSumPrjsIds.length > 0) {
-                $("#divReqBillSummary")[0].style.display = "none";
-                $("#divReqGljSummary")[0].style.display = "none";
-                $("#divReqCommonSummaryExcel")[0].style.display = "none";
-                $("#divReqCommonSummaryMultiExcel")[0].style.display = "none";
-                $("#divReqCommonSummaryPDF")[0].style.display = "";
-                zTreeOprObj.requestPrjFolderCommon(); //先处理需要汇总的报表,走另外一个分支
-            } else if (refRptTplIds.length > 0) {
-                let params = {};
+            let refRptTplIds = [], refBillSumPrjsIds = [], refGljSumPrjsIds = [];
+            let rpt_names = [], bill_rpt_names = [], glj_rpt_names = [];
+            rptControlObj.getTplIdsCommon(refRptTplIds, refBillSumPrjsIds, refGljSumPrjsIds, rpt_names, bill_rpt_names, glj_rpt_names);
+            if (zTreeOprObj.selectedPrjIDs.length > 0 && (glj_rpt_names.length > 0 || bill_rpt_names.length > 0)) {
+                let params = rptControlObj.creatCommonExportParam();
                 params.prj_id = projectObj.project.projectInfo.ID;
+                params.sum_rpt_names = bill_rpt_names.concat(glj_rpt_names);
                 params.rpt_ids = refRptTplIds;
+                params.rpt_bill_tpl_ids = refBillSumPrjsIds;
+                params.rpt_glj_tpl_ids = refGljSumPrjsIds;
                 params.rpt_names = rpt_names;
-                params.pageSize = me.getCurrentPageSize();
-                params.orientation = ((zTreeOprObj.checkedRptTplNodes.length > 1)?null:me.getCurrentOrientation());
-                params.custCfg = zTreeOprObj.reportPageCfg;
-                params.option = "normal";
-                CommonAjax.postEx("report_api/createPdfFiles", params, 120000, true, function(result){
+                params.isOneSheet = true;
+                params.rptName = projectObj.project.projectInfo.name;
+                CommonAjax.postEx("report_api/createPdfFiles", params, WAIT_TIME_EXPORT, true, function(result){
                         if (result) {
                             let uuIdUrls = [];
                             for (let uuIdObj of result) {
@@ -934,6 +814,37 @@ let rptControlObj = {
                         }
                     }, null, null
                 );
+            } else {
+                if (refBillSumPrjsIds.length > 0 || refGljSumPrjsIds.length > 0) {
+                    $("#divReqBillSummary")[0].style.display = "none";
+                    $("#divReqGljSummary")[0].style.display = "none";
+                    $("#divReqCommonSummaryExcel")[0].style.display = "none";
+                    $("#divReqCommonSummaryMultiExcel")[0].style.display = "none";
+                    $("#divReqCommonSummaryPDF")[0].style.display = "";
+                    zTreeOprObj.requestPrjFolderCommon(); //先处理需要汇总的报表,走另外一个分支
+                } else if (refRptTplIds.length > 0) {
+                    let params = {};
+                    params.prj_id = projectObj.project.projectInfo.ID;
+                    params.rpt_ids = refRptTplIds;
+                    params.rpt_names = rpt_names;
+                    params.pageSize = me.getCurrentPageSize();
+                    params.orientation = ((zTreeOprObj.checkedRptTplNodes.length > 1)?null:me.getCurrentOrientation());
+                    params.custCfg = zTreeOprObj.reportPageCfg;
+                    params.option = "normal";
+                    CommonAjax.postEx("report_api/createPdfFiles", params, WAIT_TIME_EXPORT, true, function(result){
+                            if (result) {
+                                let uuIdUrls = [];
+                                for (let uuIdObj of result) {
+                                    let uuIdUrl =  "/report_api/getFileByUUID/" + uuIdObj.uuid + "/" + stringUtil.replaceAll(uuIdObj.reportName, "#", "_") + "/pdf";
+                                    uuIdUrls.push(uuIdUrl);
+                                }
+                                downloadReport(uuIdUrls);
+                            } else {
+                                //
+                            }
+                        }, null, null
+                    );
+                }
             }
         }
     },

+ 6 - 10
web/building_saas/report/js/rpt_print.js

@@ -5,16 +5,12 @@
 let rptPrintHelper = {
     preview: function () {
         if (zTreeOprObj.checkedRptTplNodes && zTreeOprObj.checkedRptTplNodes.length > 0) {
-            let rptIds = [];
-            let params = {};
-            params.pageSize = rptControlObj.getCurrentPageSize();
-            params.orientation = ((zTreeOprObj.checkedRptTplNodes.length > 1)?null:rptControlObj.getCurrentOrientation());
-            params.custCfg = zTreeOprObj.reportPageCfg;
-            params.prj_id = projectObj.project.projectInfo.ID;
-            for (let tplNode of zTreeOprObj.checkedRptTplNodes) {
-                rptIds.push(tplNode.refId);
-            }
-            params.rpt_ids = rptIds.join(",");
+            let refRptTplIds = [], refBillSumPrjsIds = [], refGljSumPrjsIds = [];
+            rptControlObj.getTplIdsCommon(refRptTplIds, refBillSumPrjsIds, refGljSumPrjsIds, null, null, null);
+            let params = rptControlObj.creatCommonExportParam(refRptTplIds, refBillSumPrjsIds, refGljSumPrjsIds);
+            params.rpt_ids = refRptTplIds;
+            params.rpt_bill_tpl_ids = refBillSumPrjsIds;
+            params.rpt_glj_tpl_ids = refGljSumPrjsIds;
             CommonAjax.postEx("report_api/getMultiReports", params, 10000, true,
                 function(result){
                     //sessionStorage.currentPageData = JSON.stringify(zTreeOprObj.currentRptPageRst);