Browse Source

code sync

TonyKang 3 years ago
parent
commit
83ac124374
2 changed files with 47 additions and 4 deletions
  1. 13 0
      app/controller/signature_controller.js
  2. 34 4
      app/public/report/js/rpt_signature.js

+ 13 - 0
app/controller/signature_controller.js

@@ -2,6 +2,7 @@
 /**
  * Created by Tony on 2019/9/26.
  */
+const fs = require('fs');
 
 module.exports = app => {
     class ReportController extends app.BaseController {
@@ -113,6 +114,18 @@ module.exports = app => {
     return ReportController;
 };
 
+function isFileExisted(file) {
+    return new Promise(function(resolve, reject) {
+        fs.access(file, err => {
+            if (err) {
+                reject(false);
+            } else {
+                resolve(true);
+            }
+        });
+    });
+}
+
 async function encodeSignatureDataUri(roleRel, baseDir) {
     if (roleRel) {
         for (const singleRoleRel of roleRel) {

+ 34 - 4
app/public/report/js/rpt_signature.js

@@ -456,8 +456,20 @@ let rptSignatureHelper = {
             }
         );
     },
+
+    _parseRoleRelList: function(org_rel_content) {
+        const rst = JSON.parse(org_rel_content);
+        for (const role_rel of rst) {
+            if (role_rel.sign_date !== null && role_rel.sign_date !== undefined && role_rel.sign_date.length >= 8) {
+                role_rel.sign_date = new Date(role_rel.sign_date);
+            }
+        }
+        return rst;
+    },
+
     setupAfterSelectSignature: function (signatureDivId) {
         //0. 签名日期
+        let me = rptSignatureHelper;
         rptSignatureHelper.resetSignDate(signatureDivId);
         rptSignatureHelper.resetSignAudit();
         if (current_stage_status === 3) {
@@ -490,11 +502,29 @@ let rptSignatureHelper = {
                 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));
+                // 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));
+
+                // ROLE_REL_LIST = me._parseRoleRelList(result.signatureRelInfo[0].rel_content);
+                // rptSignatureHelper.originalRoleRelList = me._parseRoleRelList(result.signatureRelInfo[0].rel_content);
+
+                if (result.signatureRelInfo && result.signatureRelInfo.length > 0) {
+                    // CURRENT_ROLE_REL_ID = result.signatureRelInfo[0].id;
+                    ROLE_REL_LIST = me._parseRoleRelList(result.signatureRelInfo[0].rel_content);
+                    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.mergeSignAudit(pageRst, ROLE_REL_LIST, STAGE_AUDIT);
+                    }
+                } else {
+                    // CURRENT_ROLE_REL_ID = -1;
+                    ROLE_REL_LIST = [];
                 }
-                rptSignatureHelper.originalRoleRelList = JSON.parse(JSON.stringify(ROLE_REL_LIST));
+
             }, function(err){
                 // hintBox.unWaitBox();
             }, function(ex){