浏览代码

图片签名在归档时输出问题

Tony Kang 1 年之前
父节点
当前提交
8de94c0af1
共有 1 个文件被更改,包括 61 次插入32 次删除
  1. 61 32
      app/public/report/js/rpt_archive.js

+ 61 - 32
app/public/report/js/rpt_archive.js

@@ -628,33 +628,37 @@ let rptArchiveObj = {
             try {
                 let signCells = [];
                 let txtSignCells = [];
+                let dummyTxtSignCells = [];
+                const restoreCells = (srcCells, targetCellsStr) => {
+                    if (srcCells.length > 0) {
+                        currentRptPageRst.items.forEach((pageItem, pageIdx) => {
+                            srcCells[pageIdx].forEach((srcCell) => {
+                                pageItem[targetCellsStr].push(srcCell);
+                            });
+                            srcCells[pageIdx] = null;
+                        });
+                    }
+                };
                 if (PAGE_SHOW.isTextSignature) {
                     // 如果是显示文本签名,需要把相关签名移除(草图不动),等创建完后再加回来
                     // 批量归档的数据后台会处理(已经移除相关签名)
                     currentRptPageRst.items.forEach((pageItem, pageIdx) => {
                         const dtlSignCells = [];
                         signCells.push(dtlSignCells);
+                        const dtlTxtSignCells = [];
+                        txtSignCells.push(dtlTxtSignCells);
                         for (let sCellIdx = pageItem.signature_cells.length - 1; sCellIdx >= 0; sCellIdx--) {
                             let sCell = pageItem.signature_cells[sCellIdx];
                             if (sCell.signature_name.indexOf('dummy_pic') < 0) {
                                 dtlSignCells.push(sCell);
                                 pageItem.signature_cells.splice(sCellIdx, 1);
-                            }
-                        }
-                    });
-                }
-                if (PAGE_SHOW.closeArchiveSignature) {
-                    // 如果有closeArchiveSignature标记,那么不显示文本文档(需要删除cells目录下的匹配cell,创建完后加回来)
-                    // closeArchiveSignature和isTextSignature不能在一起判断,是2个独立事件!!!
-                    currentRptPageRst.items.forEach((pageItem, pageIdx) => {
-                        const dtlTxtSignCells = [];
-                        txtSignCells.push(dtlTxtSignCells);
-                        for (let sCellIdx = pageItem.signature_cells.length - 1; sCellIdx >= 0; sCellIdx--) {
-                            let sCell = pageItem.signature_cells[sCellIdx];
-                            if (sCell.signature_name.indexOf('dummy_pic') >= 0) {
+                            } else if (PAGE_SHOW.closeArchiveSignature) {
+                                // 如果还有closeArchiveSignature标记,那么不显示文本文档(需要删除cells目录下的匹配cell(Value不为空串))
                                 for (let cIdx = pageItem.cells.length - 1; cIdx >= 0; cIdx--) {
                                     const cCell = pageItem.cells[cIdx];
-                                    if (cCell.area.Left === sCell.orgArea.Left && cCell.area.Right === sCell.orgArea.Right && cCell.area.Top === sCell.orgArea.Top && cCell.area.Bottom === sCell.orgArea.Bottom) {
+                                    if (cCell.area.Left === sCell.orgArea.Left && cCell.area.Right === sCell.orgArea.Right && 
+                                        cCell.area.Top === sCell.orgArea.Top && cCell.area.Bottom === sCell.orgArea.Bottom &&
+                                        cCell.Value !== '') {
                                         dtlTxtSignCells.push(cCell);
                                         pageItem.cells.splice(cIdx, 1);
                                         break;
@@ -663,27 +667,54 @@ let rptArchiveObj = {
                             }
                         }
                     });
+                } else if (PAGE_SHOW.closeArchiveSignature) {
+                    // 这里还有一个场景需要考虑:签名是图片且选择了签名,又不归档输出,
+                    const rrSigns = [];
+                    ROLE_REL_LIST.forEach(role_rel => {
+                        if (role_rel.sign_output && role_rel.sign_output.includes(NORMAL_SIGN_STR)) {
+                            rrSigns.push(role_rel.signature_name);
+                        }
+                    });
+                    if (rrSigns.length > 0) {
+                        currentRptPageRst.items.forEach((pageItem, pageIdx) => {
+                            const dtlSignCells = [];
+                            const dtlDummyCells = [];
+                            signCells.push(dtlSignCells);
+                            dummyTxtSignCells.push(dtlDummyCells);
+                            for (let sCellIdx = pageItem.signature_cells.length - 1; sCellIdx >= 0; sCellIdx--) {
+                                let sCell = pageItem.signature_cells[sCellIdx];
+                                if (rrSigns.includes(sCell.signature_name)) {
+                                    dtlSignCells.push(sCell);
+                                    pageItem.signature_cells.splice(sCellIdx, 1);
+                                    // 还得加一个dummy cell,处理边框用的
+                                    const newCell = {
+                                        font: 'Footer',
+                                        control: sCell.control,
+                                        style: sCell.style,
+                                        Value: '',
+                                        area: { Left: sCell.area.Left, Right: sCell.area.Right, Top: sCell.area.Top, Bottom: sCell.area.Bottom },
+                                    };
+                                    dtlDummyCells.push(newCell);
+                                    pageItem.cells.push(newCell);
+                                }
+                            }
+                        });
+                    }
                 }
                 let doc = JpcJsPDFHelper._createPdf(currentRptPageRst, rptControlObj.getCurrentPageSize(), ROLE_REL_LIST, STAGE_AUDIT);
-                if (PAGE_SHOW.isTextSignature) {
+                restoreCells(signCells, 'signature_cells');
+                signCells = null;
+                restoreCells(txtSignCells, 'cells');
+                txtSignCells = null;
+                if (dummyTxtSignCells.length === currentRptPageRst.items.length) {
                     currentRptPageRst.items.forEach((pageItem, pageIdx) => {
-                        signCells[pageIdx].forEach((signCell) => {
-                            pageItem.signature_cells.push(signCell);
+                        dummyTxtSignCells[pageIdx].forEach((dummyCell) => {
+                            const idx = pageItem.cells.indexOf(dummyCell);
+                            if (idx >= 0) pageItem.cells.splice(idx, 1);
                         });
-                        signCells[pageIdx] = null;
-                    });
-                    signCells = null;
-                }
-                if (PAGE_SHOW.closeArchiveSignature) {
-                    currentRptPageRst.items.forEach((pageItem, pageIdx) => {
-                        if (txtSignCells[pageIdx]) {
-                            txtSignCells[pageIdx].forEach((txtCell) => {
-                                pageItem.cells.push(txtCell);
-                            });
-                            txtSignCells[pageIdx] = null;
-                        }
+                        dummyTxtSignCells[pageIdx] = null;
                     });
-                    txtSignCells = null;
+                    dummyTxtSignCells = null;
                 }
                 let pageEncryptInfo = rptArchiveObj._getPageSignatureInfo(currentRptPageRst, currentNode.refId);
                 // console.log(pageEncryptInfo);
@@ -703,8 +734,6 @@ let rptArchiveObj = {
                         archiveUrl = `/tender/report_api/addParentChildrenArchive/${PROJECT_ID}/${current_stage_id}/${currentNode.refId}/${JSON.stringify(currentRptPageRst.splitArcPages)};${JSON.stringify(currentRptPageRst.splitArcPagesInfo)};${currentRptPageRst.items.length}`;
                     }
                     postDataWithFile(archiveUrl, formData, function (result) {
-                    // postDataWithFile('/tender/report_api/addArchive/' + PROJECT_ID + '/' + current_stage_id + '/' + currentNode.refId, formData, function (result) {
-                    // postDataWithFile('/tender/report_api/addParentChildrenArchive/' + PROJECT_ID + '/' + current_stage_id + '/' + currentNode.refId, formData, function (result) { // 测试
                         // 成功后,更新当前页面
                         //*
                         if (result.updatedRst) {