CB2-20200827ONU\Administrator
2021-09-22 641ddf669ad57fb544e13a6433aa5905551b3bba
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
var LODOP;
/*
注册按键
*/
//var keyDownHook = new KeyBehaviorHook('keydown');
//keyDownHook.Regist(window.Keys.S, "document.getElementById('btnSetPrint').click()", window.WithKey.Alt); //Alt+S 设置(SetPrint)
//keyDownHook.Regist(window.Keys.L, "document.getElementById('btnLook').click()", window.WithKey.Ctrl); //Ctrl+L 预览(Look)
//keyDownHook.Regist(window.Keys.P, "document.getElementById('btnPrint').click()", window.WithKey.Ctrl); //Ctrl+P 打印(Print)
//keyDownHook.Regist(window.Keys.Q, "document.getElementById('btnQuit').click()", window.WithKey.Ctrl); //Ctrl+Q 退出(Quit)
/*
if(!-[1,])
keyDownHook.Regist(window.Keys.S, "document.getElementById('btnSaveAs').click()", window.WithKey.Ctrl); //Alt+S 另存为(SaveAs)
*/
 
 
$(function () {
 
    var thehead = document.getElementsByTagName('head')[0];
    var sitelocation = GetRootUrl();
    var appendingObj = document.createElement('script');
    appendingObj.type = 'text/javascript';
    appendingObj.src = sitelocation + 'js/common/LodopFuncs.js';
    thehead.appendChild(appendingObj);
 
    appendingObj = document.createElement('link');
    appendingObj.type = 'text/css';
    appendingObj.rel = 'stylesheet';
    appendingObj.src = sitelocation + 'common/PrintSample10.css';
    thehead.appendChild(appendingObj);
 
    //    var titles = document.getElementsByTagName('title');
    //    if (titles.length > 0) thehead.removeChild(titles); //清空title
    //    keyDownHook.Binding();
        $("#div_tool").html(toolHtml);
    //    document.getElementById('btnPrint').focus();
    //    window.wbb = document.getElementById('WebBrowser');
})
 
var toolHtml = "<input type='button'  id='btnPrint'  value='打印' onclick='Preview()'/>&#12288;" + "<input type='button' value='关闭'  id='btnQuit'  onclick='closeWindow()' />";
 
function closeWindow() {
    if (top.Dialog) {
        try {
            top.Dialog.close();
        }
        catch (ex) {
        }
    }
    else {
        window.close();
    }
}
 
/*
开始打印方法
*/
function OnPrint() {
    if ($("#div_tool").attr("spe") == "corOrint") {
        //PrintCorOrIntLetters();
    }
    document.getElementById('div_tool').style.display = 'none';
    if (window.printBeginCallBack && 'function' == typeof (window.printBeginCallBack))
        try {
            window.printBeginCallBack();
        } catch (e) {
 
        }
}
/*
打印结束方法
*/
function OnPrintOver() {
    document.getElementById('div_tool').style.display = '';
    if (window.printOverCallBack && 'function' == typeof (window.printOverCallBack))
        try {
            window.printOverCallBack();
        } catch (e) {
 
        }
    $(".warning").remove();
}
/*
打印
*/
 
var printStyle = "";
var printContent = "";
 
function SetPrintPar(style, content) {
    printStyle = style;
    printContent = content;
}
 
function Preview() {
    OnPrint();
    try {
        LODOP = getLodop(document.getElementById('LODOP_OB'), document.getElementById('LODOP_EM'));
        if ((LODOP == null) || (typeof (LODOP.VERSION) == "undefined")) return;
        var div_tool = document.getElementById('div_tool');
        var printparams = div_tool.getAttribute('printparams');
 
        if (!printparams) {
           // alert("1");
           // LODOP.SET_PRINT_PAGESIZE(0, 1700, 1200, "A4");
        }
        else {
            printparams = printparams.toString().split(',');
            LODOP.SET_PRINT_PAGESIZE(parseInt(printparams[0]), parseInt(printparams[1]), parseInt(printparams[2]), printparams[3]);
        }
 
 
        if ($("#div_tool").attr("issideways") == "true") {
            LODOP.ADD_PRINT_TABLE(30, 30, "95%", "90%", $(document.documentElement).html());
            LODOP.SET_SHOW_MODE("LANDSCAPE_DEFROTATED", 1);
        } else if ($("#div_tool").attr("issideways") == "printinfo") {
            var Oldhtml = "";
            if (printStyle != "" && printStyle != undefined && printContent !== "") {
                Oldhtml = printStyle + "<body>" + printContent + "</body>";
                LODOP.ADD_PRINT_HTM(30, 30, "95%", "90%", Oldhtml);
            }
            else {
                $(".warning").remove();
                //alert($(document.documentElement).html());
                LODOP.ADD_PRINT_HTM(30, 30, "95%", "90%", $(document.documentElement).html());
            }
        } else{
            var Oldhtml = "";
            if (printStyle != "" && printStyle != undefined && printContent !== "") {
                Oldhtml = printStyle + "<body>" + printContent + "</body>";
                LODOP.ADD_PRINT_HTM(0, 0, "100%", "100%", Oldhtml);
            }
            else {
                $(".warning").remove();
                //alert($(document.documentElement).html());
                LODOP.ADD_PRINT_HTM(0, 0, "100%", "100%", $(document.documentElement).html());
            }
        }
        LODOP.PREVIEW();
 
    } catch (e) {
        //alertMsg('异常信息:' + e.message);
    }
    OnPrintOver();
}