Sfoglia il codice sorgente

pdf字体装载调整

TonyKang 6 anni fa
parent
commit
405656c451
1 ha cambiato i file con 13 aggiunte e 10 eliminazioni
  1. 13 10
      web/building_saas/report/js/rpt_main.js

+ 13 - 10
web/building_saas/report/js/rpt_main.js

@@ -30,8 +30,8 @@ let rptTplObj = {
             }
             // dynamicLoadJs('/lib/jspdf/SmartSimsun-normal.js');
             // dynamicLoadJs('/lib/jspdf/SmartSimsun-bold.js', me.pdfFontSimsunCallBack);
-            dynamicLoadJs('http://d2.smartcost.com.cn/cach/SmartSimsun-normal.js');
-            dynamicLoadJs('http://d2.smartcost.com.cn/cach/SmartSimsun-bold.js', me.pdfFontSimsunCallBack);
+            // dynamicLoadJs('http://d2.smartcost.com.cn/cach/SmartSimsun-normal.js');
+            // dynamicLoadJs('http://d2.smartcost.com.cn/cach/SmartSimsun-bold.js', me.pdfFontSimsunCallBack);
         }
     },
     pdfFontSimsunCallBack: function() {
@@ -957,8 +957,10 @@ let rptControlObj = {
         if (rptTplObj.pdfFont['SmartSimsun'].length === 2) {
             me.getPDFEx();
         } else {
-            dynamicLoadJs('http://d2.smartcost.com.cn/cach/SmartSimsun-normal.js', me.getPdfFontCallback('normal'));
-            dynamicLoadJs('http://d2.smartcost.com.cn/cach/SmartSimsun-bold.js', me.getPdfFontCallback('bold'));
+            dynamicLoadJs('/lib/jspdf/SmartSimsun-normal.js',"normal", me.getPdfFontCallback);
+            dynamicLoadJs('/lib/jspdf/SmartSimsun-bold.js',"bold", me.getPdfFontCallback);
+            // dynamicLoadJs('http://d2.smartcost.com.cn/cach/SmartSimsun-normal.js', me.getPdfFontCallback('normal'));
+            // dynamicLoadJs('http://d2.smartcost.com.cn/cach/SmartSimsun-bold.js', me.getPdfFontCallback('bold'));
         }
     },
     getPDFEx: function () {
@@ -1149,17 +1151,18 @@ function downloadReport(urls) {
     private_download();
 }
 
-function dynamicLoadJs(url, callback) {
+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 () {
-            if (!this.readyState || this.readyState === "loaded" || this.readyState === "complete"){
-                callback();
-                script.onload = script.onreadystatechange = null;
-            }
+        script.onload = script.onreadystatechange = function (event) {
+            // console.log('this.readyState: ' + this.readyState);
+            callback(type);
+            script.onload = script.onreadystatechange = null;
+            // if (this.readyState === "loaded" || this.readyState === "complete"){
+            // }
         };
     }
     head.appendChild(script);