| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157 | <!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="/lib/jquery/jquery.min.js"></script>    <script type="text/javascript" src="/web/report/js/Jpc_Output_ValueDefine.js"></script>    <script type="text/javascript" src="/web/report/js/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()"/>                <input type="button" value="Excel" onclick="getExcel()"/>            </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;    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 getExcel() {        var id = "dummy_request_id";        var p1 = "dummy_paramm_2";        var url =  "/report_api/getExcel/" + id + "/" + p1;        window.location = url;//这里不能使用get方法跳转,否则下载不成功    }    function ajaxCall() {        if (setupReport()) {            var canvas = document.getElementById("myCanvas");            canvas.style.cursor = "wait";            $.ajax({                type:"POST",                url: 'http://localhost:6060/report_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>
 |