TonyKang 3 лет назад
Родитель
Сommit
aa18a96fe2

+ 0 - 1
app/controller/report_controller.js

@@ -19,7 +19,6 @@ const rptCronJob = require('../reports/util/rpt_tmp_file_sweep');
 const RPT_DEF_PROPERTIES = require('../const/report_defined_properties');
 const reportConst = require('../const/report');
 // const stringUtil = require('../public/js/string_util_light');
-const scheduleJob = require('node-schedule');
 const needCustomTables = [
     'mem_custom_select',
     'mem_gather_stage_bills', 'mem_gather_deal_bills', 'mem_gather_stage_pay', 'mem_gather_tender_info',

+ 43 - 28
app/public/report/js/rpt_archive.js

@@ -71,9 +71,11 @@ let rptArchiveObj = {
         if (current_stage_status === 3 && enabled) {
             $('#btnArchiveRpt').removeAttr('disabled');
             $('#btnArchiveList').removeAttr('disabled');
+            $('#btnBatchArchiveRpt').removeAttr('disabled');
         } else {
             $('#btnArchiveRpt').attr('disabled', '');
             $('#btnArchiveList').attr('disabled', '');
+            $('#btnBatchArchiveRpt').attr('disabled', '');
         }
     },
     refreshNodes: function() {
@@ -134,12 +136,9 @@ let rptArchiveObj = {
 
     batchArchive: function() {
         if (zTreeOprObj.checkedRptTplNodes && zTreeOprObj.checkedRptTplNodes.length > 0) {
-            indexDbOprObj.storeReportRequest(current_stage_id, zTreeOprObj.checkedRptTplNodes);
+            indexDbOprObj.storeReportRequest(current_stage_id, zTreeOprObj.checkedRptTplNodes, indexDbOprObj.startRequestReport);
         }
     },
-    batchArchiveTest: function() {
-        indexDbOprObj._test();
-    },
 
     _requestArchiveReport: function () {
         let me = rptArchiveObj;
@@ -475,7 +474,7 @@ let rptArchiveObj = {
         }
         return psInfo;
     },
-    archiveCurrentReport: function (currentRptPageRst, currentNode) {
+    archiveCurrentReport: function (currentRptPageRst, currentNode, cb) {
         let picKeys = [], picCells = [], dupPicPath = [], dupPicCell = [];
         // 1. 找草图路径
         for (let pageIdx = 0; pageIdx < currentRptPageRst.items.length; pageIdx++) {
@@ -514,7 +513,7 @@ let rptArchiveObj = {
                         exceptionAmt++;
                         if ((picCnt + exceptionAmt) === picAmt) {
                             $.bootstrapLoading.end();
-                            rptArchiveObj._archiveCurrentReport(currentRptPageRst, currentNode);
+                            rptArchiveObj._archiveCurrentReport(currentRptPageRst, currentNode, cb);
                         }
                     } else {
                         let oFileReader = new FileReader();
@@ -530,7 +529,7 @@ let rptArchiveObj = {
                             }
                             if ((picCnt + exceptionAmt) === picAmt) {
                                 $.bootstrapLoading.end();
-                                rptArchiveObj._archiveCurrentReport(currentRptPageRst, currentNode);
+                                rptArchiveObj._archiveCurrentReport(currentRptPageRst, currentNode, cb);
                             }
                         };
                         oFileReader.readAsDataURL(blob);
@@ -538,10 +537,10 @@ let rptArchiveObj = {
                 });
             }
         } else {
-            rptArchiveObj._archiveCurrentReport(currentRptPageRst, currentNode);
+            rptArchiveObj._archiveCurrentReport(currentRptPageRst, currentNode, cb);
         }
     },
-    _archiveCurrentReport: function(currentRptPageRst, currentNode) {
+    _archiveCurrentReport: function(currentRptPageRst, currentNode, cb) {
         // 归档当前报表
         if (currentRptPageRst !== null) {
             try {
@@ -567,24 +566,34 @@ let rptArchiveObj = {
                             params.content = pageEncryptInfo;
                             params.uuid = result.uuid; //正确返回时,带着uuid回来
                             CommonAjax.postXsrfEx("/tender/report_api/addArchiveEncryption", params, 10000, true, getCookie('csrfToken_j'),
-                                function(result){
-                                    //
+                                function(rst){
+                                    if (cb) {
+                                        cb(null, 'add archive encryption succeed!', params.uuid);
+                                    }
                                 }, function(err){
-                                    //
+                                    if (cb) {
+                                        cb('err', 'add archive encryption err!', params.uuid);
+                                    }
                                 }, function(ex){
-                                    //
+                                    if (cb) {
+                                        cb('err', 'add archive encryption err!', params.uuid);
+                                    }
                                 }
                             );
                         } else {
                             // 有冲突,需要删除
                             CommonAjax.postXsrfEx('/tender/report_api/removeArchive/' + PROJECT_ID + '/' + current_stage_id + '/' + currentNode.refId + result.fileName, '', 3000, true, getCookie('csrfToken_j'),
                                 function(result){
-                                    //
+                                    if (cb) {
+                                        cb('err', 'add archive conflict!', null);
+                                    }
                                 }
                             );
                         }
                     }, function (error){
-                        // alert(error);
+                        if (cb) {
+                            cb('err', 'add archive err!', null);
+                        }
                     });
                 } else {
                     let aItem = this._getCurrentArchives(currentNode);
@@ -614,28 +623,43 @@ let rptArchiveObj = {
                                 params.uuid = orgName;
                                 CommonAjax.postXsrfEx("/tender/report_api/updateArchiveEncryption", params, 10000, true, getCookie('csrfToken_j'),
                                     function(result){
-                                        //
+                                        if (cb) {
+                                            cb(null, 'update archive succeed!', params.uuid);
+                                        }
                                     }, function(err){
-                                        //
+                                        if (cb) {
+                                            cb('err', 'update archive err!', params.uuid);
+                                        }
                                     }, function(ex){
-                                        //
+                                        if (cb) {
+                                            cb('err', 'update archive err!', params.uuid);
+                                        }
                                     }
                                 );
                             } else {
                                 // 有冲突,需要删除
                                 CommonAjax.postXsrfEx('/tender/report_api/removeArchive/' + PROJECT_ID + '/' + current_stage_id + '/' + currentNode.refId + result.fileName, '', 3000, true, getCookie('csrfToken'),
                                     function(result){
-                                        //
+                                        if (cb) {
+                                            cb('err', 'update archive conflict!', null);
+                                        }
                                     }
                                 );
                             }
                         }, function (error){
                             // alert(error);
+                            if (cb) {
+                                cb('err', 'update archive conflict!', null);
+                            }
                         });
                     }
                 }
             } catch (ex) {
+                console.log(ex);
                 console.log(ex.toString());
+                if (cb) {
+                    cb('err', 'has exception!', null);
+                }
             }
         } else {
             alert('请选择打开一个报表!');
@@ -643,15 +667,6 @@ let rptArchiveObj = {
     }
 };
 
