123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361 |
- <script type="text/javascript" src="/public/jspdf/jspdf.min.js"></script>
- <script type="text/javascript" src="/public/report/js/rpt_public.js"></script>
- <script type="text/javascript" src="/public/js/common_ajax.js"></script>
- <script type="text/javascript" src="/public/report/js/jpc_output_value_define.js"></script>
- <script type="text/javascript" src="/public/report/js/rpt_signature.js"></script>
- <script type="text/javascript" src="/public/report/js/jpc_output.js"></script>
- <script type="text/javascript" src="/public/report/js/rpt_move_signature.js"></script>
- <script type="text/javascript" src="/public/report/js/rpt_jspdf.js"></script>
- <div class="panel-content">
- <div class="panel-title fluid">
- <div class="title-main d-flex justify-content-between">
- <div><a class="mr-2" href="/payment/<%- ctx.tender.id %>/list/<%- trInfo.id %>"><i class="fa fa-chevron-left"></i> 返回</a><%- ctx.tender.name %> / <%- trInfo.rpt_name %> / <%- ctx.detail.code %></div>
- <div>
- <% if ((ctx.detail.status == auditConst.status.uncheck || ctx.detail.status == auditConst.status.checkNo) && trInfo.is_change) { %>
- <span class="text-danger pull-right">报表内容已发生变化,请删除并重新生成详情</span>
- <% } else { %>
- <% include ./audit_btn.ejs %>
- <% if (rptAudit &&
- ((ctx.detail.status !== auditConst.status.checkNo && ctx.detail.status !== auditConst.status.checked) ||
- (ctx.detail.status === auditConst.status.checked && !nextDetail) ||
- (ctx.detail.status === auditConst.status.checkNo && ctx.detail.uid === ctx.session.sessionUser.accountId))
- ) { %>
- <a href="#sub-sp5" data-toggle="modal" data-target="#sub-sp5" class="btn btn-sm btn-primary pull-right mr-2">签字意见</a>
- <% } %>
- <a href="#sign-flow" data-toggle="modal" data-target="#sign-flow" class="btn btn-sm btn-outline-success pull-right mr-2">签署进度</a>
- <% } %>
- </div>
- </div>
- </div>
- <div class="content-wrap">
- <div class="c-body">
- <div class="sjs-height-0">
- <div class="row m-0 mt-3">
- <div id="rpt-form" class="col-5 mr-3">
- <% for (const c of content) { %>
- <div>
- <h5><%- c.title %>内容</h5>
- <% for (const item of c.items) { %>
- <div class="form-group">
- <label><%- item.label %></label>
- <% if (item.type === 'textarea') { %>
- <textarea <% if (ctx.detail.readOnly) { %>readonly<% } %> class="form-control form-control-sm" data-index="<%- item.index %>"><%- item.value %></textarea>
- <% } else { %>
- <input <% if (ctx.detail.readOnly) { %>readonly<% } %> type="<%- item.type %>" value="<%- item.type === 'number' && ctx.helper._.indexOf(item.value, '元') !== -1 ? parseFloat(item.value) : item.value %>" data-index="<%- item.index %>" class="form-control form-control-sm" placeholder="请输入">
- <% } %>
- </div>
- <% } %>
- </div>
- <% } %>
- </div>
- <div class="col-6 ml-5">
- <div class="d-flex flex-row">
- <a href="javascript: void(0);" onclick="auditRptPrintHelper.showPage()" class="mr-2" >刷新</a>
- <a href="javascript: void(0);" class="mr-2" onclick="auditRptPrintHelper.directPDF()">导出pdf</a>
- <a href="javascript: void(0);" onclick="auditRptPrintHelper.directPrint()">打印</a>
- </div>
- <div align="center">
- <canvas id="auditRptCanvas" height="1200" width="920"></canvas>
- </div>
- </div>
- </div>
- </div>
- </div>
- </div>
- </div>
- <script type="text/javascript">
- const tenderId = parseInt('<%- ctx.tender.id %>');
- const detailId = parseInt('<%- ctx.detail.id %>');
- const rptAudit = JSON.parse(unescape('<%- escape(JSON.stringify(rptAudit)) %>'));
- <% if (rptAudit &&
- ((ctx.detail.status !== auditConst.status.checkNo && ctx.detail.status !== auditConst.status.checked) ||
- (ctx.detail.status === auditConst.status.checked && !nextDetail) ||
- (ctx.detail.status === auditConst.status.checkNo && ctx.detail.uid === ctx.session.sessionUser.accountId))
- ) { %>
- let currentStamp = JSON.parse(unescape('<%- escape(JSON.stringify(currentStamp)) %>'));
- <% } %>
- let tesRpttData = JSON.parse(unescape('<%- escape(JSON.stringify(report_json)) %>'));
- console.log(tesRpttData);
- const SCREEN_DPI = [];
- const PAGE_SHOW = {closeWaterMark: 1};
- const current_stage_status = -1;
- const VIEW_CANVAS = document.getElementById("auditRptCanvas");
- const OSS_PATH = '<%- OSS_PATH %>';
- const CUST_CFG = {
- "fonts": [
- {
- "ID": "ReportTitle_Main",
- "Name": "宋体",
- "FontBold": "T",
- "FontHeight": 32,
- "FontItalic": "F",
- "CfgDispName": "表标题",
- "FontUnderline": "F"
- },
- {
- "ID": "Column",
- "Name": "宋体",
- "FontBold": "F",
- "FontHeight": 12,
- "FontItalic": "F",
- "CfgDispName": "列标题",
- "FontUnderline": "F"
- },
- {
- "ID": "Content",
- "Name": "宋体",
- "FontBold": "F",
- "FontHeight": 12,
- "FontItalic": "F",
- "CfgDispName": "正文内容",
- "FontUnderline": "F"
- },
- {
- "ID": "Total",
- "Name": "宋体",
- "FontBold": "F",
- "FontHeight": 12,
- "FontItalic": "F",
- "CfgDispName": "合计",
- "FontUnderline": "F"
- },
- {
- "ID": "Header",
- "Name": "宋体",
- "FontBold": "F",
- "FontHeight": 12,
- "FontItalic": "F",
- "CfgDispName": "表眉/表脚",
- "FontUnderline": "F"
- }
- ],
- "margins": {
- "Top": 12,
- "Left": 15,
- "Right": 15,
- "Bottom": 15
- },
- "fillZero": false,
- "isNarrow": false,
- "borderThick": 2,
- "showVerticalLine": true,
- "closeWarterMark": false,
- "continuousOutput": true
- }
- let zTreeOprObj = {
- _chkPrePayStatus: function() {
- return -1;
- }
- };
- let rptTplObj = {
- pdfFont: {'SmartSimsun': [], 'simhei': [], 'simkai': []},
- isLoading: false,
- };
- let auditRptPrintHelper = {
- currentPageData: null,
- currentDownloadIdx: 0,
- chkPicFeatures: async function(pageData) {
- for (let page of pageData.items) {
- for (let signCell of page.signature_cells) {
- if (typeof signCell.path === 'string' && signCell.path.length > 10) {
- let paths = signCell.path.split('!;!');
- signCell.picFeatures = [];
- if (!signCell.orgArea) {
- signCell.orgArea = JSON.parse(JSON.stringify(signCell.area));
- }
- signCell.signType = 'mixed';
- for (let path of paths) {
- let imgSrc = path;
- if (path.indexOf(OSS_PATH) < 0 && path[0] !== '/') {
- imgSrc = OSS_PATH + path;
- }
- const picFeature = await getPicFeature(imgSrc);
- signCell.picFeatures.push(picFeature);
- }
- }
- }
- }
- },
- showPage: async function() {
- await auditRptPrintHelper.chkPicFeatures(tesRpttData);
- JpcCanvasOutput.cleanCanvas(VIEW_CANVAS);
- JpcCanvasOutput.drawPageBorder(tesRpttData, VIEW_CANVAS, getScreenDPI());
- JpcCanvasOutput.drawToCanvas(tesRpttData, VIEW_CANVAS, 1, false, true);
- },
- directPrint: function() {
- sessionStorage.report_direct_data = JSON.stringify(tesRpttData);
- sessionStorage.closeWaterMark = 1;
- sessionStorage.pageSize = 'A4';
- sessionStorage.OSS_PATH = OSS_PATH;
- window.open('/printReport/A4');
- },
- _getPdfFontCallback: function(fontProperty) {
- let me = auditRptPrintHelper;
- if (rptTplObj.pdfFont['SmartSimsun'].indexOf(fontProperty) < 0) {
- rptTplObj.pdfFont['SmartSimsun'].push(fontProperty);
- }
- if (rptTplObj.pdfFont['SmartSimsun'].length >= 2) {
- $.bootstrapLoading.end();
- downloadPDFReport([tesRpttData], 'A4', [tesRpttData['打印页面_信息']['报表名称']], [], [], [-1], []);
- }
- },
- directPDF: function() {
- if (rptTplObj.pdfFont['SmartSimsun'].length >= 2) {
- downloadPDFReport([tesRpttData], 'A4', [tesRpttData['打印页面_信息']['报表名称']], [], [], [-1], []);
- } else {
- dynamicLoadJs('https://d2.smartcost.com.cn/cach/SmartSimsun-normal2.js', 'normal', this._getPdfFontCallback);
- dynamicLoadJs('https://d2.smartcost.com.cn/cach/SmartSimsun-bold.js', 'bold', this._getPdfFontCallback);
- }
- },
- };
- // $(document).ready(() => {
- // autoFlashHeight();
- // auditRptPrintHelper.showPage();
- // iniPage();
- // });
- function _getAdhocDummyCells(srcCell, rstCells, controls = null) {
- if (typeof srcCell.path === 'string') {
- let paths = srcCell.path.split('!;!');
- for (let dtlPathIdx = 0; dtlPathIdx < paths.length; dtlPathIdx++) {
- dtlPath = paths[dtlPathIdx];
- // srcCell.picFeatures
- if (dtlPath.length > 10) {
- let imgSrc = dtlPath;
- if (dtlPath.indexOf(OSS_PATH) < 0 && dtlPath[0] !== '/') {
- imgSrc = OSS_PATH + dtlPath;
- }
- let couldCreate = true;
- if (srcCell.picFeatures && srcCell.picFeatures.length === paths.length && (srcCell.picFeatures[dtlPathIdx] === 'not found!')) {
- couldCreate = false;
- }
- if (couldCreate) {
- let area = srcCell.area;
- if ((dtlPathIdx === 0) && (srcCell.orgArea)) {
- area = JSON.parse(JSON.stringify(srcCell.orgArea));
- let control = srcCell[JV.PROP_CONTROL];
- if (typeof srcCell[JV.PROP_CONTROL] === "string") {
- control = controls[srcCell[JV.PROP_CONTROL]];
- }
- let tmpArea = srcCell.area;
- srcCell.area = area;
- srcCell.isOrgShow = (dtlPathIdx === 0);
- let signArea = getProperSignatureArea(srcCell, control, 0, 0, JV);
- srcCell.area = tmpArea;
- area[JV.PROP_LEFT] = signArea[0];
- area[JV.PROP_TOP] = signArea[1];
- area[JV.PROP_RIGHT] = signArea[2];
- area[JV.PROP_BOTTOM] = signArea[3];
- }
- const newStampCell = {
- signature_name: 'dummy_pic',
- control: srcCell.control,
- // style: srcCell.style,
- style: (srcCell.style && srcCell.style !== '') ? srcCell.style : 'sign_pic' ,
- path: imgSrc,
- isStamp: true,
- area,
- isOrgShow: (dtlPathIdx === 0),
- };
- rstCells.push(newStampCell);
- }
- }
- }
- }
- }
- function downloadPDFReport(pageDataArr, pageSize, rpt_names, signatureRelArr, signatureRelInfo, refRptTplIds, STAGE_AUDIT) {
- auditRptPrintHelper.currentDownloadIdx = 0;
- const private_download = function(newPageDataArr, new_rpt_names, dummyCells) {
- if (auditRptPrintHelper.currentDownloadIdx < newPageDataArr.length) {
- let singleSignatureRelArr = [];
- for (let rIdx = 0; rIdx < signatureRelInfo.length; rIdx++) {
- let rptId = refRptTplIds[auditRptPrintHelper.currentDownloadIdx];
- if (signatureRelInfo[rIdx].rpt_id === rptId) {
- singleSignatureRelArr = signatureRelArr[rIdx]; // 有些报表可能没有签名
- break;
- }
- }
- let pageData = newPageDataArr[auditRptPrintHelper.currentDownloadIdx];
- let rptName = new_rpt_names[auditRptPrintHelper.currentDownloadIdx];
- auditRptPrintHelper.currentDownloadIdx++;
- JpcJsPDFHelper.outputAsPdf(pageData, pageSize, rptName, singleSignatureRelArr, STAGE_AUDIT); // 精确控制签名
- if (auditRptPrintHelper.currentDownloadIdx < newPageDataArr.length) {
- setTimeout(private_download(newPageDataArr, new_rpt_names), 2000);
- } else {
- for (let pd of newPageDataArr) {
- for (let pItem of pd.items) {
- for (let idx = pItem.signature_cells.length - 1; idx >= 0; idx--) {
- let pIdx = dummyCells.indexOf(pItem.signature_cells[idx]);
- if (pIdx >= 0) {
- pItem.signature_cells.splice(idx, 1);
- dummyCells.splice(pIdx, 1);
- }
- }
- }
- }
- }
- }
- };
- // 导出PDF审核优化代码
- let picPaths = [], dummyPicAmt = 0, dummyCells = [];
- // 1. 先找有没有dummy
- for (let pageData of pageDataArr) {
- let tmpDummyCells = [];
- let controls = pageData[JV.NODE_CONTROL_COLLECTION];
- for (let page of pageData.items) {
- for (let dCell of page.signature_cells) {
- _getAdhocDummyCells(dCell, tmpDummyCells, controls);
- }
- if (tmpDummyCells.length > 0) {
- page.signature_cells = page.signature_cells.concat(tmpDummyCells);
- dummyCells = dummyCells.concat(tmpDummyCells);
- }
- }
- }
- dummyPicAmt = dummyCells.length;
- if (dummyPicAmt > 0) {
- // 2. 有则一个个请求下载图片,下载完后统一导出PDF
- $.bootstrapLoading.start();
- let handledAmt = 0, exceptionAmt = 0;
- for (let pIdx = 0; pIdx < dummyCells.length; pIdx++) {
- let dCell = dummyCells[pIdx];
- getBlobPublic(dCell.path).then(blob => {
- if (blob === 'not found!') {
- exceptionAmt++;
- if ((handledAmt + exceptionAmt) === dummyPicAmt) {
- $.bootstrapLoading.end();
- private_download(pageDataArr, rpt_names, dummyCells);
- }
- } else {
- let oFileReader = new FileReader();
- oFileReader.onloadend = function (e) {
- let base64 = e.target.result;
- dCell.pic = base64;
- handledAmt++;
- if ((handledAmt + exceptionAmt) === dummyPicAmt) {
- $.bootstrapLoading.end();
- private_download(pageDataArr, rpt_names, dummyCells);
- }
- };
- oFileReader.readAsDataURL(blob);
- }
- });
- }
- } else {
- // 3. 无则普通导出
- private_download(pageDataArr, rpt_names);
- }
- //*/
- }
- </script>
|