Browse Source

审核签名输出

Tony Kang 2 years ago
parent
commit
d8220179d0

+ 14 - 3
app/public/report/js/jpc_output.js

@@ -454,8 +454,19 @@ let JpcCanvasOutput = {
                 };
             } else if (cell.path) {
                 let paths = cell.path.split('!;!');
-                for (let dtlPath of paths) {
-                    if (typeof dtlPath === 'string' && dtlPath.length > 10) {
+                for (let dtlPathIdx = 0; dtlPathIdx < paths.length; dtlPathIdx++) {
+                    let dtlPath = paths[dtlPathIdx];
+                    if (typeof dtlPath === 'string' && dtlPath.length > 20) {
+                        if (cell.picFeatures && cell.picFeatures.length === paths.length) {
+                            if (dtlPathIdx === 0) {
+                                cell.area = JSON.parse(JSON.stringify(cell.orgArea));
+                                cell.isOrgShow = false;
+                            } else {
+                                // 重新设置cell area
+                                resetStampArea(control, cell, JV, cell.picFeatures[dtlPathIdx]);
+                                cell.isOrgShow = true;
+                            }
+                        }
                         const img = new Image();
                         if (dtlPath.indexOf(OSS_PATH) < 0 && dtlPath[0] !== '/') {
                             img.src = OSS_PATH + dtlPath;
@@ -505,7 +516,7 @@ let JpcCanvasOutput = {
                     cell.signType
                 );
             }  
-            let area = getProperSignatureArea(cell, control, JV);
+            let area = getProperSignatureArea(cell, control, JpcCanvasOutput.offsetX, JpcCanvasOutput.offsetY, JV);
             if (orgSize) {
                 area[0] = cell.area.Left + JpcCanvasOutput.offsetX; // Left
                 area[1] = cell.area.Top + JpcCanvasOutput.offsetY; // Top

+ 20 - 44
app/public/report/js/rpt_print.js

@@ -349,9 +349,7 @@ function buildCellSvg(cell, fonts, styles, controls, pageMergeBorder, rptMergeBo
     return rst.join("");
 }
 
-function buildImage(destRst, cell, control, offsetX, offsetY, HtoVStr, orgSize = false, offsetArea) {
-    let href = '';
-    const area = getProperSignatureArea(cell, control, offsetX, offsetY);
+function _resetArea(area, orgSize, offsetArea, offsetX, offsetY) {
     if (orgSize) {
         area[0] = cell[JV.PROP_AREA][JV.PROP_LEFT] + offsetX; // Left
         area[1] = cell[JV.PROP_AREA][JV.PROP_TOP] + offsetY; // Top
@@ -364,13 +362,31 @@ function buildImage(destRst, cell, control, offsetX, offsetY, HtoVStr, orgSize =
         area[2] = area[2] - offsetArea[2]; // Right
         area[3] = area[3] - offsetArea[3]; // Bottom
     }
+}
+function buildImage(destRst, cell, control, offsetX, offsetY, HtoVStr, orgSize = false, offsetArea) {
+    let href = '';
+    let area = getProperSignatureArea(cell, control, offsetX, offsetY, JV);
+    _resetArea(area, orgSize, offsetArea, offsetX, offsetY);
     if (cell.pic) {
         href = 'href="' + cell.pic +'"';
         destRst.push('<image x="' + area[0] + '" y="' + area[1] + '" width="' + (area[2] - area[0]) + '" height="' + (area[3] - area[1]) + '" ');
         destRst.push(href + HtoVStr + ' />');
     } else {
         let paths = cell.path.split('!;!');
-        for (let dtlPath of paths) {
+        for (let dtlPathIdx = 0; dtlPathIdx < paths.length; dtlPathIdx++) {
+            let dtlPath = paths[dtlPathIdx];
+            if (cell.picFeatures && cell.picFeatures.length === paths.length) {
+                if (dtlPathIdx === 0) {
+                    cell.area = JSON.parse(JSON.stringify(cell.orgArea));
+                    cell.isOrgShow = false;
+                } else {
+                    // 重新设置cell area
+                    resetStampArea(control, cell, JV, cell.picFeatures[dtlPathIdx]);
+                    cell.isOrgShow = true;
+                }
+                area = getProperSignatureArea(cell, control, offsetX, offsetY, JV);
+                _resetArea(area, orgSize, offsetArea, offsetX, offsetY);
+            }
             if (typeof dtlPath === 'string' && dtlPath.length > 10) {
                 let imgSrc = dtlPath;
                 if (dtlPath.indexOf(OSS_PATH) < 0 && dtlPath[0] !== '/') {
@@ -386,46 +402,6 @@ function buildImage(destRst, cell, control, offsetX, offsetY, HtoVStr, orgSize =
     }
 }
 
-function getProperSignatureArea(cell, control, offsetX, offsetY) {
-    // 约定默认长宽比例是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 '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 '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;
-        }
-    }
-    rst[0] = rst[0] + offsetX;
-    rst[2] = rst[2] + offsetX;
-    rst[1] = rst[1] + offsetY;
-    rst[3] = rst[3] + offsetY;
-    return rst;
-}
-
 function strReplaceAll(targetStr, FindText, RepText) {
     let regExp = new RegExp(FindText, "gm");
     return targetStr.replace(regExp, RepText);

+ 27 - 25
app/public/report/js/rpt_public.js

@@ -71,7 +71,7 @@ function dynamicLoadJs(url, type, callback) {
     });
 }
 
-function getProperSignatureArea(cell, control, JV = null) {
+function getProperSignatureArea(cell, control, offsetX, offsetY, JV = null) {
     // 约定默认长宽比例是2:1,图片分辨率是600*300
     const rst = [0, 0, 0, 0]; // left, top, right, bottom
     if (JV) {
@@ -125,10 +125,10 @@ function getProperSignatureArea(cell, control, JV = null) {
             }
         }
     }
-    rst[0] = rst[0] + JpcCanvasOutput.offsetX;
-    rst[2] = rst[2] + JpcCanvasOutput.offsetX;
-    rst[1] = rst[1] + JpcCanvasOutput.offsetY;
-    rst[3] = rst[3] + JpcCanvasOutput.offsetY;
+    rst[0] = rst[0] + offsetX;
+    rst[2] = rst[2] + offsetX;
+    rst[1] = rst[1] + offsetY;
+    rst[3] = rst[3] + offsetY;
     return rst;
 }
 
@@ -188,26 +188,28 @@ function resetStampArea(ctrl, stampCell, JV, stampFeature = 'not found!') {
         stampCell.area.Right = pLeft + std_stamp_size_width;
         stampCell.area.Bottom = pTop + std_stamp_size_height;
         // 最后一步,如超过报表范围,则要调整坐标
-        const maxRect = stampCell.maxRect;
-        if (stampCell.area.Left < maxRect[0]) {
-            const width = maxRect[0] - stampCell.area.Left;
-            stampCell.area.Left += width;
-            stampCell.area.Right += width;
-        }
-        if (stampCell.area.Top < maxRect[1]) {
-            const height = maxRect[1] - stampCell.area.Top;
-            stampCell.area.Top += height;
-            stampCell.area.Bottom += height;
-        }
-        if (stampCell.area.Right > maxRect[2]) {
-            const width = maxRect[2] - stampCell.area.Right; // 负
-            stampCell.area.Left += width;
-            stampCell.area.Right += width;
-        }
-        if (stampCell.area.Bottom > maxRect[3]) {
-            const height = maxRect[3] - stampCell.area.Bottom;
-            stampCell.area.Top += height;
-            stampCell.area.Bottom += height;
+        if (stampCell.maxRect) {
+            const maxRect = stampCell.maxRect;
+            if (stampCell.area.Left < maxRect[0]) {
+                const width = maxRect[0] - stampCell.area.Left;
+                stampCell.area.Left += width;
+                stampCell.area.Right += width;
+            }
+            if (stampCell.area.Top < maxRect[1]) {
+                const height = maxRect[1] - stampCell.area.Top;
+                stampCell.area.Top += height;
+                stampCell.area.Bottom += height;
+            }
+            if (stampCell.area.Right > maxRect[2]) {
+                const width = maxRect[2] - stampCell.area.Right; // 负
+                stampCell.area.Left += width;
+                stampCell.area.Right += width;
+            }
+            if (stampCell.area.Bottom > maxRect[3]) {
+                const height = maxRect[3] - stampCell.area.Bottom;
+                stampCell.area.Top += height;
+                stampCell.area.Bottom += height;
+            }
         }
     }
 }

+ 22 - 14
app/view/payment/detail.ejs

@@ -155,25 +155,33 @@
     let auditRptPrintHelper = {
         currentPageData: null,
         currentDownloadIdx: 0,
-        resetPicArea: async function(pageData) {
-                // const picFeature = await getPicFeature(imgSrc);
-                // resetStampArea(control, cell, JV, picFeature);
-                // area[0] = cell[JV.PROP_AREA][JV.PROP_LEFT] + offsetX; // Left
-                // area[1] = cell[JV.PROP_AREA][JV.PROP_TOP] + offsetY; // Top
-                // area[2] = cell[JV.PROP_AREA][JV.PROP_RIGHT] + offsetX; // Right
-                // area[3] = cell[JV.PROP_AREA][JV.PROP_BOTTOM] + offsetY; // Bottom
+        chkPicFeatures: async function(pageData) {
             for (let page of pageData.items) {
                 for (let signCell of page.signature_cells) {
-                    //
+                    if (typeof signCell.path === 'string' && signCell.path.length > 10) {
+                        let paths = signCell.path.split('!;!');
+                        signCell.picFeatures = [];
+                        signCell.orgArea = JSON.parse(JSON.stringify(signCell.area));
+                        for (let path of paths) {
+                            let imgSrc = path;
+                            if (path.indexOf(OSS_PATH) < 0 && path[0] !== '/') {
+                                imgSrc = OSS_PATH + path;
+                            }
+                            const picFeature = await getPicFeature(imgSrc);
+                            signCell.picFeatures.push(picFeature);
+                        }
+                    }
                 }
             }
         },
 
-        showPage: function() {
+        showPage: async function() {
+            await auditRptPrintHelper.chkPicFeatures(tesRpttData);
             JpcCanvasOutput.cleanCanvas(VIEW_CANVAS);
             JpcCanvasOutput.drawPageBorder(tesRpttData, VIEW_CANVAS, getScreenDPI());
             JpcCanvasOutput.drawToCanvas(tesRpttData, VIEW_CANVAS, 1, false, true);
         },
+
         directPrint: function() {
             sessionStorage.report_direct_data = JSON.stringify(tesRpttData);
             sessionStorage.closeWaterMark = 1;
@@ -203,11 +211,11 @@
         },
     };
 
-    $(document).ready(() => {
-        autoFlashHeight();
-        auditRptPrintHelper.showPage();
-        iniPage();
-    });
+    // $(document).ready(() => {
+    //     autoFlashHeight();
+    //     auditRptPrintHelper.showPage();
+    //     iniPage();
+    // });
 
     function _getAdhocDummyCells(srcCell, rstCells) {
         if (typeof srcCell.path === 'string') {

+ 1 - 0
app/view/report/rpt_print.ejs

@@ -6,6 +6,7 @@
     <script src="/public/js/jquery/jquery-3.2.1.min.js"></script>
     <script type="text/javascript" src="/public/js/common_ajax.js"></script>
     <script type="text/javascript" src="/public/report/js/jpc_output_value_define.js"></script>
+    <script type="text/javascript" src="/public/report/js/rpt_public.js"></script>
     <script type="text/javascript" src="/public/report/js/jpc_output.js"></script>
     <script type="text/javascript" src="/public/report/js/rpt_print.js"></script>
     <script type="text/javascript" src="/public/report/js/rpt_signature.js"></script>