-function dataURLtoFile(dataurl, filename) {
-    var arr = dataurl.split(','), mime = arr[0].match(/:(.*?);/)[1],
-        bstr = atob(arr[1]), n = bstr.length, u8arr = new Uint8Array(n);
-    while(n--){
-        u8arr[n] = bstr.charCodeAt(n);
-    }
-    return new File([u8arr], filename, {type:mime});
-};
-
 /**
  * 获取 blob
  * @param  {String} url 目标文件地址

+ 246 - 125
app/public/report/js/rpt_indexDb.js

@@ -5,10 +5,12 @@
 
 const indexDbOprObj = {
     currentDb: null,
+    tb_name_request: 'tb_ReportRequests',   // 记录报表请求信息,在不同的场景传递中有用
+    tb_name_page: 'tb_ReportPages',         // 记录已请求并返回的报表结果信息
     iniDb: function (dbName, version) {
         let rst = window.indexedDB.open(dbName, version);
         rst.onsuccess = function (event) {
-            indexDbOprObj.currentDb = event.target.result;;
+            indexDbOprObj.currentDb = event.target.result;
             console.log('数据库打开成功!');
         };
         rst.onupgradeneeded = function (event) {
@@ -21,173 +23,292 @@ const indexDbOprObj = {
     _iniTable: function(db) {
         if (db) {
             //本地表,主要是用来储存报表结果对象,主要是为PDF多表导出用,当然,其他方式也是可以用的(如打印),看实际需要
-            if (!db.objectStoreNames.contains('tb_ReportPages')) {
-                db.createObjectStore('tb_ReportPages', { keyPath: 'id' });
+            if (!db.objectStoreNames.contains(this.tb_name_page)) {
+                db.createObjectStore(this.tb_name_page, { keyPath: 'id' });
             }
-            if (!db.objectStoreNames.contains('tb_ReportRequests')) {
-                db.createObjectStore('tb_ReportRequests', { keyPath: 'id' });
+            if (!db.objectStoreNames.contains(this.tb_name_request)) {
+                db.createObjectStore(this.tb_name_request, { keyPath: 'id' });
             }
         }
     },
     batchAdd: function (tbName, datas, cb) {
         let db =  indexDbOprObj.currentDb;
         let ttlAmt = datas.length;
-        console.log(`已选报表数量:${ttlAmt}`);
+        // console.log(`已选报表数量:${ttlAmt}`);
         let cnt = 0;
-        let request = db.transaction([tbName], 'readwrite').objectStore(tbName);
-        request.onsuccess = function (event) {
-            cnt++;
-            console.log(`已选加数量:${cnt}`);
-            if (cnt === ttlAmt && cb) {
-                cb(datas);
-            }
-        };
+        let store = db.transaction([tbName], 'readwrite').objectStore(tbName);
         for (let data of datas) {
-            request.add(data);
+            let request = store.add(data);
+            request.onsuccess = function (event) {
+                cnt++;
+                // console.log(`已选加数量:${cnt}`);
+                if (cnt === ttlAmt && cb) {
+                    cb(datas);
+                }
+            };
         }
     },
-    _addDummy: function() {
-        let db =  indexDbOprObj.currentDb;
-        // let request = db.transaction(['tb_ReportRequests'], 'readwrite')
-        db.transaction(['tb_ReportRequests'], 'readwrite')
-            .objectStore('tb_ReportRequests')
-            .add({ id: '_2830_1725', name: '多人协同2', pageSize: 'A4', CFG: null, prj_ids: [123,456,789] });
-        // request.onsuccess = function (event) {
-        //     console.log('数据写入成功');
-        // };
-        //
-        // request.onerror = function (event) {
-        //     console.log('数据写入失败');
-        // }
-
-        db.transaction(['tb_ReportRequests'], 'readwrite')
-            .objectStore('tb_ReportRequests')
-            .add({ id: '_2830_1728', name: '多人协同3', pageSize: 'A3', CFG: null, prj_ids: [668] });
-    },
-    _updateDummy: function () {
+    getOne: function (tbName, id, cb = null) {
         let db =  indexDbOprObj.currentDb;
-        let request = db.transaction(['tb_ReportRequests'], 'readwrite')
-            .objectStore('tb_ReportRequests')
-            .put({ id: '_2830_1725', name: '多人协同2', pageSize: 'A4', CFG: 'CFG', prj_ids: [1,2,3] });
-
+        // let objectStore = db.transaction(tbName).objectStore(tbName);
+        let objectStore = db.transaction([tbName], 'readwrite').objectStore(tbName);
+        let request = objectStore.get(id);
         request.onsuccess = function (event) {
-            console.log('数据写入成功');
-        };
-
-        request.onerror = function (event) {
-            console.log('数据写入失败');
+            let data = event.target.result;
+            if (cb) cb(data);
         }
     },
-    _getDummy: function () {
-        let db =  indexDbOprObj.currentDb;
-        let transaction = db.transaction(['tb_ReportRequests']);
-        let objectStore = transaction.objectStore('tb_ReportRequests');
-        let request = objectStore.get('_2830_1725');
-
-        request.onerror = function(event) {
-            console.log('事务失败');
-        };
-
-        request.onsuccess = function(event) {
-            if (request.result) {
-                console.log('Name: ' + request.result.name);
-                console.log('PageSize: ' + request.result.pageSize);
-                console.log('CFG: ' + request.result.CFG);
-                console.log('ProjectIds: ' + request.result.prj_ids);
-            } else {
-                console.log('未获得数据记录');
-            }
-        };
-    },
-    _getDummyAll: function (idRst, cb) {
+    getAll: function (tbName, idRst, cb = null) {
         let db =  indexDbOprObj.currentDb;
-        let objectStore = db.transaction('tb_ReportRequests').objectStore('tb_ReportRequests');
-
+        let objectStore = db.transaction(tbName).objectStore(tbName);
+        let amt = 0;
         objectStore.openCursor().onsuccess = function (event) {
             let cursor = event.target.result;
-
             if (cursor) {
-                console.log('Id: ' + cursor.key);
-                console.log('Name: ' + cursor.value.name);
-                console.log('PageSize: ' + cursor.value.pageSize);
-                console.log('gather_select: ' + cursor.value.gather_select);
-                console.log('stage_select: ' + cursor.value.stage_select);
-                console.log('CFG: ');
-                console.log(cursor.value.CFG);
                 if (idRst) {
                     idRst.push(cursor.key);
                 }
+                amt++;
                 cursor.continue();
             } else {
-                console.log('没有更多数据了!');
+                console.log(`已取数量:${amt}`);
                 if (cb) {
                     cb(idRst);
                 }
             }
         };
     },
-    _removeDummy: function () {
-        let db =  indexDbOprObj.currentDb;
-        let request = db.transaction(['tb_ReportRequests'], 'readwrite')
-            .objectStore('tb_ReportRequests')
-            .delete('_2830_1725');
-
-        request.onsuccess = function (event) {
-            console.log('数据删除成功');
-        };
-
-        request.onerror = function (event) {
-            console.log('数据删除失败');
+    storeReportRequest: function (stage_id, rptNodes, cb = null) {
+        if (rptNodes && rptNodes.length > 0) {
+            indexDbOprObj.removeAll(()=>{
+                let datas = [];
+                for (let node of rptNodes) {
+                    let keyStr = `_${stage_id}_${node.refId}`;
+                    const gather_select = customSelects.gather_select.find(function (x) {
+                        return x.id === node.refId;
+                    });
+                    const stage_select = customSelects.stage_select.find(function (x) {
+                        return x.id === node.refId;
+                    });
+                    let data = {id: keyStr, name: node.name, rpt_id: node.refId, stage_id, gather_select, stage_select, pageSize: rptControlObj.getCurrentPageSize(), CFG: CUST_CFG};
+                    datas.push(data);
+                }
+                indexDbOprObj.batchAdd(this.tb_name_request, datas, (rstArr)=>{
+                    console.log('batch add succeeded!');
+                    console.log(rstArr);
+                    //其他操作
+                    if (rstArr.length > 0 && cb) {
+                        cb(stage_id, rptNodes);
+                    }
+                });
+            });
         }
     },
-    _test: function () {
-        // indexDbOprObj._addDummy();
-        // indexDbOprObj._getDummy();
+    startRequestReport: async function(stage_id, rptNodes) {
+        //划重点:这里要能处理所有相关的报表请求,除非是带选择的,否则就要静悄悄地处理完,带选择的只需要选择一次同类型的!!!
+        //第一步:只需要请求数据并保存
+        //第二步:所有请求数据完备后,才开始转PDF并上传
+        //所有这些处理都是异步的!!!
+        //1. 开始,初始化
+        let gather_select_param = null;
+        let stage_select_param = null;
         let idRst = [];
-        indexDbOprObj._getDummyAll(idRst, (ids)=>{
-            console.log(ids);
-            // indexDbOprObj.removeAll(ids);
-        });
-        // indexDbOprObj._updateDummy();
-        // indexDbOprObj._removeDummy();
-    },
-    storeReportRequest: function (stage_id, rptNodes) {
-        if (rptNodes && rptNodes.length > 0) {
-            let datas = [];
-            for (let node of rptNodes) {
-                let keyStr = `_${stage_id}_${node.refId}`;
-                const gather_select = customSelects.gather_select.find(function (x) {
-                    return x.id === node.refId;
+        let normal_request = [], gather_request = [], stage_request = [];
+        let db =  indexDbOprObj.currentDb;
+        let needWaterMark = false;
+        if (COMMON_WATER_MARK_PIC_DATA === null || COMMON_WATER_MARK_PIC_DATA === '') {
+            needWaterMark = true;
+        }
+        const _requestNormalReport = async function() {
+            let refRptTplIds = [], rpt_names = [];
+            for (let req of normal_request) {
+                //{id: keyStr, name: node.name, rpt_id: node.refId, stage_id, gather_select, stage_select, pageSize: rptControlObj.getCurrentPageSize(), CFG: CUST_CFG}
+                refRptTplIds.push(req.rpt_id);
+                rpt_names.push(req.name);
+            }
+            let params = rptControlObj.creatCommonExportParam(refRptTplIds);
+            await rptCustomObj.getCustomSelect(params);
+            // params.customSelect = [];
+            params.needWaterMark = needWaterMark;
+            indexDbOprObj._getRptDataForDb(params, rpt_names, stage_id, (records)=>{
+                console.log('the normal type page results have been saved!');
+                // console.log(records);
+                _createPDF(0, records, rptNodes, ()=>{
+                    console.log('the normal type archive PDFs have been created!');
+                    let ids = [];
+                    for (let rec of records) {
+                        ids.push(rec.id);
+                    }
+                    indexDbOprObj.remove(indexDbOprObj.tb_name_request, ids);
+                    indexDbOprObj.remove(indexDbOprObj.tb_name_page, ids);
+                    _requestGatherReport();
                 });
-                const stage_select = customSelects.stage_select.find(function (x) {
-                    return x.id === node.refId;
+            });
+        };
+        const _requestGatherReport = function() {
+            if (gather_request.length > 0) {
+                let refRptTplIds = [], rpt_names = [];
+                for (let req of gather_request) {
+                    //{id: keyStr, name: node.name, rpt_id: node.refId, stage_id, gather_select, stage_select, pageSize: rptControlObj.getCurrentPageSize(), CFG: CUST_CFG}
+                    refRptTplIds.push(req.rpt_id);
+                    rpt_names.push(req.name);
+                }
+                let params = rptControlObj.creatCommonExportParam(refRptTplIds);
+                params.customSelect = [];
+                params.needWaterMark = needWaterMark;
+                indexDbOprObj._getRptDataForDb(params, rpt_names, stage_id, (records)=>{
+                    console.log('the normal type page results have been saved!');
+                    // console.log(records);
+                    _createPDF(0, records, rptNodes, ()=>{
+                        console.log('the normal type archive PDFs have been created!');
+                        let ids = [];
+                        for (let rec of records) {
+                            ids.push(rec.id);
+                        }
+                        indexDbOprObj.remove(indexDbOprObj.tb_name_request, ids);
+                        indexDbOprObj.remove(indexDbOprObj.tb_name_page, ids);
+                        _requestStageReport();
+                    });
                 });
-                let data = {id: keyStr, name: node.name, gather_select, stage_select, pageSize: rptControlObj.getCurrentPageSize(), CFG: CUST_CFG};
-                datas.push(data);
+            } else {
+                _requestStageReport();
+            }
+        };
+        const _requestStageReport = function() {
+            console.log('go on stage report...');
+        };
+        indexDbOprObj.getAll(indexDbOprObj.tb_name_request, idRst, (ids)=>{
+            if (ids && ids.length > 0) {
+                let cnt = 0;
+                let store = db.transaction([indexDbOprObj.tb_name_request], 'readwrite').objectStore(indexDbOprObj.tb_name_request);
+                for (let id of ids) {
+                    let request = store.get(id);
+                    request.onsuccess = function(event) {
+                        cnt++;
+                        if (request.result) {
+                            // if (request.result.gather_select) {
+                            //     gather_request.push(request.result);
+                            // } else if (request.result.stage_select) {
+                            //     stage_request.push(request.result);
+                            // } else {
+                            //     normal_request.push(request.result);
+                            // }
+                            normal_request.push(request.result);
+                        } else {
+                            // console.log('未获得数据记录');
+                        }
+                        if (cnt === ids.length) {
+                            //下一步处理
+                            _requestNormalReport();
+                        }
+                    };
+                }
             }
-            indexDbOprObj.batchAdd('tb_ReportRequests', datas, (rstArr)=>{
-                console.log('batch add succeeded!');
-                console.log(rstArr);
-                //其他操作
+        });
+    },
+    removeAll: function(cb = null) {
+        let tbArr = [indexDbOprObj.tb_name_request, indexDbOprObj.tb_name_page];
+        let tbAmt = 0;
+        for (let tbName of tbArr) {
+            tbAmt++;
+            let idRst = [];
+            indexDbOprObj.getAll(tbName, idRst, (ids)=>{
+                if (ids && ids.length > 0) {
+                    let db =  indexDbOprObj.currentDb;
+                    let store = db.transaction([tbName], 'readwrite').objectStore(tbName);
+                    let amt = 0;
+                    for (let id of ids) {
+                        let req = store.delete(id);
+                        req.onsuccess = function (event) {
+                            amt++;
+                            if (tbAmt === tbArr.length && amt === ids.length && cb) {
+                                cb();
+                            }
+                        };
+
+                    }
+                } else if (tbAmt === tbArr.length && cb) {
+                    cb();
+                }
             });
         }
     },
-    storeReportPages: function (rptPages, stage_id, rptNode) {
-        //
-    },
-    removeAll: function(idArr) {
-        if (idArr && idArr.length > 0) {
+    remove: function(tbName, ids) {
+        if (ids && ids.length > 0) {
             let db =  indexDbOprObj.currentDb;
-            let request = db.transaction(['tb_ReportRequests'], 'readwrite').objectStore('tb_ReportRequests');
-            for (let id of idArr) {
-                request.delete(id);
-                request.onsuccess = function (event) {
-                    console.log(`数据('${id}')删除成功`);
-                };
+            let store = db.transaction([tbName], 'readwrite').objectStore(tbName);
+            for (let id of ids) {
+                store.delete(id);
             }
         }
     },
-    getReportPages: function (rpt_id, stage_id) {
+    _getRptDataForDb: function(params, rpt_names, stage_id, cb) {
+        CommonAjax.postXsrfEx("/tender/report_api/getMultiReports", params, 60000, true, getCookie('csrfToken_j'),
+            function(result){
+                const signatureRelArr = [];
+                STAGE_AUDIT = result.stageAudit;
+                if (params.needWaterMark) sessionStorage.waterMarkStr = result.waterMarkStr;
+                for (const signatureRel of result.signatureRelInfo) {
+                    signatureRelArr.push(JSON.parse(signatureRel.rel_content));
+                }
+                for (let idx = 0; idx < result.data.length; idx++) {
+                    let singleSignatureRelArr = [];
+                    for (let rIdx = 0; rIdx < result.signatureRelInfo.length; rIdx++) {
+                        if (result.signatureRelInfo[rIdx].rpt_id === params.rpt_ids[idx]) {
+                            singleSignatureRelArr = signatureRelArr[rIdx]; // 有些报表可能没有签名
+                            break;
+                        }
+                    }
+                    if (params.stage_status === 3) {
+                        rptSignatureHelper.mergeSignDate(result.data[idx], singleSignatureRelArr, false);
+                        rptSignatureHelper.mergeSignature(result.data[idx], singleSignatureRelArr);
+                        rptSignatureHelper.mergeSignAudit(result.data[idx], singleSignatureRelArr, result.stageAudit);
+                    }
+                }
+                let multiRptData = result.data;
+                let datas = [];
+                for (let idx = 0; idx < multiRptData.length; idx++) {
+                    // this._storeReportPages(multiRptData[idx], stage_id, params.rpt_ids[idx], cb);
+                    let keyStr = `_${stage_id}_${params.rpt_ids[idx]}`;
+                    let data = {id: keyStr, rpt_id: params.rpt_ids[idx], rpt_name: rpt_names[idx], stage_id, pageData: multiRptData[idx]};
+                    datas.push(data);
+                }
+                indexDbOprObj.batchAdd(indexDbOprObj.tb_name_page, datas, (rstArr)=>{
+                    cb(rstArr);
+                });
+            },
+            function(failRst){
+                // sessionStorage.currentPageData = null;
+                console.log(failRst);
+            },
+            function(exceptionRst){
+                // sessionStorage.currentPageData = null;
+                console.log(exceptionRst);
+            }
+        );
+    },
+    _startToCreatePDF: function(idArr) {
         //
     }
+};
+
+function _createPDF(currentIdx, records, rptNodes, cb) {
+    if (currentIdx === records.length) {
+        if (cb) {
+            cb();
+        }
+    } else {
+        let rec = records[currentIdx];
+        let nextIdx = currentIdx + 1;
+        indexDbOprObj.getOne(indexDbOprObj.tb_name_page, rec.id, (record)=>{
+            for (let node of rptNodes) {
+                if (node.refId === record.rpt_id) {
+                    rptArchiveObj.archiveCurrentReport(record.pageData, node, (err, msg, uuid)=>{
+                        _createPDF(nextIdx, records, rptNodes, cb);
+                    });
+                    break;
+                }
+            }
+        });
+    }
 };

+ 5 - 5
app/public/report/js/rpt_jspdf.js

@@ -59,11 +59,11 @@ let JpcJsPDFHelper = {
 
         function private_getIniPageMergeBorder(mergedBand) {
             let rst = {};
-            rst[JV.PROP_LEFT] = mergedBand[JV.PROP_LEFT];
-            rst[JV.PROP_RIGHT] = mergedBand[JV.PROP_RIGHT];
-            rst[JV.PROP_TOP] = mergedBand[JV.PROP_TOP];
-            rst[JV.PROP_BOTTOM] = mergedBand[JV.PROP_BOTTOM];
-            rst[JV.PROP_STYLE] = mergedBand[JV.PROP_STYLE];
+            rst[JV.PROP_LEFT] = (mergedBand) ? mergedBand[JV.PROP_LEFT] : 0;
+            rst[JV.PROP_RIGHT] = (mergedBand) ? mergedBand[JV.PROP_RIGHT] : 0;
+            rst[JV.PROP_TOP] = (mergedBand) ? mergedBand[JV.PROP_TOP] : 0;
+            rst[JV.PROP_BOTTOM] = (mergedBand) ? mergedBand[JV.PROP_BOTTOM] : 0;
+            rst[JV.PROP_STYLE] = (mergedBand) ? mergedBand[JV.PROP_STYLE] : 0;
             return rst;
         }
 

+ 5 - 0
app/public/report/js/rpt_main.js

@@ -85,6 +85,11 @@ let zTreeOprObj = {
             $("#export_div").find("span").each(function(cIdx,elementSpan){
                 elementSpan.innerText = cnt;
             });
+            if (cnt) {
+                $('#btnBatchArchiveRpt').removeAttr('disabled');
+            } else {
+                $('#btnBatchArchiveRpt').attr('disabled', '');
+            }
         }
     },
     getReportTemplateTree: function() {

+ 1 - 2
app/view/report/index.ejs

@@ -75,9 +75,8 @@
                                 <div class="panel-body">
                                     <div class="btn-group" role="group">
                                         <button id="btnArchiveRpt" type="button" class="btn btn-outline-primary btn-sm" data-toggle="modal" data-target="#guidang" disabled><i class="fa fa-archive"></i> 归档报表</button>
+                                        <button id="btnBatchArchiveRpt" type="button" class="btn btn-outline-primary btn-sm" onclick="rptArchiveObj.batchArchive()" disabled><i class="fa fa-archive"></i>批量归档</button>
                                         <!--
-                                        <button id="btnBatchArchiveRpt" type="button" class="btn btn-outline-primary btn-sm" onclick="rptArchiveObj.batchArchive()"><i class="fa fa-archive"></i>批量归档</button>
-                                        <button id="btnBatchArchiveRpt" type="button" class="btn btn-outline-primary btn-sm" onclick="rptArchiveObj.batchArchiveTest()"><i class="fa fa-archive"></i>测试批量归档</button>
                                         -->
                                         <div class="btn-group" role="group">
                                             <button id="btnArchiveList" type="button" class="btn btn-success btn-sm dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" disabled>