Bladeren bron

spreadjs换行转义

laiguoran 5 jaren geleden
bovenliggende
commit
2adcba649a
2 gewijzigde bestanden met toevoegingen van 13 en 2 verwijderingen
  1. 1 1
      app/public/js/global.js
  2. 12 1
      app/public/js/material.js

+ 1 - 1
app/public/js/global.js

@@ -665,7 +665,7 @@ function toastMessageUniq (obj) {
 }
 
 function trimInvalidChar(str) {
-    return $.trim(str).replace('\n', '').replace('\r', '').replace('\t', '');
+    return $.trim(str).replace(/\n/g, '').replace(/\r/g, '').replace(/\t/g, '');
 }
 
 jQuery.bootstrapLoading = {

+ 12 - 1
app/public/js/material.js

@@ -242,7 +242,8 @@ $(document).ready(() => {
                 const select = SpreadJsObj.getSelectObject(info.sheet);
                 const col = info.sheet.zh_setting.cols[info.col];
                 // 未改变值则不提交
-                const validText = info.editingText ? (typeof(info.editingText) === 'String' ? info.editingText.replace('\n', '') : info.editingText) : null;
+                const validText = info.editingText ? trimInvalidChar(info.editingText) : null;
+                console.log(validText);
                 const orgValue = select[col.field];
                 if (orgValue == validText || ((!orgValue || orgValue === '') && (validText === ''))) {
                     SpreadJsObj.reLoadRowData(info.sheet, info.row);
@@ -596,3 +597,13 @@ $(document).ready(() => {
         }
     });
 });
+//
+// const pasteExpr = function (e, obj) {
+//     let text = e.clipboardData.getData('text');
+//     e.preventDefault();
+//     text = trimInvalidChar(_.trim(text));
+//     const start = obj.selectionStart, end = obj.selectionEnd;
+//     obj.value = obj.value.substr(0, start) + text + obj.value.substring(end, obj.value.length);
+//     obj.selectionStart = start + text.length;
+//     obj.selectionEnd = start + text.length;
+// };