Bläddra i källkod

处理图片信息直接输出

Tony Kang 3 år sedan
förälder
incheckning
f58c5fd420

+ 11 - 11
app/public/report/js/jpc_output.js

@@ -411,17 +411,7 @@ let JpcCanvasOutput = {
             } else {
                 control = cell[JV.PROP_CONTROL];
             }
-            if (cell.path) {
-                const img = new Image();
-                img.src = cell.path;
-                img.crossOrigin = 'anonymous';
-                img.onload = function() {
-                    private_drawImage(cell, control, img, (!!cell.isStamp));
-                };
-                img.onerror = function() {
-                    console.log('cell.path error: ' + cell.path);
-                }
-            } else if (cell.pic) {
+            if (cell.pic) {
                 const img = new Image();
                 img.src = cell.pic;
                 img.crossOrigin = 'anonymous';
@@ -433,6 +423,16 @@ let JpcCanvasOutput = {
                     }
                     // private_drawImage(cell, control, img);
                 };
+            } else if (cell.path) {
+                const img = new Image();
+                img.src = cell.path;
+                img.crossOrigin = 'anonymous';
+                img.onload = function() {
+                    private_drawImage(cell, control, img, (!!cell.isStamp));
+                };
+                img.onerror = function() {
+                    console.log('cell.path error: ' + cell.path);
+                }
             }
         }
         function private_getProperSignatureArea(cell, control) {

+ 22 - 2
app/public/report/js/rpt_jsexcel.js

@@ -1063,7 +1063,9 @@ function writeWorkSheetRels(signSheetIdx) {
 
 async function writeImage(path, pic) {
     let rst = null;
-    if (path) {
+    if (pic) {
+        rst = convertPicBase64ToBlob(pic);
+    } else if (path) {
         // 前端方式处理不同,不用考虑哪里(水印也是),直接都一股脑地申请下载即可(重复的浏览器会找cache!)
         let picpath = path; // 前端的path已经是完整的了
         rst = await getBlob(picpath); //这里通过getBlob函数得到的结果已经是所需要的流数据,无需转换
@@ -1775,4 +1777,22 @@ const excelExportUtil = {
             console.log(e);
         }
     }
-};
+};
+
+function convertPicBase64ToBlob(picdata) {
+    //去掉头(如:'data:image/png;base64,'),并转换为byte
+    let splitPic = picdata.split(',');
+    let tmpPicData = '';
+    if (splitPic.length === 2) {
+        tmpPicData = splitPic[1];
+    } else {
+        tmpPicData = splitPic[0];
+    }
+    var bytes = window.atob(tmpPicData);
+    //处理异常,将ascii码小于0的转换为大于0
+    var ab = new Uint8Array(bytes.length);
+    for (var i = 0; i < bytes.length; i++) {
+        ab[i] = bytes.charCodeAt(i);
+    }
+    return new Blob([ab], { type: 'application/pdf' });
+}

+ 1 - 1
app/public/report/js/rpt_main.js

@@ -440,7 +440,7 @@ let zTreeOprObj = {
                     rptSignatureHelper.originalRoleRelList = me._parseRoleRelList(result.signatureRelInfo[0].rel_content);
                     if (current_stage_status === 3) {
                         rptSignatureHelper.mergeSignDate(pageRst, ROLE_REL_LIST, true);
-                        rptSignatureHelper.mergeSignature(pageRst, ROLE_REL_LIST);
+                        rptSignatureHelper.mergeSignature(pageRst, ROLE_REL_LIST, true);
                         await rptSignatureHelper.resetDummySignature(pageRst, ROLE_REL_LIST); // 这里重新整理签章坐标信息(因签章大小在后台暂时获取不到,挪到前端处理)
                         rptSignatureHelper.mergeSignAudit(pageRst, ROLE_REL_LIST, STAGE_AUDIT);
                     }

+ 1 - 1
app/public/report/js/rpt_preview_common.js

@@ -57,7 +57,7 @@ async function printPageLoading() {
                 }
                 if (_current_stage_status === 3) {
                     rptSignatureHelper.mergeSignDate(result.data[idx], singleSignatureRelArr, false);
-                    rptSignatureHelper.mergeSignature(result.data[idx], singleSignatureRelArr);
+                    rptSignatureHelper.mergeSignature(result.data[idx], singleSignatureRelArr, true);
                     await rptSignatureHelper.resetDummySignature(result.data[idx], null); // 这里重新整理签章坐标信息(因签章大小在后台暂时获取不到,挪到前端处理)
                     rptSignatureHelper.mergeSignAudit(result.data[idx], singleSignatureRelArr, result.stageAudit);
                 }

+ 3 - 3
app/public/report/js/rpt_print.js

@@ -338,10 +338,10 @@ function buildCellSvg(cell, fonts, styles, controls, pageMergeBorder, rptMergeBo
 
 function buildImage(destRst, cell, control, offsetX, offsetY, adjustY, isHtoV, HtoVStr) {
     let href = '';
-    if (cell.path) {
-        href = 'xlink:href="' + cell.path +'"';
-    } else {
+    if (cell.pic) {
         href = 'href="' + cell.pic +'"';
+    } else {
+        href = 'xlink:href="' + cell.path +'"';
     }
     const area = getProperSignatureArea(cell, control, offsetX, offsetY);
     if (cell.signature_name.indexOf(JV.SIGNATURE_NAME_DUMMY) >= 0) {