|
@@ -1000,23 +1000,33 @@ function downloadPDFReport(pageDataArr, pageSize, rpt_names, signatureRelArr, si
|
|
|
/*/
|
|
|
|
|
|
// 导出PDF真实优化代码
|
|
|
- let dummyPicAmt = 0, dummyCells = [];
|
|
|
+ let pidPaths = [], dummyPicAmt = 0, dummyCells = [], dupPicPath = [], dupPicCell = [];
|
|
|
// 1. 先找有没有dummy
|
|
|
for (let pageData of pageDataArr) {
|
|
|
for (let page of pageData.items) {
|
|
|
for (let dCell of page.signature_cells) {
|
|
|
if (dCell.signature_name === 'dummy_pic') {
|
|
|
- dummyCells.push(dCell);
|
|
|
- dummyPicAmt++;
|
|
|
+ let picIdx = pidPaths.indexOf(dCell.path);
|
|
|
+ if (picIdx < 0) {
|
|
|
+ pidPaths.push(dCell.path);
|
|
|
+ dummyCells.push(dCell);
|
|
|
+ dummyPicAmt++;
|
|
|
+ } else {
|
|
|
+ let dPicIdx = dupPicPath.indexOf(dCell.path);
|
|
|
+ if (dPicIdx < 0) {
|
|
|
+ dupPicPath.push(dCell.path);
|
|
|
+ dupPicCell.push([]);
|
|
|
+ dPicIdx = dupPicPath.length - 1;
|
|
|
+ }
|
|
|
+ dupPicCell[dPicIdx].push(dCell);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
if (dummyPicAmt > 0) {
|
|
|
- // console.log(`dummyPicAmt: ${dummyPicAmt}`);
|
|
|
- // console.log(`dummyCells.length: ${dummyCells.length}`);
|
|
|
// 2. 有则一个个请求下载图片,下载完后统一导出PDF
|
|
|
- // $.bootstrapLoading.start();
|
|
|
+ $.bootstrapLoading.start();
|
|
|
let handledAmt = 0, exceptionAmt = 0;
|
|
|
for (let pIdx = 0; pIdx < dummyCells.length; pIdx++) {
|
|
|
let dCell = dummyCells[pIdx];
|
|
@@ -1025,8 +1035,12 @@ function downloadPDFReport(pageDataArr, pageSize, rpt_names, signatureRelArr, si
|
|
|
if (blob === 'not found!') {
|
|
|
exceptionAmt++;
|
|
|
// console.log(`已出错草图: ${exceptionAmt}`);
|
|
|
+ // let pPathIdx = dupPicPath.indexOf(dCell.path);
|
|
|
+ // if (pPathIdx >= 0) {
|
|
|
+ // console.log(`dupPicCell[pPathIdx].length: ${dupPicCell[pPathIdx].length}`);
|
|
|
+ // }
|
|
|
if ((handledAmt + exceptionAmt) === dummyPicAmt) {
|
|
|
- // $.bootstrapLoading.end();
|
|
|
+ $.bootstrapLoading.end();
|
|
|
private_download(pageDataArr, rpt_names);
|
|
|
}
|
|
|
} else {
|
|
@@ -1035,9 +1049,15 @@ function downloadPDFReport(pageDataArr, pageSize, rpt_names, signatureRelArr, si
|
|
|
let base64 = e.target.result;
|
|
|
dCell.pic = base64;
|
|
|
handledAmt++;
|
|
|
+ let pPathIdx = dupPicPath.indexOf(dCell.path);
|
|
|
+ if (pPathIdx >= 0) {
|
|
|
+ for (let dupCell of dupPicCell[pPathIdx]) {
|
|
|
+ dupCell.pic = base64;
|
|
|
+ }
|
|
|
+ }
|
|
|
// console.log(`已处理草图: ${handledAmt}`);
|
|
|
if ((handledAmt + exceptionAmt) === dummyPicAmt) {
|
|
|
- // $.bootstrapLoading.end();
|
|
|
+ $.bootstrapLoading.end();
|
|
|
private_download(pageDataArr, rpt_names);
|
|
|
}
|
|
|
};
|