Browse Source

Merge branch 'master' of http://192.168.1.41:3000/maixinrong/Calculation

MaiXinRong 5 years ago
parent
commit
f15a74806b

+ 84 - 0
app/public/report/js/jpc_output.js

@@ -331,6 +331,80 @@ let JpcCanvasOutput = {
             private_drawCellText(cell, fonts, controls);
             ctx.restore();
         }
+        function private_drawSignatureCell(cell, fonts, styles, controls, mergedBand) {
+            ctx.save();
+            ctx.translate(0.5,0.5);
+            let style = styles[cell[JV.PROP_STYLE]];
+            if (style) {
+                let isNeedMergeBand = private_chkIfInMergedBand(mergedBand, cell);
+                private_drawLine(cell, ctx, style, JV.PROP_TOP, [JV.PROP_LEFT, JV.PROP_TOP],[JV.PROP_RIGHT, JV.PROP_TOP], mergedBand, styles, isNeedMergeBand);
+                private_drawLine(cell, ctx, style, JV.PROP_RIGHT, [JV.PROP_RIGHT, JV.PROP_TOP],[JV.PROP_RIGHT, JV.PROP_BOTTOM], mergedBand, styles, isNeedMergeBand);
+                private_drawLine(cell, ctx, style, JV.PROP_BOTTOM, [JV.PROP_RIGHT, JV.PROP_BOTTOM],[JV.PROP_LEFT, JV.PROP_BOTTOM], mergedBand, styles, isNeedMergeBand);
+                private_drawLine(cell, ctx, style, JV.PROP_LEFT, [JV.PROP_LEFT, JV.PROP_BOTTOM],[JV.PROP_LEFT, JV.PROP_TOP], mergedBand, styles, isNeedMergeBand);
+            }
+            private_drawSignatureCellText(cell, controls);
+            ctx.restore();
+        }
+        function private_drawSignatureCellText(cell, controls) {
+            let control = null;
+            if (typeof cell[JV.PROP_CONTROL] === "string") {
+                control = controls[cell[JV.PROP_CONTROL]];
+            } else {
+                control = cell[JV.PROP_CONTROL];
+            }
+            if (cell.path) {
+                const img = new Image();
+                img.src = cell.path;
+                img.onload(function() {
+                    private_drawImage(cell, control, img);
+                });
+            } else if (cell.pic) {
+                const img = new Image();
+                img.src = cell.pic;
+                img.onload(function() {
+                    private_drawImage(cell, control, img);
+                });
+            }
+        }
+        function private_getProperSignatureArea(cell, control) {
+            // 约定默认长宽比例是2:1,图片分辨率是600*300
+            const rst = [0, 0, 0, 0]; // left, top, right, bottom
+            if (cell && cell[JV.PROP_AREA]) {
+                let width = cell[JV.PROP_AREA][JV.PROP_RIGHT] - cell[JV.PROP_AREA][JV.PROP_LEFT],
+                    height = cell[JV.PROP_AREA][JV.PROP_BOTTOM] - cell[JV.PROP_AREA][JV.PROP_TOP];
+                if (width > height * 2) {
+                    width = height * 2;
+                } else {
+                    height = width / 2;
+                }
+                switch (control[JV.CONTROL_PROPS[JV.CONTROL_PROP_IDX_HORIZON]]) {
+                    case JV.PROP_LEFT:
+                        rst[0] = cell[JV.PROP_AREA][JV.PROP_LEFT];
+                        rst[1] = cell[JV.PROP_AREA][JV.PROP_TOP];
+                        rst[2] = rst[0] + width;
+                        rst[3] = rst[1] + height;
+                        break;
+                    case JV.PROP_RIGHT:
+                        rst[2] = cell[JV.PROP_AREA][JV.PROP_RIGHT];
+                        rst[3] = cell[JV.PROP_AREA][JV.PROP_BOTTOM];
+                        rst[0] = rst[2] - width;
+                        rst[1] = rst[3] - height;
+                        break;
+                    default:
+                        //center
+                        rst[0] = (cell[JV.PROP_AREA][JV.PROP_LEFT] + cell[JV.PROP_AREA][JV.PROP_RIGHT] - width) / 2;
+                        rst[1] = cell[JV.PROP_AREA][JV.PROP_TOP];
+                        rst[2] = rst[0] + width;
+                        rst[3] = rst[1] + height;
+                        break;
+                }
+            }
+            return rst;
+        }
+        function private_drawImage(cell, control, imageData) {
+            let area = private_getProperSignatureArea(cell, control);
+            ctx.drawImage(imageData, area[0], area[1], area[2] - area[0], area[3] - area[1]);
+        }
         function getIniPageMergeBorder(mergedBand) {
             let rst = {};
             if (mergedBand) {
@@ -360,6 +434,16 @@ let JpcCanvasOutput = {
                 let cell = page.cells[j];
                 private_drawCell(cell, fonts, styles, controls, newPageMergeBand);
             }
+            //电子签名
+            for (let k = 0; k < page.signature_cells.length; j++) {
+                let cell = page.signature_cells[k];
+                private_drawSignatureCell(cell, fonts, styles, controls, newPageMergeBand);
+            }
+            //电子签名日期(跟普通格子输出一样)
+            for (let k = 0; k < page.signature_date_cells.length; j++) {
+                let cell = page.signature_date_cells[k];
+                private_drawCell(cell, fonts, styles, controls, newPageMergeBand);
+            }
         }
     },
     drawPageBorder: function(rptTpl, canvas, resolution) {

+ 26 - 22
app/reports/rpt_component/helper/jpc_helper_common_output.js

@@ -1,14 +1,17 @@
-let JV = require('../jpc_value_define');
-let JpcFieldHelper = require('./jpc_helper_field');
+'use strict';
 
-let JpcCommonOutputHelper = {
-    createCommonOutputWithoutDecorate: function (node, value, forceCombine) {
-        let me = this, rst = {};
-        //1. font/style/control
+const JV = require('../jpc_value_define');
+const JpcFieldHelper = require('./jpc_helper_field');
+
+const JpcCommonOutputHelper = {
+    createCommonOutputWithoutDecorate: function(node, value, forceCombine) {
+        const me = this;
+        const rst = {};
+        // 1. font/style/control
         rst[JV.PROP_FONT] = node[[JV.PROP_FONT]];
         rst[JV.PROP_CONTROL] = node[[JV.PROP_CONTROL]];
         rst[JV.PROP_STYLE] = node[[JV.PROP_STYLE]];
-        //2. value
+        // 2. value
         rst[JV.PROP_VALUE] = value;
         me.formatCell(node[JV.PROP_FORMAT], rst);
         // innerFormat(node[JV.PROP_FORMAT], rst);
@@ -24,32 +27,33 @@ let JpcCommonOutputHelper = {
         }
         return rst;
     },
-    createCommonOutput: function (node, value, controls) {
-        let me = this, rst = {};
-        //1. font/style/control
+    createCommonOutput: function(node, value, controls) {
+        const me = this;
+        const rst = {};
+        // 1. font/style/control
         rst[JV.PROP_FONT] = node[[JV.PROP_FONT]];
         rst[JV.PROP_CONTROL] = node[[JV.PROP_CONTROL]];
         rst[JV.PROP_STYLE] = node[[JV.PROP_STYLE]];
-        //2. value
+        // 2. value
         rst[JV.PROP_VALUE] = value;
         JpcFieldHelper.decorateValue(rst, controls);
         me.formatCell(node[JV.PROP_FORMAT], rst);
         // innerFormat(node[JV.PROP_FORMAT], rst);
-        if (node[JV.PROP_PREFIX] && rst[JV.PROP_VALUE] !== null && rst[JV.PROP_VALUE] !== "") {
+        if (node[JV.PROP_PREFIX] && rst[JV.PROP_VALUE] !== null && rst[JV.PROP_VALUE] !== '') {
             rst[JV.PROP_VALUE] = node[JV.PROP_PREFIX] + rst[JV.PROP_VALUE];
         }
-        if (node[JV.PROP_SUFFIX] && rst[JV.PROP_VALUE] !== null && rst[JV.PROP_VALUE] !== "") {
+        if (node[JV.PROP_SUFFIX] && rst[JV.PROP_VALUE] !== null && rst[JV.PROP_VALUE] !== '') {
             rst[JV.PROP_VALUE] = rst[JV.PROP_VALUE] + node[JV.PROP_SUFFIX];
         }
         return rst;
     },
-    formatCell: function (formatStr, rstCell) {
+    formatCell: function(formatStr, rstCell) {
         if (formatStr) {
             if (!(isNaN(parseFloat(rstCell[JV.PROP_VALUE])))) {
-                let dotIdx = formatStr.indexOf(".");
+                const dotIdx = formatStr.indexOf('.');
                 if (dotIdx >= 0) {
                     let tmpStr = parseFloat(rstCell[JV.PROP_VALUE]).toFixed(formatStr.length - dotIdx - 1);
-                    let digStr = formatStr.substr(dotIdx + 1, formatStr.length - dotIdx);
+                    const digStr = formatStr.substr(dotIdx + 1, formatStr.length - dotIdx);
                     for (let sIdx = digStr.length - 1; sIdx >= 0; sIdx--) {
                         if (digStr[sIdx] === '#') {
                             if (tmpStr.length > 0 && tmpStr[tmpStr.length - 1] === '0') {
@@ -66,18 +70,18 @@ let JpcCommonOutputHelper = {
                 } else {
                     rstCell[JV.PROP_VALUE] = parseFloat(rstCell[JV.PROP_VALUE]).toFixed(0);
                 }
-                let commaIdx = formatStr.indexOf(",");
+                const commaIdx = formatStr.indexOf(',');
                 if (commaIdx >= 0) {
                     rstCell[JV.PROP_VALUE] = comdify(rstCell[JV.PROP_VALUE].toString());
                 }
             }
         }
-    }
+    },
 };
 
-function comdify(numStr){
-    let re = /\d{1,3}(?=(\d{3})+$)/g;
-    return numStr.replace(/^(\d+)((\.\d+)?)$/,function(s,s1,s2){return s1.replace(re,"$&,")+s2;});
+function comdify(numStr) {
+    const re = /\d{1,3}(?=(\d{3})+$)/g;
+    return numStr.replace(/^(\d+)((\.\d+)?)$/, function(s, s1, s2) { return s1.replace(re, '$&,') + s2; });
 }
 
-module.exports = JpcCommonOutputHelper;
+module.exports = JpcCommonOutputHelper;

+ 15 - 2
app/reports/rpt_component/helper/jpc_helper_discrete.js

@@ -8,7 +8,7 @@ const JpcAreaHelper = require('./jpc_helper_area');
 const JpcFieldHelper = require('./jpc_helper_field');
 
 const JpcDiscreteHelper = {
-    outputDiscreteInfo: function(discreteArray, bands, dataObj, unitFactor, pageStatus, segIdx, multiCols, multiColIdx, $CURRENT_RPT, customizeCfg) {
+    outputDiscreteInfo: function(discreteArray, bands, dataObj, unitFactor, pageStatus, segIdx, multiCols, multiColIdx, $CURRENT_RPT, customizeCfg, signatureRst, signatureDateRst) {
         const rst = [];
         if (discreteArray && dataObj) {
             for (let i = 0; i < discreteArray.length; i++) {
@@ -28,7 +28,20 @@ const JpcDiscreteHelper = {
                         for (let j = 0; j < discreteArray[i][JV.PROP_DISCRETE_FIELDS].length; j++) {
                             const df = discreteArray[i][JV.PROP_DISCRETE_FIELDS][j];
                             if (JE.isSignature(df[JV.PROP_FIELD_ID], $CURRENT_RPT)) {
-                                //
+                                // 这里输出到signatureRst
+                                if (Array.isArray(signatureRst)) {
+                                    const map_data_field = JE.F(df[JV.PROP_FIELD_ID], $CURRENT_RPT);
+                                    const signatureItem = { signature_name: map_data_field[JV.PROP_NAME], path: null, pic: null };
+                                    signatureItem[JV.PROP_AREA] = JpcAreaHelper.outputArea(df[JV.PROP_AREA], band, unitFactor, 1, 0, 1, 0, 1, 0, false, false);
+                                    signatureRst.push(signatureItem);
+                                }
+                            } else if (JE.isDynamicParam(df[JV.PROP_PARAM_ID], $CURRENT_RPT)) {
+                                // 这里输出到signatureDateRst
+                                if (Array.isArray(signatureDateRst)) {
+                                    const param = JE.P(df[JV.PROP_PARAM_ID], $CURRENT_RPT);
+                                    const signatureDateItem = JpcCommonOutputHelper.createCommonOutputWithoutDecorate(df, param[JV.PROP_DFT_VALUE], true);
+                                    signatureDateRst.push(signatureDateItem);
+                                }
                             } else {
                                 let value = '';
                                 if (df[JV.PROP_FIELD_ID]) {

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

@@ -364,6 +364,8 @@ JpcExSrv.prototype.createNew = function() {
                         adHocMergePos = {};
                     }
                     rst[JV.PROP_CELLS] = me.flowTab.outputAsSimpleJSONPage(rptTpl, dataObj, page, bands, controls, adHocMergePos, me, customizeCfg);
+                    rst[JV.PROP_SIGNATURE_CELLS] = me.flowTab.signatureRst;
+                    rst[JV.PROP_SIGNATURE_DATE_CELLS] = me.flowTab.signatureDateRst;
                     if (adHocMergePos) {
                         adHocMergePos[JV.NODE_PAGE_SIZE] = JpcCommonHelper.getPageSize(rptTpl);
                         rst[JV.PAGE_SPECIAL_MERGE_POS] = adHocMergePos;
@@ -372,6 +374,8 @@ JpcExSrv.prototype.createNew = function() {
                 } else {
                     if (!me.isFollowMode) {
                         rst[JV.PROP_CELLS] = me.flowTabEx.outputAsSimpleJSONPage(rptTpl, dataObj, page - (me.totalPages - me.exTotalPages), bands, controls, adHocMergePos, me, customizeCfg);
+                        rst[JV.PROP_SIGNATURE_CELLS] = me.flowTabEx.signatureRst;
+                        rst[JV.PROP_SIGNATURE_DATE_CELLS] = me.flowTabEx.signatureDateRst;
                     }
                 }
             } else if (me.crossTab) {

+ 14 - 11
app/reports/rpt_component/jpc_flow_tab.js

@@ -175,6 +175,9 @@ JpcFlowTabSrv.prototype.createNew = function() {
         me.pageSumValLst = [];
         me.multiCols = 1;
         me.pagesAmt = 0;
+
+        me.signatureRst = [];
+        me.signatureDateRst = [];
     };
     JpcFlowTabResult.sorting = function(rptTpl, dataObj, dataSeq, $CURRENT_RPT) {
         const me = this;
@@ -750,7 +753,7 @@ JpcFlowTabSrv.prototype.createNew = function() {
         }
         const unitFactor = JpcCommonHelper.getUnitFactor(rptTpl);
         // 2.2 Column tab
-        rst = rst.concat(me.outputColumn(rptTpl, null, 1, 0, bands, unitFactor, 0));
+        rst = rst.concat(me.outputColumn(rptTpl, null, 1, 0, bands, unitFactor, 0, $CURRENT_RPT, null));
         // 2.1 Content-Tab
         rst = rst.concat(me.outputPreviewContent(rptTpl, bands, unitFactor, controls, pageStatus, maxRowRec));
         // 2.3 Sum Seg
@@ -781,14 +784,14 @@ JpcFlowTabSrv.prototype.createNew = function() {
             // 2.1 Content-Tab
             tabRstLst.push(me.outputContent(rptTpl, dataObj, page, bands, unitFactor, controls, 0, $CURRENT_RPT, customizeCfg));
             // 2.2 Column tab
-            tabRstLst.push(me.outputColumn(rptTpl, dataObj, page, segIdx, bands, unitFactor, 0));
+            tabRstLst.push(me.outputColumn(rptTpl, dataObj, page, segIdx, bands, unitFactor, 0, $CURRENT_RPT, customizeCfg));
             // 2.3 Sum Seg
             tabRstLst.push(me.outputSegSum(rptTpl, dataObj, page, segIdx, bands, unitFactor, controls, $CURRENT_RPT, customizeCfg));
             // 2.4 Sum Page
             tabRstLst.push(me.outputPageSum(rptTpl, dataObj, page, segIdx, bands, unitFactor, controls, $CURRENT_RPT, customizeCfg));
             // 2.5 Group
             // 2.6 Discrete
-            tabRstLst.push(JpcDiscreteHelper.outputDiscreteInfo(rptTpl[FLOW_NODE_STR][JV.NODE_DISCRETE_INFO], bands, dataObj, unitFactor, me.pageStatusLst[page - 1], segIdx, 1, 0, $CURRENT_RPT, customizeCfg));
+            tabRstLst.push(JpcDiscreteHelper.outputDiscreteInfo(rptTpl[FLOW_NODE_STR][JV.NODE_DISCRETE_INFO], bands, dataObj, unitFactor, me.pageStatusLst[page - 1], segIdx, 1, 0, $CURRENT_RPT, customizeCfg, me.signatureRst, me.signatureDateRst));
             // 3. reset merge band position
             if (bands[JV.BAND_PROP_MERGE_BAND] && adHocMergePos) {
                 const mergedBand = bands[JV.BAND_PROP_MERGE_BAND];
@@ -815,7 +818,7 @@ JpcFlowTabSrv.prototype.createNew = function() {
                 // 2.1 Content-Tab
                 tabRstLst.push(me.outputContent(rptTpl, dataObj, actualPage, bands, unitFactor, controls, pi, $CURRENT_RPT, customizeCfg));
                 // 2.2 Column tab
-                tabRstLst.push(me.outputColumn(rptTpl, dataObj, actualPage, segIdx, bands, unitFactor, pi));
+                tabRstLst.push(me.outputColumn(rptTpl, dataObj, actualPage, segIdx, bands, unitFactor, pi, $CURRENT_RPT, customizeCfg));
                 // 2.3 Sum Seg
                 tabRstLst.push(me.outputSegSum(rptTpl, dataObj, actualPage, segIdx, bands, unitFactor, controls, $CURRENT_RPT, customizeCfg));
                 // 2.4 Sum Page
@@ -823,7 +826,7 @@ JpcFlowTabSrv.prototype.createNew = function() {
                 // 2.5 Group
                 // 2.6 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, customizeCfg));
+                    tabRstLst.push(JpcDiscreteHelper.outputDiscreteInfo(rptTpl[FLOW_NODE_STR][JV.NODE_DISCRETE_INFO], bands, dataObj, unitFactor, me.pageStatusLst[actualPage - 1], segIdx, 1, pi, $CURRENT_RPT, customizeCfg, me.signatureRst, me.signatureDateRst));
                 }
             }
         }
@@ -1169,7 +1172,7 @@ JpcFlowTabSrv.prototype.createNew = function() {
         me.combinePageCells(rst, verticalCombinePos, horizonCombinePos);
         return rst;
     };
-    JpcFlowTabResult.outputColumn = function(rptTpl, dataObj, page, segIdx, bands, unitFactor, multiColIdx) {
+    JpcFlowTabResult.outputColumn = function(rptTpl, dataObj, page, segIdx, bands, unitFactor, multiColIdx, $CURRENT_RPT, customizeCfg) {
         const me = this;
         let rst = [];
         const FLOW_NODE_STR = me.isEx ? JV.NODE_FLOW_INFO_EX : JV.NODE_FLOW_INFO;
@@ -1178,7 +1181,7 @@ JpcFlowTabSrv.prototype.createNew = function() {
         if (band) {
             const pageStatus = me.pageStatusLst[page - 1];
             if (pageStatus[band[JV.BAND_PROP_DISPLAY_TYPE]]) {
-                rst = rst.concat(me.commonTabRestOutput(dataObj, page, segIdx, bands, band, unitFactor, tab, multiColIdx));
+                rst = rst.concat(me.commonTabRestOutput(dataObj, page, segIdx, bands, band, unitFactor, tab, multiColIdx, $CURRENT_RPT, customizeCfg));
             }
         }
         return rst;
@@ -1236,7 +1239,7 @@ JpcFlowTabSrv.prototype.createNew = function() {
                     cellItem[JV.PROP_AREA] = JpcAreaHelper.outputArea(tab_fields[i][JV.PROP_AREA], band, unitFactor, 1, 0, 1, 0, me.multiCols, 0, false, false);
                     rst.push(cellItem);
                 }
-                rst = rst.concat(me.commonTabRestOutput(dataObj, page, segIdx, bands, band, unitFactor, tab, 0));
+                rst = rst.concat(me.commonTabRestOutput(dataObj, page, segIdx, bands, band, unitFactor, tab, 0, $CURRENT_RPT, customizeCfg));
             }
         }
         return rst;
@@ -1267,7 +1270,7 @@ JpcFlowTabSrv.prototype.createNew = function() {
                     cellItem[JV.PROP_AREA] = JpcAreaHelper.outputArea(tab_fields[i][JV.PROP_AREA], band, unitFactor, 1, 0, 1, 0, me.multiCols, 0, false, false);
                     rst.push(cellItem);
                 }
-                rst = rst.concat(me.commonTabRestOutput(dataObj, page, segIdx, bands, band, unitFactor, tab, 0));
+                rst = rst.concat(me.commonTabRestOutput(dataObj, page, segIdx, bands, band, unitFactor, tab, 0, $CURRENT_RPT, customizeCfg));
             }
         }
         return rst;
@@ -1344,7 +1347,7 @@ JpcFlowTabSrv.prototype.createNew = function() {
             }
         }
     };
-    JpcFlowTabResult.commonTabRestOutput = function(dataObj, page, segIdx, bands, band, unitFactor, tab, multiColIdx) {
+    JpcFlowTabResult.commonTabRestOutput = function(dataObj, page, segIdx, bands, band, unitFactor, tab, multiColIdx, $CURRENT_RPT, customizeCfg) {
         const me = this;
         let rst = [];
         if (tab[JV.PROP_TEXT]) {
@@ -1356,7 +1359,7 @@ JpcFlowTabSrv.prototype.createNew = function() {
             }
         }
         if (tab[JV.NODE_DISCRETE_INFO]) {
-            rst = rst.concat(JpcDiscreteHelper.outputDiscreteInfo(tab[JV.NODE_DISCRETE_INFO], bands, dataObj, unitFactor, me.pageStatusLst[page - 1], segIdx, 1, 0, null));
+            rst = rst.concat(JpcDiscreteHelper.outputDiscreteInfo(tab[JV.NODE_DISCRETE_INFO], bands, dataObj, unitFactor, me.pageStatusLst[page - 1], segIdx, 1, 0, $CURRENT_RPT, customizeCfg, me.signatureRst, me.signatureDateRst));
         }
         return rst;
     };

+ 2 - 2
app/reports/rpt_component/jpc_rte.js

@@ -157,7 +157,7 @@ const JE = {
             rst = $CURRENT_RPT.params[JV.NODE_DYNAMIC_DATE_PARAMS][JV.PROP_ID + '_' + pID] !== undefined;
         }
         return rst;
-    }
+    },
 };
 
-module.exports = JE;
+module.exports = JE;

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

@@ -296,6 +296,8 @@ module.exports = {
     PROP_PAGE_SEQ: 'page_seq',
     PROP_PAGE_MERGE_BORDER: 'page_merge_border',
     PROP_CELLS: 'cells',
+    PROP_SIGNATURE_CELLS: 'signature_cells',
+    PROP_SIGNATURE_DATE_CELLS: 'signature_date_cells',
 
     PAGING_OPTION_NORMAL: 'normal',
     PAGING_OPTION_INFINITY: 'infinity',