|
@@ -0,0 +1,167 @@
|
|
|
+<!DOCTYPE html>
|
|
|
+<html>
|
|
|
+<head>
|
|
|
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
|
|
+ <title>Report Demo!</title>
|
|
|
+</head>
|
|
|
+<body>
|
|
|
+ <!--
|
|
|
+ <script src="https://code.jquery.com/jquery-3.1.1.min.js"></script>
|
|
|
+ -->
|
|
|
+
|
|
|
+ <script src="/src/lib/jquery-1.9.1.min.js"></script>
|
|
|
+ <script type="text/javascript" src="/src/jpc_report/rpt_component/Jpc_Output_ValueDefine.js"></script>
|
|
|
+ <script type="text/javascript" src="/src/jpc_report/rpt_component/Jpc_Output.js"></script>
|
|
|
+ <table id="forPrintHide">
|
|
|
+ <tr>
|
|
|
+ <td width="5"></td>
|
|
|
+ <td>
|
|
|
+ <select name="select1" id="select_k1" onchange="ajaxCall()">
|
|
|
+ <option value="SC;07_1">07-1表</option>
|
|
|
+ <option value="SC;08_2">08-2表</option>
|
|
|
+ <option value="MEASURE;M_ZB03_QDZF_09">计量-清单支付09表</option>
|
|
|
+ </select>
|
|
|
+ <select name="select2" id="select_k2" onchange="ajaxCall()">
|
|
|
+ <option value="A4">A4</option>
|
|
|
+ <option value="A3">A3</option>
|
|
|
+ </select>
|
|
|
+ </td>
|
|
|
+ <td>
|
|
|
+ <input type="button" value="显示报表" onclick="ajaxCall()"/>
|
|
|
+ <input type="button" value="< 前一页" onclick="showPage(-1)"/>
|
|
|
+ <input type="button" value="后一页 >" onclick="showPage(1)"/>
|
|
|
+ <input type="button" value="打印" onclick="printCurrentPage()"/>
|
|
|
+ </td>
|
|
|
+ </tr>
|
|
|
+ </table>
|
|
|
+ <canvas id="myCanvas" width="2000" height="1280">
|
|
|
+ </canvas>
|
|
|
+</body>
|
|
|
+<style>
|
|
|
+ body {
|
|
|
+ margin: 0px;
|
|
|
+ padding: 0px;
|
|
|
+ }
|
|
|
+ #myCanvas {
|
|
|
+ border: 0px solid #9C9898;
|
|
|
+ }
|
|
|
+</style>
|
|
|
+<script>
|
|
|
+ var currentPage = 1;
|
|
|
+ var pageRst = null;
|
|
|
+ var currentRptTpl = null;
|
|
|
+ var maxPages = 20;
|
|
|
+ var defProperties = null;
|
|
|
+ var rpt_grp = null;
|
|
|
+ var rpt_id = null;
|
|
|
+ var rpt_size = null;
|
|
|
+
|
|
|
+ window.onload = function (){
|
|
|
+ $.ajax({
|
|
|
+ type:"POST",
|
|
|
+ url: 'http://localhost:3010/api/setDftCache',
|
|
|
+ dataType: 'json',
|
|
|
+ cache: false,
|
|
|
+ timeout: 10000,
|
|
|
+ success: function(data){
|
|
|
+ defProperties = data;
|
|
|
+ },
|
|
|
+ error: function(jqXHR, textStatus, errorThrown){
|
|
|
+ //alert('error ' + textStatus + " " + errorThrown);
|
|
|
+ //or create local default cache...
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ function printCurrentPage() {
|
|
|
+ if (currentRptTpl) {
|
|
|
+ //$("table#forPrintHide").css
|
|
|
+ $("table#forPrintHide").css("display","none");
|
|
|
+ window.print();
|
|
|
+ //$("canvas#myCanvas").printArea();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ function getScreenDPI() {
|
|
|
+ var me = this, arrDPI = [];
|
|
|
+ if (window.screen.deviceXDPI != undefined) {
|
|
|
+ arrDPI.push(window.screen.deviceXDPI);
|
|
|
+ arrDPI.push(window.screen.deviceYDPI);
|
|
|
+ } else {
|
|
|
+ var tmpNode = document.createElement("DIV");
|
|
|
+ tmpNode.style.cssText = "width:1in;height:1in;position:absolute;left:0px;top:0px;z-index:99;visibility:hidden";
|
|
|
+ document.body.appendChild(tmpNode);
|
|
|
+ arrDPI.push(parseInt(tmpNode.offsetWidth));
|
|
|
+ arrDPI.push(parseInt(tmpNode.offsetHeight));
|
|
|
+ tmpNode.parentNode.removeChild(tmpNode);
|
|
|
+ }
|
|
|
+ return arrDPI;
|
|
|
+ }
|
|
|
+
|
|
|
+ function setupReport() {
|
|
|
+ var rst = false;
|
|
|
+ var rpt = document.getElementById("select_k1");
|
|
|
+ var size = document.getElementById("select_k2");
|
|
|
+ if (rpt.selectedIndex >= 0 && size.selectedIndex >= 0) {
|
|
|
+ var strs = rpt.options[rpt.selectedIndex].value.split(';');
|
|
|
+ rpt_grp = strs[0];
|
|
|
+ rpt_id = strs[1];
|
|
|
+ rpt_size = size.options[size.selectedIndex].value;
|
|
|
+ rst = true;
|
|
|
+ }
|
|
|
+ return rst;
|
|
|
+ }
|
|
|
+
|
|
|
+ function showPage(pageStep, cv) {
|
|
|
+ if (currentPage + pageStep >= 1 && currentPage + pageStep <= maxPages) {
|
|
|
+ currentPage = currentPage + pageStep;
|
|
|
+ var canvas = null;
|
|
|
+ if (cv) {
|
|
|
+ canvas = cv;
|
|
|
+ } else canvas = document.getElementById("myCanvas");
|
|
|
+ JpcCanvasOutput.cleanCanvas(canvas);
|
|
|
+ JpcCanvasOutput.drawPageBorder(currentRptTpl, canvas, getScreenDPI());
|
|
|
+ JpcCanvasOutput.drawToCanvas(pageRst, canvas, currentPage);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ function ajaxCall() {
|
|
|
+ if (setupReport()) {
|
|
|
+ var canvas = document.getElementById("myCanvas");
|
|
|
+ canvas.style.cursor = "wait";
|
|
|
+ $.ajax({
|
|
|
+ type:"POST",
|
|
|
+ url: 'http://localhost:3010/api/getReport',
|
|
|
+ //url: 'http://www.smart_cost_tony.cn:3010/api/getReport',
|
|
|
+ data: {"grp_id": rpt_grp, "tpl_id": rpt_id, "pageSize": rpt_size},
|
|
|
+ dataType: 'json',
|
|
|
+ cache: false,
|
|
|
+ timeout: 15000,
|
|
|
+ success: function(result){
|
|
|
+ canvas.style.cursor = "default";
|
|
|
+ currentPage = 1;
|
|
|
+ pageRst = result.data;
|
|
|
+ if (pageRst) {
|
|
|
+ maxPages = pageRst.items.length;
|
|
|
+ currentRptTpl = pageRst;
|
|
|
+ if (rpt_size === "A4") {
|
|
|
+ canvas.width = 1200;
|
|
|
+ canvas.height = 900;
|
|
|
+ } else if (rpt_size === "A3") {
|
|
|
+ canvas.width = 1880;
|
|
|
+ canvas.height = 1200;
|
|
|
+ }
|
|
|
+ showPage(0, canvas);
|
|
|
+ }
|
|
|
+ },
|
|
|
+ error: function(jqXHR, textStatus, errorThrown){
|
|
|
+ canvas.style.cursor = "default";
|
|
|
+ alert('error ' + textStatus + " " + errorThrown);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+</script>
|
|
|
+
|
|
|
+</html>
|