Browse Source

code sync

TonyKang 4 years atrás
parent
commit
57c74052dd
2 changed files with 27 additions and 23 deletions
  1. 24 23
      app/controller/report_controller.js
  2. 3 0
      app/public/report/js/jpc_output.js

+ 24 - 23
app/controller/report_controller.js

@@ -342,7 +342,7 @@ module.exports = app => {
             // console.log('after role stage!');
             // console.log(roleRel);
             await encodeSignatureDataUri(roleRel, this.app.baseDir);
-            // await encodeDummySignatureDataUri(pageRst, this.app.baseDir); // 经测试,在页码多且有草图+未审核图片情况下,数据太大
+            await encodeDummySignatureDataUri(pageRst, this.app.baseDir); // 注意草图数据量问题
             const stageFlow = await ctx.service.stageAudit.getAuditGroupByListWithOwner(params.stage_id, params.stage_times);
 
             // console.log('encodeSignatureDataUri!');
@@ -448,9 +448,9 @@ module.exports = app => {
             // console.log('roleRel: ');
             // console.log(roleRel);
             await encodeSignatureDataUri(roleRel, this.app.baseDir);
-            // for (const pageRst of pageRstArr) {
-            //     await encodeDummySignatureDataUri(pageRst, this.app.baseDir);
-            // }
+            for (const pageRst of pageRstArr) {
+                await encodeDummySignatureDataUri(pageRst, this.app.baseDir); // 注意草图数据量问题!
+            }
             // console.log(pageRstArr);
             ctx.body = { data: pageRstArr, signatureRelInfo: roleRel, stageAudit: stgAudit, waterMarkStr };
             ctx.status = 201;
@@ -1263,25 +1263,26 @@ async function encodeDummySignatureDataUri(pageRst, baseDir) {
                     }
                 }
             }
-            for (const signature of page[JV.PROP_WATERMARK_CELLS]) {
-                if (signature.path !== '') {
-                    const filePath = baseDir + '/app' + signature.path;
-                    try {
-                        const res = await isFileExisted(filePath);
-                        if (res) {
-                            const bData = fs.readFileSync(filePath);
-                            const base64Str = bData.toString('base64');
-                            const datauri = 'data:image/png;base64,' + base64Str;
-                            signature.pic = datauri;
-                            signature.path = '';
-                        } else {
-                            console.log('文件不存在:' + filePath);
-                        }
-                    } catch (err) {
-                        console.error(err);
-                    }
-                }
-            }
+            // 考虑优化,水印只需要一张即可,不需要每页都设置
+            // for (const signature of page[JV.PROP_WATERMARK_CELLS]) {
+            //     if (signature.path !== '') {
+            //         const filePath = baseDir + '/app' + signature.path;
+            //         try {
+            //             const res = await isFileExisted(filePath);
+            //             if (res) {
+            //                 const bData = fs.readFileSync(filePath);
+            //                 const base64Str = bData.toString('base64');
+            //                 const datauri = 'data:image/png;base64,' + base64Str;
+            //                 signature.pic = datauri;
+            //                 signature.path = '';
+            //             } else {
+            //                 console.log('文件不存在:' + filePath);
+            //             }
+            //         } catch (err) {
+            //             console.error(err);
+            //         }
+            //     }
+            // }
         }
     }
 }

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

@@ -359,6 +359,9 @@ let JpcCanvasOutput = {
                 img.onload = function() {
                     private_drawImage(cell, control, img);
                 };
+                img.onerror = function() {
+                    console.log('cell.path error: ' + cell.path);
+                }
             } else if (cell.pic) {
                 const img = new Image();
                 img.src = cell.pic;