浏览代码

归档冗余数据处理 + 归档签名丢失问题

TonyKang 4 年之前
父节点
当前提交
d13da56cd9

+ 1 - 0
app/controller/report_archive_controller.js

@@ -128,6 +128,7 @@ module.exports = app => {
                     if (item.rpt_id === rptId) {
                         // 考虑到报表模板的稳定性,只保留一项来记录位置就足够了,都不考虑用uuid了
                         item.encryption = content;
+                        item.total_page = ttlPgs;
                         hasArchive = true;
                         break;
                     }

+ 37 - 1
app/controller/signature_controller.js

@@ -48,8 +48,11 @@ module.exports = app => {
             const params = JSON.parse(ctx.request.body.params);
             // console.log(params);
             const rst = await ctx.service.roleRptRel.updateRoleRelationship(params.id, params.tender_id, params.rpt_id, params.stage_id, params.rel_content);
+            const roleRel = await ctx.service.roleRptRel.getRoleRptRelByDetailIds(params.tender_id, params.rpt_id, params.stage_id);
+            // const roleRel = params.rel_content;
+            await encodeSignatureDataUri(roleRel, this.app.baseDir);
             // console.log(rst);
-            ctx.body = { data: rst };
+            ctx.body = { data: rst, signatureRelInfo: roleRel };
             // ctx.body = { data: { msg: 'test the network' } };
             ctx.status = 201;
         }
@@ -109,3 +112,36 @@ module.exports = app => {
 
     return ReportController;
 };
+
+async function encodeSignatureDataUri(roleRel, baseDir) {
+    if (roleRel) {
+        for (const singleRoleRel of roleRel) {
+            if (singleRoleRel.rel_content !== null && singleRoleRel.rel_content !== undefined && singleRoleRel.rel_content !== '') {
+                const roleRelContent = JSON.parse(singleRoleRel.rel_content);
+                for (const role of roleRelContent) {
+                    // console.log(role);
+                    if (role.sign_path !== '') {
+                        const filePath = baseDir + '/app' + role.sign_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;
+                                role.sign_pic = datauri;
+                            } else {
+                                console.log('文件不存在:' + filePath);
+                            }
+                        } catch (err) {
+                            console.error(err);
+                        }
+                    }
+                }
+                singleRoleRel.rel_content = JSON.stringify(roleRelContent);
+            } else {
+                singleRoleRel.rel_content = [];
+            }
+        }
+    }
+}
+

+ 6 - 1
app/public/report/js/rpt_signature.js

@@ -486,10 +486,15 @@ let rptSignatureHelper = {
         rptSignatureHelper.originalRoleRelList = JSON.parse(JSON.stringify(ROLE_REL_LIST));
         CommonAjax.postXsrfEx("/tender/report_api/updateRoleRelationship", params, 10000, true, getCookie('csrfToken_j'),
             function(result){
-                console.log(result);
+                // console.log(result);
                 if (result.data && result.data.insertId > 0) {
                     CURRENT_ROLE_REL_ID = result.data.insertId;
                 }
+                ROLE_REL_LIST = [];
+                for (const signatureRel of result.signatureRelInfo) {
+                    ROLE_REL_LIST.push(JSON.parse(signatureRel.rel_content));
+                }
+                rptSignatureHelper.originalRoleRelList = JSON.parse(JSON.stringify(ROLE_REL_LIST));
             }, function(err){
                 // hintBox.unWaitBox();
             }, function(ex){