Explorar el Código

报表模板js导入问题(不认tab符)

TonyKang hace 7 años
padre
commit
433313893e
Se han modificado 2 ficheros con 6 adiciones y 1 borrados
  1. 4 0
      public/web/string_util_light.js
  2. 2 1
      web/maintain/report/js/rpt_tpl_helper.js

+ 4 - 0
public/web/string_util_light.js

@@ -14,6 +14,10 @@ let stringUtil = {
         }
         }
         return rst;
         return rst;
     },
     },
+    replaceAll: function (targetStr, FindText, RepText) {
+        let regExp = new RegExp(FindText, "gm");
+        return targetStr.replace(regExp, RepText);
+    },
     convertStrToBoolean: function(str) {
     convertStrToBoolean: function(str) {
         let rst = false, me = this;
         let rst = false, me = this;
         if (!me.isEmptyString(str)) {
         if (!me.isEmptyString(str)) {

+ 2 - 1
web/maintain/report/js/rpt_tpl_helper.js

@@ -46,7 +46,8 @@ let tplHelper = {
         if (srcDom && zTreeOprObj.currentNode && zTreeOprObj.currentNode.refId > 0 &&
         if (srcDom && zTreeOprObj.currentNode && zTreeOprObj.currentNode.refId > 0 &&
             confirm("导入将覆盖原模板所有信息,请确认!")) {
             confirm("导入将覆盖原模板所有信息,请确认!")) {
             try {
             try {
-                let rptTpl = JSON.parse(srcDom.value);
+                // let rptTpl = JSON.parse(srcDom.value);
+                let rptTpl = JSON.parse(stringUtil.replaceAll(srcDom.value, "\t", " "));
                 // JSON.format()
                 // JSON.format()
                 delete rptTpl["__v"];
                 delete rptTpl["__v"];
                 delete rptTpl["_id"];
                 delete rptTpl["_id"];