|
@@ -755,7 +755,7 @@ let rptControlObj = {
|
|
|
const signatureRelArr = [];
|
|
|
if (refRptTplIds.length > 0) {
|
|
|
let params = rptControlObj.creatCommonExportParam(refRptTplIds);
|
|
|
- params.getPicFlag = true; //专门针对草图项,只有此项为true,才需要把草图信息带过来,预览及打印动态加载草图 // 纠结:但这样还是解决不了效率问题,得另外想交互方式
|
|
|
+ // params.getPicFlag = true; //专门针对草图项,只有此项为true,才需要把草图信息带过来,预览及打印动态加载草图 // 纠结:但这样还是解决不了效率问题,得另外想交互方式
|
|
|
await rptCustomObj.getCustomSelect(params);
|
|
|
delete params.orientation; // 打印时有勾选的话,不需要提供方向
|
|
|
$.bootstrapLoading.start();
|
|
@@ -998,7 +998,57 @@ function downloadPDFReport(pageDataArr, pageSize, rpt_names, signatureRelArr, si
|
|
|
let newPageDataRst = _resetPageDataByBreaks(10, newRptNames);
|
|
|
private_download(newPageDataRst, newRptNames);
|
|
|
/*/
|
|
|
- private_download(pageDataArr, rpt_names);
|
|
|
+
|
|
|
+ // 导出PDF真实优化代码
|
|
|
+ let dummyPicAmt = 0, dummyCells = [];
|
|
|
+ // 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++;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (dummyPicAmt > 0) {
|
|
|
+ // console.log(`dummyPicAmt: ${dummyPicAmt}`);
|
|
|
+ // console.log(`dummyCells.length: ${dummyCells.length}`);
|
|
|
+ // 2. 有则一个个请求下载图片,下载完后统一导出PDF
|
|
|
+ // $.bootstrapLoading.start();
|
|
|
+ let handledAmt = 0, exceptionAmt = 0;
|
|
|
+ for (let pIdx = 0; pIdx < dummyCells.length; pIdx++) {
|
|
|
+ let dCell = dummyCells[pIdx];
|
|
|
+ _getBlob(dCell.path).then(blob => {
|
|
|
+ // console.log(`pIdx: ${pIdx}`);
|
|
|
+ if (blob === 'not found!') {
|
|
|
+ exceptionAmt++;
|
|
|
+ // console.log(`已出错草图: ${exceptionAmt}`);
|
|
|
+ if ((handledAmt + exceptionAmt) === dummyPicAmt) {
|
|
|
+ // $.bootstrapLoading.end();
|
|
|
+ private_download(pageDataArr, rpt_names);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ let oFileReader = new FileReader();
|
|
|
+ oFileReader.onloadend = function (e) {
|
|
|
+ let base64 = e.target.result;
|
|
|
+ dCell.pic = base64;
|
|
|
+ handledAmt++;
|
|
|
+ // console.log(`已处理草图: ${handledAmt}`);
|
|
|
+ if ((handledAmt + exceptionAmt) === dummyPicAmt) {
|
|
|
+ // $.bootstrapLoading.end();
|
|
|
+ private_download(pageDataArr, rpt_names);
|
|
|
+ }
|
|
|
+ };
|
|
|
+ oFileReader.readAsDataURL(blob);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ // 3. 无则普通导出
|
|
|
+ private_download(pageDataArr, rpt_names);
|
|
|
+ }
|
|
|
//*/
|
|
|
}
|
|
|
|
|
@@ -1067,3 +1117,19 @@ function getExcelOutputOption() {
|
|
|
return 'normal'; // 目前是普通方式
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+function _getBlob(url) {
|
|
|
+ return new Promise((resolve, reject) => {
|
|
|
+ const xhr = new XMLHttpRequest();
|
|
|
+ xhr.open('GET', url, true);
|
|
|
+ xhr.responseType = 'blob';
|
|
|
+ xhr.onload = () => {
|
|
|
+ if (xhr.status === 200) {
|
|
|
+ resolve(xhr.response);
|
|
|
+ } else {
|
|
|
+ resolve('not found!');
|
|
|
+ }
|
|
|
+ };
|
|
|
+ xhr.send();
|
|
|
+ });
|
|
|
+}
|