Parcourir la source

html 标签处理

zhangweicheng il y a 5 ans
Parent
commit
f447e56eea
1 fichiers modifiés avec 14 ajouts et 2 suppressions
  1. 14 2
      web/building_saas/main/js/views/sub_view.js

+ 14 - 2
web/building_saas/main/js/views/sub_view.js

@@ -911,8 +911,20 @@ $('.gljSubTab ul li a').on('shown.bs.tab', function () {
 $('#tzCharacterText').blur(async function () {
   let billID = $("#xmtz_billID").val();
   let htmlString = $(this).html();
-  let value = htmlString.replace(/<br>/g,"\n");
-  value = value.replace(/&nbsp;/g," ");
+  let value = htmlString.replace(/&nbsp;/g," ");
+  if(value.indexOf("<div>")!= -1){
+      let preString = value.substring(0,value.indexOf("<div>"));
+      let arrayText =[];
+      let divArray = value.match(/<div>(.*?)<\/div>/g);
+      for(let d of divArray){
+          t = d.match(/<div>(\S*)<\/div>/)[1];
+          if(t == "<br>") t="";
+          arrayText.push(t)
+      }
+      value = preString +"\n"+ arrayText.join("\n");
+  }
+  value = value.replace(/<br>/g,"\n");
+
   let billNode = projectObj.project.mainTree.getNodeByID(billID);
   if(billNode && value == billNode.data.itemCharacterText) return;
   let datas = [{