|
@@ -0,0 +1,231 @@
|
|
|
+<!DOCTYPE html>
|
|
|
+<html lang="en">
|
|
|
+<head>
|
|
|
+ <meta charset="UTF-8">
|
|
|
+ <title></title>
|
|
|
+ <script src="/public/js/jquery/jquery-3.2.1.min.js"></script>
|
|
|
+ <script type="text/javascript" src="/public/jspdf/jspdf.min.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/jpc_output.js"></script>
|
|
|
+ <script type="text/javascript" src="/public/js/string_util_light.js"></script>
|
|
|
+ <script type="text/javascript" src="/public/report/js/rpt_signature.js"></script>
|
|
|
+ <script type="text/javascript" src="/public/report/js/rpt_jspdf.js"></script>
|
|
|
+ <!--
|
|
|
+ <link rel="stylesheet" href="/public/css/bootstrap/bootstrap.min.css">
|
|
|
+ -->
|
|
|
+
|
|
|
+ <link rel="shortcut icon" href="/public/images/favicon.ico">
|
|
|
+</head>
|
|
|
+<style type="text/css">
|
|
|
+</style>
|
|
|
+<body onload="pageLoading()">
|
|
|
+<div class="panel-body" id="print_preview_div" style="display:block">
|
|
|
+ <button class="btn btn-outline-primary btn-sm" type="button" onclick="exportPDF()">
|
|
|
+ <i class="fa fa-print"></i>
|
|
|
+ 导出 <span id="checkCountPrint" class="badge badge-primary"></span>
|
|
|
+ </button>
|
|
|
+ <div class="pageContainer">
|
|
|
+ <canvas id="rptIndividualCanvas" height="100%" width="100%"></canvas>
|
|
|
+ </div>
|
|
|
+</div>
|
|
|
+</body>
|
|
|
+<SCRIPT type="text/javascript">
|
|
|
+ const SCREEN_DPI = [96, 96];
|
|
|
+ const WAIT_TIME_EXPORT = 300000;
|
|
|
+ const current_stage_status = 3;
|
|
|
+ const PAGE_SHOW = {closeWatermark: 0, closeExportPdf: 0, closeExportExcel: 0, showArchive: 0};
|
|
|
+ const pdfFont = {'SmartSimsun': [], 'simhei': [], 'simkai': []};
|
|
|
+ let CUST_CFG = null;
|
|
|
+ let currentPageRst = null;
|
|
|
+ let currentDownloadUrl = null;
|
|
|
+ let currentDownloadIdx = 0;
|
|
|
+
|
|
|
+ dynamicLoadJs('/public/jspdf/Arial Narrow-normal.js');
|
|
|
+ dynamicLoadJs('/public/jspdf/Arial Narrow-bold.js');
|
|
|
+ dynamicLoadJs('/public/jspdf/Arial Narrow-italic.js');
|
|
|
+ dynamicLoadJs('/public/jspdf/Arial Narrow-bolditalic.js');
|
|
|
+
|
|
|
+ function pageLoading() {
|
|
|
+ let req_params = JSON.parse(sessionStorage.req_params);
|
|
|
+ let params = {};
|
|
|
+ params.pageSize = 'A4';
|
|
|
+ // params.rpt_tpl_id = req_params.refId;
|
|
|
+ params.rpt_tpl_id = 1784;
|
|
|
+ params.project_id = req_params.project_id;
|
|
|
+ params.tender_id = req_params.tender_id;
|
|
|
+ params.stage_id = req_params.stage_id;
|
|
|
+ params.stage_status = 3;
|
|
|
+ params.closeWatermark = 1;
|
|
|
+ params.custCfg = req_params.custCfg;
|
|
|
+ CUST_CFG = req_params.custCfg;
|
|
|
+
|
|
|
+ CommonAjax.postXsrfEx("/tender/report_api/getReport", params, 300000, true, getCookie('csrfToken_j'),
|
|
|
+ function(result){
|
|
|
+ currentPageRst = result.data;
|
|
|
+ _replaceKeyValue(currentPageRst);
|
|
|
+ _addQRCode(currentPageRst, '/public/upload/qr_code/icon-qrcode.png');
|
|
|
+ let canvas = document.getElementById("rptIndividualCanvas");
|
|
|
+
|
|
|
+ if (currentPageRst && currentPageRst.items && currentPageRst.items.length > 0) {
|
|
|
+ let size = JpcCanvasOutput.getReportSizeInPixel(currentPageRst, SCREEN_DPI);
|
|
|
+ canvas.width = size[0] + 20;
|
|
|
+ if (size[1] > size[0]) {
|
|
|
+ canvas.height = size[1] + 100;
|
|
|
+ } else {
|
|
|
+ canvas.height = size[1] + 50;
|
|
|
+ }
|
|
|
+ JpcCanvasOutput.cleanCanvas(canvas);
|
|
|
+ JpcCanvasOutput.drawPageBorder(currentPageRst, canvas, SCREEN_DPI);
|
|
|
+ JpcCanvasOutput.drawToCanvas(currentPageRst, canvas, 1);
|
|
|
+ } else {
|
|
|
+ //返回了无数据表
|
|
|
+ JpcCanvasOutput.cleanCanvas(canvas);
|
|
|
+ JpcCanvasOutput.drawPageBorder(currentPageRst, canvas, SCREEN_DPI);
|
|
|
+ }
|
|
|
+ }, function(err){
|
|
|
+ console.log(err);
|
|
|
+ }, function(ex){
|
|
|
+ console.log(ex);
|
|
|
+ }
|
|
|
+ );
|
|
|
+ }
|
|
|
+
|
|
|
+ function _replaceKeyValue(pageRst) {
|
|
|
+ if (sessionStorage.replace_key_params) {
|
|
|
+ let replace_key_params = JSON.parse(sessionStorage.replace_key_params);
|
|
|
+ if (pageRst && pageRst.length > 0) {
|
|
|
+ for (let pageItem of pageRst) {
|
|
|
+ for (let cell of pageItem.cells) {
|
|
|
+ for (let keyP of replace_key_params) {
|
|
|
+ if (cell.Value === keyP.key) {
|
|
|
+ cell.Value = keyP.Value;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ function _addQRCode(pageRst, qrCodePath) {
|
|
|
+ if (pageRst && pageRst.items && pageRst.items.length > 0) {
|
|
|
+ for (pageItem of pageRst.items) {
|
|
|
+ let maxRight = 0, minTop = 10000;
|
|
|
+ for (let cell of pageItem.cells) {
|
|
|
+ maxRight = (cell.area.Right > maxRight) ? cell.area.Right : maxRight;
|
|
|
+ minTop = (cell.area.Top < minTop) ? cell.area.Top : minTop;
|
|
|
+ }
|
|
|
+ let offset = pageRst.MergeBand.Top - minTop - 5;
|
|
|
+ let left = maxRight - offset;
|
|
|
+ let bottom = minTop + offset;
|
|
|
+ let signCell = {area: {Left: left, Right: maxRight, Top: minTop, Bottom: bottom}, control: 'Column', path: qrCodePath, pic: null, signature_name: 'dummy_pic', style: 'Default_Normal'};
|
|
|
+ pageItem.signature_cells.push(signCell);
|
|
|
+ //注:这里不用async方式,只有一个二维图,一瞬间就能下载完
|
|
|
+ _getBlob(qrCodePath).then(blob => {
|
|
|
+ // saveAs(blob, filename);
|
|
|
+ let oFileReader = new FileReader();
|
|
|
+ oFileReader.onloadend = function (e) {
|
|
|
+ let base64 = e.target.result;
|
|
|
+ // console.log("方式一》》》》》》》》》", base64)
|
|
|
+ signCell.pic = base64;
|
|
|
+ };
|
|
|
+ oFileReader.readAsDataURL(blob);
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ function exportExcel() {
|
|
|
+ //导出EXCEL(excel方式在处理二维码时会有问题,不合适,放弃)
|
|
|
+ if (currentPageRst) {
|
|
|
+ let params = {};
|
|
|
+ params.rptNames = ['奉建项目现场收方单'];
|
|
|
+ params.pageData = [currentPageRst];
|
|
|
+ CommonAjax.postXsrfEx("/tender/report_api/getDirectReport", params, WAIT_TIME_EXPORT, true, getCookie('csrfToken_j'), function(result){
|
|
|
+ if (result) {
|
|
|
+ let uuIdUrls = [];
|
|
|
+ for (let uuIdObj of result.data) {
|
|
|
+ let uuIdUrl = "/getFileByUUID/" + uuIdObj.uuid + "/" + stringUtil.replaceAll(uuIdObj.reportName, "#", "_") + "/xlsx";
|
|
|
+ uuIdUrls.push(uuIdUrl);
|
|
|
+ }
|
|
|
+ downloadReport(uuIdUrls);
|
|
|
+ } else {
|
|
|
+ //
|
|
|
+ }
|
|
|
+ },
|
|
|
+ function(failRst){
|
|
|
+ console.log(failRst);
|
|
|
+ },
|
|
|
+ function(exceptionRst){
|
|
|
+ console.log(exceptionRst);
|
|
|
+ }
|
|
|
+ );
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ function exportPDF() {
|
|
|
+ //导出PDF
|
|
|
+ if (currentPageRst) {
|
|
|
+ dynamicLoadJs('https://d2.smartcost.com.cn/cach/SmartSimsun-normal.js', 'normal', _getPdfFontCallback);
|
|
|
+ dynamicLoadJs('https://d2.smartcost.com.cn/cach/SmartSimsun-bold.js', 'bold', _getPdfFontCallback);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ function dynamicLoadJs(url, type, callback) {
|
|
|
+ let head = document.getElementsByTagName('head')[0];
|
|
|
+ let script = document.createElement('script');
|
|
|
+ script.type = 'text/javascript';
|
|
|
+ script.src = url;
|
|
|
+ if (callback) {
|
|
|
+ script.onload = script.onreadystatechange = function (event) {
|
|
|
+ callback(type);
|
|
|
+ script.onload = script.onreadystatechange = null;
|
|
|
+ };
|
|
|
+ }
|
|
|
+ head.appendChild(script);
|
|
|
+ }
|
|
|
+
|
|
|
+ function _getPdfFontCallback(fontProperty) {
|
|
|
+ if (pdfFont['SmartSimsun'].indexOf(fontProperty) < 0) {
|
|
|
+ pdfFont['SmartSimsun'].push(fontProperty);
|
|
|
+ }
|
|
|
+ if (pdfFont['SmartSimsun'].length === 2) {
|
|
|
+ JpcJsPDFHelper.outputAsPdf(currentPageRst, 'A4', '奉建项目现场收方单', null, null);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ function downloadReport(urls) {
|
|
|
+ //考虑到多个报表下载,一些浏览器(如chrome)不允许一下子下载多个文件,得缓缓处理,统一在这处理
|
|
|
+ currentDownloadUrl = null;
|
|
|
+ currentDownloadIdx = 0;
|
|
|
+ const private_download = function() {
|
|
|
+ if (currentDownloadIdx >= 0 && currentDownloadIdx < urls.length) {
|
|
|
+ currentDownloadUrl = urls[currentDownloadIdx];
|
|
|
+ currentDownloadIdx++;
|
|
|
+ window.location = currentDownloadUrl;
|
|
|
+ if (currentDownloadIdx < urls.length) setTimeout(private_download, 2000);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ private_download();
|
|
|
+ }
|
|
|
+
|
|
|
+ function _getBlob(url) {
|
|
|
+ return new Promise(resolve => {
|
|
|
+ const xhr = new XMLHttpRequest();
|
|
|
+
|
|
|
+ xhr.open('GET', url, true);
|
|
|
+ xhr.responseType = 'blob';
|
|
|
+ xhr.onload = () => {
|
|
|
+ if (xhr.status === 200) {
|
|
|
+ resolve(xhr.response);
|
|
|
+ }
|
|
|
+ };
|
|
|
+
|
|
|
+ xhr.send();
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+</SCRIPT>
|
|
|
+</html>
|