瀏覽代碼

账单式报表导出excel/pdf出错问题

TonyKang 5 年之前
父節點
當前提交
f6bf088287

+ 5 - 0
app/controller/report_controller.js

@@ -280,6 +280,8 @@ async function getReportData(ctx, params, filters) {
     const rst = {};
     const runnableRst = [];
     const runnableKey = []; // 这个配合runnableRst用,未来考虑并行查询优化
+    // console.log('params');
+    // console.log(params);
     for (const filter of filters) {
         switch (filter) {
             case 'project' :
@@ -326,7 +328,10 @@ async function getReportData(ctx, params, filters) {
                 break;
         }
     }
+    // console.log('before query, runnableKey');
+    // console.log(runnableKey);
     const queryRst = await Promise.all(runnableRst);
+    // console.log('after query');
     for (let idx = 0; idx < runnableKey.length; idx++) {
         rst[runnableKey[idx]] = queryRst[idx];
         // console.log(runnableKey[idx]);

+ 10 - 6
app/public/report/js/jpc_output.js

@@ -440,14 +440,18 @@ let JpcCanvasOutput = {
                 private_drawCell(cell, fonts, styles, controls, newPageMergeBand);
             }
             //电子签名
-            for (let k = 0; k < page.signature_cells.length; k++) {
-                let cell = page.signature_cells[k];
-                private_drawSignatureCell(cell, fonts, styles, controls, newPageMergeBand);
+            if (page.signature_cells && page.signature_cells.length > 0) {
+                for (let k = 0; k < page.signature_cells.length; k++) {
+                    let cell = page.signature_cells[k];
+                    private_drawSignatureCell(cell, fonts, styles, controls, newPageMergeBand);
+                }
             }
             //电子签名日期(跟普通格子输出一样)
-            for (let k = 0; k < page.signature_date_cells.length; k++) {
-                let cell = page.signature_date_cells[k];
-                private_drawCell(cell, fonts, styles, controls, newPageMergeBand);
+            if (page.signature_date_cells && page.signature_date_cells.length > 0) {
+                for (let k = 0; k < page.signature_date_cells.length; k++) {
+                    let cell = page.signature_date_cells[k];
+                    private_drawCell(cell, fonts, styles, controls, newPageMergeBand);
+                }
             }
         }
     },

+ 58 - 45
app/reports/rpt_component/jpc_bill_tab.js

@@ -1,28 +1,33 @@
-let JV = require('./jpc_value_define');
-let JE = require('./jpc_rte');
-let JpcFieldHelper = require('./helper/jpc_helper_field');
-let JpcBandHelper = require('./helper/jpc_helper_band');
-let JpcCommonHelper = require('./helper/jpc_helper_common');
-let JpcDiscreteHelper = require('./helper/jpc_helper_discrete');
-let JpcTextHelper = require('./helper/jpc_helper_text');
-let JpcCommonOutputHelper = require('./helper/jpc_helper_common_output');
-let JpcAreaHelper = require('./helper/jpc_helper_area');
+'use strict';
 
-let JpcBillTabSrv = function(){};
-JpcBillTabSrv.prototype.createNew = function(){
-    let JpcBillTabResult = {};
+const JV = require('./jpc_value_define');
+const JE = require('./jpc_rte');
+const JpcFieldHelper = require('./helper/jpc_helper_field');
+const JpcBandHelper = require('./helper/jpc_helper_band');
+const JpcCommonHelper = require('./helper/jpc_helper_common');
+const JpcDiscreteHelper = require('./helper/jpc_helper_discrete');
+const JpcTextHelper = require('./helper/jpc_helper_text');
+const JpcCommonOutputHelper = require('./helper/jpc_helper_common_output');
+const JpcAreaHelper = require('./helper/jpc_helper_area');
+
+const JpcBillTabSrv = function() {};
+JpcBillTabSrv.prototype.createNew = function() {
+    const JpcBillTabResult = {};
     JpcBillTabResult.initialize = function() {
-        let me = this;
+        const me = this;
         me.disp_fields_idx = [];
+
+        me.signatureRst = [];
+        me.signatureDateRst = [];
     };
     JpcBillTabResult.sorting = function(rptTpl) {
-        let me = this;
+        const me = this;
         JpcFieldHelper.findAndPutDataFieldIdx(rptTpl, rptTpl[JV.NODE_BILL_INFO][JV.NODE_BILL_CONTENT][JV.PROP_BILL_FIELDS], null, me.disp_fields_idx);
     };
     JpcBillTabResult.paging = function(rptTpl, dataObj) {
         let rst = 0;
         function getDataLength(fields_str) {
-            let dataFields = dataObj[fields_str];
+            const dataFields = dataObj[fields_str];
             if (dataFields && dataFields.length > 0) {
                 rst = dataFields[0].length;
             }
@@ -40,26 +45,30 @@ JpcBillTabSrv.prototype.createNew = function(){
         }
         return rst;
     };
-    JpcBillTabResult.outputAsPreviewPage = function (rptTpl, bands, controls, $CURRENT_RPT) {
-        let me = this, rst = [], vIdx = [];
-        //只预览第一页的数据
-        let pageStatus = [true, true, false, true, false, false, false, false];
+    JpcBillTabResult.outputAsPreviewPage = function(rptTpl, bands, controls, $CURRENT_RPT) {
+        const me = this;
+        let rst = [];
+        // const vIdx = [];
+        // 只预览第一页的数据
+        const pageStatus = [true, true, false, true, false, false, false, false];
         JpcBandHelper.setBandArea(bands, rptTpl, pageStatus, true, false);
-        let unitFactor = JpcCommonHelper.getUnitFactor(rptTpl);
+        const unitFactor = JpcCommonHelper.getUnitFactor(rptTpl);
         rst = rst.concat(me.outputPreviewContent(rptTpl, bands, unitFactor, controls, pageStatus));
         rst = rst.concat(JpcDiscreteHelper.outputPreviewDiscreteInfo(rptTpl[JV.NODE_BILL_INFO][JV.NODE_DISCRETE_INFO], bands, unitFactor, pageStatus));
         return rst;
     };
-    JpcBillTabResult.outputAsSimpleJSONPage = function (rptTpl, dataObj, page, bands, controls, $CURRENT_RPT, customizeCfg) {
-        let me = this, rst = [], tabRstLst = [];
-        //1 calculate the band position
-        let pageStatus = [true, false, false, false, false, false, false, false];
+    JpcBillTabResult.outputAsSimpleJSONPage = function(rptTpl, dataObj, page, bands, controls, $CURRENT_RPT, customizeCfg) {
+        const me = this;
+        let rst = [];
+        const tabRstLst = [];
+        // 1. calculate the band position
+        const pageStatus = [true, false, false, false, false, false, false, false];
         JpcBandHelper.setBandArea(bands, rptTpl, pageStatus);
-        //2. start to output detail-part
-        let unitFactor = JpcCommonHelper.getUnitFactor(rptTpl);
-        //2.1 output content
+        // 2. start to output detail-part
+        const unitFactor = JpcCommonHelper.getUnitFactor(rptTpl);
+        //  2.1 output content
         tabRstLst.push(me.outputContent(rptTpl, dataObj, page, bands, unitFactor, controls, pageStatus, $CURRENT_RPT, customizeCfg));
-        //2.2 output discrete
+        //  2.2 output discrete
         tabRstLst.push(JpcDiscreteHelper.outputDiscreteInfo(rptTpl[JV.NODE_BILL_INFO][JV.NODE_DISCRETE_INFO], bands, dataObj, unitFactor, pageStatus, page - 1, 1, 0, $CURRENT_RPT, customizeCfg));
         for (let i = 0; i < tabRstLst.length; i++) {
             rst = rst.concat(tabRstLst[i]);
@@ -69,15 +78,15 @@ JpcBillTabSrv.prototype.createNew = function(){
     };
     JpcBillTabResult.outputPreviewContent = function(rptTpl, bands, unitFactor, controls, pageStatus) {
         let rst = [];
-        let tab = rptTpl[JV.NODE_BILL_INFO][JV.NODE_BILL_CONTENT];
-        let band = bands[tab[JV.PROP_BAND_NAME]];
+        const tab = rptTpl[JV.NODE_BILL_INFO][JV.NODE_BILL_CONTENT];
+        const band = bands[tab[JV.PROP_BAND_NAME]];
         if (band) {
             if (pageStatus[band[JV.BAND_PROP_DISPLAY_TYPE]]) {
-                let tab_fields = tab[JV.PROP_BILL_FIELDS];
+                const tab_fields = tab[JV.PROP_BILL_FIELDS];
                 for (let i = 0; i < tab_fields.length; i++) {
-                    let tab_field = tab_fields[i];
+                    const tab_field = tab_fields[i];
                     if (!(tab_field[JV.PROP_HIDDEN])) {
-                        let cellItem = JpcCommonOutputHelper.createCommonOutput(tab_field, "", controls);
+                        const cellItem = JpcCommonOutputHelper.createCommonOutput(tab_field, '', controls);
                         cellItem[JV.PROP_AREA] = JpcAreaHelper.outputArea(tab_field[JV.PROP_AREA], band, unitFactor, 1, 0, 1, 0, 1, 0, false, false);
                         rst.push(cellItem);
                     }
@@ -98,22 +107,26 @@ JpcBillTabSrv.prototype.createNew = function(){
         return rst;
     };
     JpcBillTabResult.outputContent = function(rptTpl, dataObj, page, bands, unitFactor, controls, pageStatus, $CURRENT_RPT, customizeCfg) {
-        let me = this, rst = [];
-        let tab = rptTpl[JV.NODE_BILL_INFO][JV.NODE_BILL_CONTENT];
-        let band = bands[tab[JV.PROP_BAND_NAME]];
+        const me = this;
+        let rst = [];
+        const tab = rptTpl[JV.NODE_BILL_INFO][JV.NODE_BILL_CONTENT];
+        const band = bands[tab[JV.PROP_BAND_NAME]];
         if (band) {
             if (pageStatus[band[JV.BAND_PROP_DISPLAY_TYPE]]) {
-                let tab_fields = tab[JV.PROP_BILL_FIELDS];
+                const tab_fields = tab[JV.PROP_BILL_FIELDS];
                 let data_details = null;
                 if (rptTpl[JV.NODE_FIELD_MAP][JV.NODE_DETAIL_FIELDS]) {
                     data_details = dataObj[JV.DATA_DETAIL_DATA];
                 } else if (rptTpl[JV.NODE_FIELD_MAP][JV.NODE_MASTER_FIELDS]) {
                     data_details = dataObj[JV.DATA_MASTER_DATA];
                 }
-                let flexiblePrecisionRefObj = null, flexibleRefField = null, precision_ref_data = null;
+                let flexiblePrecisionRefObj = null;
+                let flexibleRefField;
+                let precision_ref_data;
                 for (let i = 0; i < tab_fields.length; i++) {
-                    let tab_field = tab_fields[i];
-                    let data_field = null, map_data_field = JE.F(tab_field[JV.PROP_FIELD_ID], $CURRENT_RPT);
+                    const tab_field = tab_fields[i];
+                    let data_field = null;
+                    const map_data_field = JE.F(tab_field[JV.PROP_FIELD_ID], $CURRENT_RPT);
                     if (me.disp_fields_idx.length > i && me.disp_fields_idx[i] !== JV.BLANK_FIELD_INDEX && (typeof me.disp_fields_idx[i] !== 'object')) {
                         data_field = data_details[me.disp_fields_idx[i]];
                     } else {
@@ -126,8 +139,8 @@ JpcBillTabSrv.prototype.createNew = function(){
                             flexiblePrecisionRefObj = {};
                             flexibleRefField = JE.F(map_data_field[JV.PROP_PRECISION][JV.PROP_FLEXIBLE_REF_FILED_ID], $CURRENT_RPT);
                             precision_ref_data = dataObj[map_data_field.DataNodeName][flexibleRefField.DataSeq];
-                            for (let decimalObj of map_data_field.flexiblePrecisionRefObj) {
-                                flexiblePrecisionRefObj["refUnit_" + decimalObj.unit] = decimalObj.decimal;
+                            for (const decimalObj of map_data_field.flexiblePrecisionRefObj) {
+                                flexiblePrecisionRefObj['refUnit_' + decimalObj.unit] = decimalObj.decimal;
                             }
                         }
                         JpcFieldHelper.resetFlexibleFormat(tab_field, precision_ref_data, flexiblePrecisionRefObj, page - 1, customizeCfg);
@@ -135,8 +148,8 @@ JpcBillTabSrv.prototype.createNew = function(){
                         if (page === 1) JpcFieldHelper.resetFormat(tab_field, map_data_field, customizeCfg);
                     }
                     if (!(tab_field[JV.PROP_HIDDEN])) {
-                        let val = JpcFieldHelper.getValue(data_field, page - 1);
-                        let cellItem = JpcCommonOutputHelper.createCommonOutput(tab_field, val, controls);
+                        const val = JpcFieldHelper.getValue(data_field, page - 1);
+                        const cellItem = JpcCommonOutputHelper.createCommonOutput(tab_field, val, controls);
                         cellItem[JV.PROP_AREA] = JpcAreaHelper.outputArea(tab_field[JV.PROP_AREA], band, unitFactor, 1, 0, 1, 0, 1, 0, false, false);
                         rst.push(cellItem);
                     }
@@ -159,4 +172,4 @@ JpcBillTabSrv.prototype.createNew = function(){
     return JpcBillTabResult;
 };
 
-module.exports = new JpcBillTabSrv();
+module.exports = new JpcBillTabSrv();

+ 2 - 0
app/reports/rpt_component/jpc_cross_tab.js

@@ -206,6 +206,8 @@ JpcCrossTabSrv.prototype.createNew = function(){
         me.crsOrient = JV.PAGE_ORIENTATION_V_FIRST;
         me.pageStatusLst = [];
         me.paging_option = JV.PAGING_OPTION_NORMAL;
+        me.signatureRst = [];
+        me.signatureDateRst = [];
     };
     JpcCrossTabResult.sorting = function(rptTpl, dataObj, dataSeq, $CURRENT_RPT) {
         let me = this;

+ 4 - 0
app/reports/rpt_component/jpc_ex.js

@@ -380,8 +380,12 @@ JpcExSrv.prototype.createNew = function() {
                 }
             } else if (me.crossTab) {
                 rst[JV.PROP_CELLS] = me.crossTab.outputAsSimpleJSONPage(rptTpl, dataObj, page, bands, controls, me, customizeCfg);
+                rst[JV.PROP_SIGNATURE_CELLS] = me.crossTab.signatureRst;
+                rst[JV.PROP_SIGNATURE_DATE_CELLS] = me.crossTab.signatureDateRst;
             } else if (me.billTab) {
                 rst[JV.PROP_CELLS] = me.billTab.outputAsSimpleJSONPage(rptTpl, dataObj, page, bands, controls, me, customizeCfg);
+                rst[JV.PROP_SIGNATURE_CELLS] = me.billTab.signatureRst;
+                rst[JV.PROP_SIGNATURE_DATE_CELLS] = me.billTab.signatureDateRst;
             }
             if (!(me.flowTab && me.flowTab.paging_option === JV.PAGING_OPTION_INFINITY)) {
                 const pageMergeBorder = getPageMergeBorder();

+ 9 - 1
app/service/report_memory.js

@@ -87,7 +87,11 @@ module.exports = app => {
         async _generateStageIm(tid, sid, isTz = true) {
             await this._checkTender(tid);
             await this._checkStage(sid);
+            // console.log('this.ctx.stage.im_type: ' + this.ctx.stage.im_type);
+            // console.log('imType.tz.value: ' + imType.tz.value);
+            // console.log('isTz: ' + isTz);
             if (isTz && this.ctx.stage.im_type !== imType.tz.value) {
+                // console.log('您查看的报表跟设置不符,请查看“总量控制”的报表');
                 throw '您查看的报表跟设置不符,请查看“总量控制”的报表';
             } else if (!isTz && this.ctx.stage.im_type === imType.tz.value) {
                 throw '您查看的报表跟设置不符,请查看“0号台账”的报表';
@@ -106,6 +110,7 @@ module.exports = app => {
                 try {
                     await this._generateStageIm(tid, sid);
                 } catch(err) {
+                    // console.log('getStageImTzData exception');
                     if (err.statck) {
                         this.ctx.logger.error(error);
                     }
@@ -121,7 +126,9 @@ module.exports = app => {
                 this.stageImData = {};
                 try {
                     await this._generateStageIm(tid, sid);
-                } catch(err) {
+                } catch (err) {
+                    // console.log(err);
+                    // console.log('getStageImTzBillsData exception');
                     if (err.statck) {
                         this.ctx.logger.error(error);
                     }
@@ -137,6 +144,7 @@ module.exports = app => {
             try {
                 await this._generateStageIm(tid, sid, false);
             } catch(err) {
+                // console.log('getStageImZlData exception');
                 if (err.statck) {
                     this.ctx.logger.error(error);
                 }