|
@@ -6,6 +6,7 @@
|
|
// const JV = require('../rpt_component/jpc_value_define'); // JV对象默认已有
|
|
// const JV = require('../rpt_component/jpc_value_define'); // JV对象默认已有
|
|
// const JSZip = require('jszip'); // 已引用
|
|
// const JSZip = require('jszip'); // 已引用
|
|
// const strUtil = require('../public/stringUtil'); // stringUtil对象也有
|
|
// const strUtil = require('../public/stringUtil'); // stringUtil对象也有
|
|
|
|
+// STAGE_AUDIT, STAGE_LIST 已存在
|
|
const DPI = 96;
|
|
const DPI = 96;
|
|
const dftHeadXml = '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>';
|
|
const dftHeadXml = '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>';
|
|
const STD_COMP_STAMP_SIZE_WIDTH = Math.round(5 * 96 / 2.54); // 公章标准尺寸(宽4.2厘米)转成像素
|
|
const STD_COMP_STAMP_SIZE_WIDTH = Math.round(5 * 96 / 2.54); // 公章标准尺寸(宽4.2厘米)转成像素
|
|
@@ -1389,7 +1390,7 @@ function createDummySignatureCell(pageData) {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
-function _checkAndSetSignatureCache(pageData, signKeyArr, signPathArr, roleRel, signSheetIdxArr, isSinglePage) {
|
|
|
|
|
|
+function _checkAndSetSignatureCache(pageData, signKeyArr, signPathArr, roleRel, signSheetIdxArr, isSinglePage, checkAudit = false) {
|
|
// 备注:电子签名是以图形的方式处理,一页可以有多个签名,多页的签名基本是引用同样的图片,在这里先处理一下,后期统一引用。
|
|
// 备注:电子签名是以图形的方式处理,一页可以有多个签名,多页的签名基本是引用同样的图片,在这里先处理一下,后期统一引用。
|
|
// 另:以后的图片(在电子签名(signature_cells)以外的图片)会单独处理(如计算草图、水印等)
|
|
// 另:以后的图片(在电子签名(signature_cells)以外的图片)会单独处理(如计算草图、水印等)
|
|
let rst = false;
|
|
let rst = false;
|
|
@@ -1422,26 +1423,28 @@ function _checkAndSetSignatureCache(pageData, signKeyArr, signPathArr, roleRel,
|
|
for (const role of chkRoles) {
|
|
for (const role of chkRoles) {
|
|
if (signatureCell.signature_name === role.signature_name) {
|
|
if (signatureCell.signature_name === role.signature_name) {
|
|
if (!(role.signature_name.indexOf(JV.SIGNATURE_NAME_DUMMY) < 0 && role.sign_output.indexOf('normal_sign') < 0)) {
|
|
if (!(role.signature_name.indexOf(JV.SIGNATURE_NAME_DUMMY) < 0 && role.sign_output.indexOf('normal_sign') < 0)) {
|
|
- // 如果签名但用户并没有选择显示签名,则不输出!
|
|
|
|
- if (role.sign_pic) {
|
|
|
|
- const signPath = { signature_name: signatureCell.signature_name, path: null, pic: null };
|
|
|
|
- signPathArr.push(signPath);
|
|
|
|
- signPath.pic = role.sign_pic;
|
|
|
|
- signKeyArr.push(signatureCell.signature_name);
|
|
|
|
- rst = true;
|
|
|
|
- signSheetIdxArr[pageIdx] = true;
|
|
|
|
- } else if (role.sign_path) {
|
|
|
|
- let sPObj = _getDupPicPath(role.sign_path);
|
|
|
|
- if (sPObj !== null && isSinglePage) { // 只有在isSinglePage为true时,才需要优化签名
|
|
|
|
- signatureCell.signature_name = sPObj.signature_name; // 重点,如果有相同路径的,修改signature_name!
|
|
|
|
- rst = true;
|
|
|
|
- } else {
|
|
|
|
|
|
+ if (!checkAudit || role.signature_name.indexOf(JV.SIGNATURE_NAME_DUMMY) >= 0 || _chkIfAudit(role)) {
|
|
|
|
+ // 如果签名但用户并没有选择显示签名,则不输出!
|
|
|
|
+ if (role.sign_pic) {
|
|
const signPath = { signature_name: signatureCell.signature_name, path: null, pic: null };
|
|
const signPath = { signature_name: signatureCell.signature_name, path: null, pic: null };
|
|
signPathArr.push(signPath);
|
|
signPathArr.push(signPath);
|
|
- signPath.path = role.sign_path;
|
|
|
|
|
|
+ signPath.pic = role.sign_pic;
|
|
signKeyArr.push(signatureCell.signature_name);
|
|
signKeyArr.push(signatureCell.signature_name);
|
|
rst = true;
|
|
rst = true;
|
|
signSheetIdxArr[pageIdx] = true;
|
|
signSheetIdxArr[pageIdx] = true;
|
|
|
|
+ } else if (role.sign_path) {
|
|
|
|
+ let sPObj = _getDupPicPath(role.sign_path);
|
|
|
|
+ if (sPObj !== null && isSinglePage) { // 只有在isSinglePage为true时,才需要优化签名
|
|
|
|
+ signatureCell.signature_name = sPObj.signature_name; // 重点,如果有相同路径的,修改signature_name!
|
|
|
|
+ rst = true;
|
|
|
|
+ } else {
|
|
|
|
+ const signPath = { signature_name: signatureCell.signature_name, path: null, pic: null };
|
|
|
|
+ signPathArr.push(signPath);
|
|
|
|
+ signPath.path = role.sign_path;
|
|
|
|
+ signKeyArr.push(signatureCell.signature_name);
|
|
|
|
+ rst = true;
|
|
|
|
+ signSheetIdxArr[pageIdx] = true;
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -1473,8 +1476,39 @@ function _checkAndSetSignatureCache(pageData, signKeyArr, signPathArr, roleRel,
|
|
return rst;
|
|
return rst;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+function _chkIfAudit(role_rel) {
|
|
|
|
+ // STAGE_AUDIT, STAGE_LIST 已在index.ejs定义
|
|
|
|
+ let rst = false;
|
|
|
|
+ for (const stg_audit of STAGE_AUDIT) {
|
|
|
|
+ if (role_rel.acc_id === stg_audit.aid) {
|
|
|
|
+ if (stg_audit.status === 3) {
|
|
|
|
+ rst = true;
|
|
|
|
+ } else {
|
|
|
|
+ rst = false;
|
|
|
|
+ }
|
|
|
|
+ // break; //因为实际业务中会有反复,所以就不break了,一直判断,以最后一个为准
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if (!rst) {
|
|
|
|
+ // 还有原报需要检测
|
|
|
|
+ for (const stg_ort_rpt of STAGE_LIST) {
|
|
|
|
+ if (role_rel.acc_id === stg_ort_rpt.user_id) {
|
|
|
|
+ if (stg_ort_rpt.status !== 1 && stg_ort_rpt.status !== 4) {
|
|
|
|
+ // 只要不是待上报(1)、退回审批(4) 状态,都需要显示
|
|
|
|
+ rst = true;
|
|
|
|
+ } else {
|
|
|
|
+ rst = false;
|
|
|
|
+ }
|
|
|
|
+ // break; //因为实际业务中会有反复,所以就不break了,一直判断,以最后一个为准
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ // rst = true; //测试,未来将屏蔽
|
|
|
|
+ return rst;
|
|
|
|
+}
|
|
|
|
+
|
|
const excelExportUtil = {
|
|
const excelExportUtil = {
|
|
- exportExcel: async function(pageData, paperSize, fName, options, custSheetNames, custSheetMergeBands, roleRel, callback) {
|
|
|
|
|
|
+ exportExcel: async function(pageData, paperSize, fName, options, custSheetNames, custSheetMergeBands, roleRel, callback, checkAudit = false) {
|
|
const rptOptions = ({ singlePage: false, fileName: 'report' });
|
|
const rptOptions = ({ singlePage: false, fileName: 'report' });
|
|
if (options === 'true' || options === true) {
|
|
if (options === 'true' || options === true) {
|
|
rptOptions.singlePage = true;
|
|
rptOptions.singlePage = true;
|
|
@@ -1491,7 +1525,7 @@ const excelExportUtil = {
|
|
await rptSignatureHelper.resetDummySignature(pageData, thisRoleRel, true); // 把草图转换一下roleRel
|
|
await rptSignatureHelper.resetDummySignature(pageData, thisRoleRel, true); // 把草图转换一下roleRel
|
|
|
|
|
|
// const hasSignature = false; // 暂时不支持电子签名、草图导出excel
|
|
// const hasSignature = false; // 暂时不支持电子签名、草图导出excel
|
|
- const hasSignature = _checkAndSetSignatureCache(pageData, signKeyArr, signPathArr, thisRoleRel, signSheetIdxArr, isSinglePage); // 因草图的关系,thisRoleRel是否为null就不是充要的条件
|
|
|
|
|
|
+ const hasSignature = _checkAndSetSignatureCache(pageData, signKeyArr, signPathArr, thisRoleRel, signSheetIdxArr, isSinglePage, checkAudit); // 因草图的关系,thisRoleRel是否为null就不是充要的条件
|
|
if (!hasSignature) {
|
|
if (!hasSignature) {
|
|
createDummySignatureCell(pageData);
|
|
createDummySignatureCell(pageData);
|
|
}
|
|
}
|
|
@@ -1622,7 +1656,7 @@ const excelExportUtil = {
|
|
saveAs(content, `${fName}.xlsx`); // 页面需要引用 FileSaver.js 才有这个方法
|
|
saveAs(content, `${fName}.xlsx`); // 页面需要引用 FileSaver.js 才有这个方法
|
|
});
|
|
});
|
|
},
|
|
},
|
|
- exportExcelInOneBook: async function(pageDataArray, paperSize, fName, roleRelArr, callback) {
|
|
|
|
|
|
+ exportExcelInOneBook: async function(pageDataArray, paperSize, fName, roleRelArr, callback, checkAudit = false) {
|
|
const me = this;
|
|
const me = this;
|
|
const newPageData = {};
|
|
const newPageData = {};
|
|
// 1. 重新编排一下数据,把一份报表的pageData合并到一起作为一个Sheet输出(需要重新调整数据纵向坐标),多份报表数据就形成多个Sheet
|
|
// 1. 重新编排一下数据,把一份报表的pageData合并到一起作为一个Sheet输出(需要重新调整数据纵向坐标),多份报表数据就形成多个Sheet
|
|
@@ -1763,7 +1797,7 @@ const excelExportUtil = {
|
|
// 重新分配分页符结束------------------
|
|
// 重新分配分页符结束------------------
|
|
}
|
|
}
|
|
// 3. everything is ok, then call me
|
|
// 3. everything is ok, then call me
|
|
- await me.exportExcel(newPageData, paperSize, fName, 'false', sheetNames, custMergeBands, roleRelArr, callback);
|
|
|
|
|
|
+ await me.exportExcel(newPageData, paperSize, fName, 'false', sheetNames, custMergeBands, roleRelArr, callback, checkAudit);
|
|
} catch (e) {
|
|
} catch (e) {
|
|
console.log(e);
|
|
console.log(e);
|
|
}
|
|
}
|