Explorar o código

waterAnalysisDataVisualization water.js 李欣儒 commit at 2021-04-15

李欣儒 %!s(int64=4) %!d(string=hai) anos
pai
achega
fd817f45f8
Modificáronse 1 ficheiros con 50 adicións e 0 borrados
  1. 50 0
      waterAnalysisDataVisualization/externalJs/water.js

+ 50 - 0
waterAnalysisDataVisualization/externalJs/water.js

@@ -1957,3 +1957,53 @@ $("#building").change(function() {
     }, 100)
 
 });
+
+// 打印
+(function() {
+
+    $("#btnPrint").click(function() {
+        print_detail()
+    });
+
+    var print_detail = function() {
+
+        //打印前echarts图表转换成图片 start   
+        $('#divergenceChart1_img').show()
+        $('#divergenceChart1').hide()
+
+        $('#hiddenCheckChart1_img').show()
+        $('#hiddenCheckChart1').hide()
+
+        $('#deviceLinkChart1_img,#deviceLinkChart2_img').show()
+        $('#deviceLinkChart1,#deviceLinkChart2').hide()
+
+        $('#dataChangeChart1_img').show()
+        $('#dataChangeChart1').hide()
+            //  end
+
+        var div1_label1 = document.getElementById('printArea').innerHTML;
+        var hkey_key;
+        var hkey_root = 'HKEY_CURRENT_USER';
+        var hkey_path = '\\Software\\Micorsoft\\Internet Explorer\\PageSetup\\';
+        var print_win = window.open('打印窗口', '_blank');
+        var div = document.createElement('div');
+        div.setAttribute('width', '100%');
+        div.setAttribute('height', '100%');
+        var div_print = document.createElement('div');
+        div_print.setAttribute('style', 'width:595px;height:842px;padding:50px 20px;margin:0px auto 0px auto');
+        div_print.innerHTML = div1_label1;
+        div.appendChild(div_print);
+
+        print_win.document.write(div.innerHTML);
+        print_win.document.close();
+        try {
+            var RegWsh = new ActiveXObject('WScript.Shell');
+            hkey_key = 'header';
+            RegWsh.RegWrite(hkey_root + hkey_path + hkey_key, '');
+            hkey_key = 'footer';
+            RegWsh.RegWrite(hkey_root + hkey_path + hkey_key, '');
+        } catch (e) {}
+        print_win.print();
+        print_win.close();
+    }
+})()