Переглянути джерело

Merge branch 'dev' of http://192.168.1.41:3000/maixinrong/Calculation into dev

MaiXinRong 3 роки тому
батько
коміт
3ed8762fbb
1 змінених файлів з 17 додано та 13 видалено
  1. 17 13
      app/public/js/material_exponent.js

+ 17 - 13
app/public/js/material_exponent.js

@@ -159,13 +159,17 @@ $(document).ready(() => {
                         SpreadJsObj.reLoadRowData(info.sheet, info.row);
                         return;
                     }
-                    const num = parseFloat(validText);
-                    if (validText !== null && (num < 0 || !/^(\d{1,10})?$/.test(num))) {
+                    const num = parseFloat(validText.toPrecision(10));
+                    if (validText !== null && num < 0) {
                         toastr.error('请输入10位以内有效数字并且小于3位小数的浮点数');
                         SpreadJsObj.reLoadRowData(info.sheet, info.row);
                         return;
-                    } else if (validText !== null && !/^(\d{1,7}\.\d{1,3})?$/.test(num)) {
-                        toastr.warning('已保留3位小数');
+                    } else if (validText !== null) {
+                        if(!Number.isInteger(num) && !/^(\d{1,10}\.\d{1,3})?$/.test(num)) {
+                            toastr.warning('已保留3位小数');
+                        } else if (validText.toString().length > 11) {
+                            toastr.warning('已保留10位有效数字');
+                        }
                         // SpreadJsObj.reLoadRowData(info.sheet, info.row);
                         // return;
                         validText = ZhCalc.round(num, 3);
@@ -307,6 +311,7 @@ $(document).ready(() => {
                 numberCan: {type: 'error', msg: '请粘贴10位以内有效数字并且小于3位小数的浮点数'},
                 numberCan2: {type: 'error', msg: '请粘贴0~1范围内并且小于3位小数的浮点数'},
                 numberCan3: {type: 'warning', msg: '已保留3位小数'},
+                numberCan4: {type: 'warning', msg: '已保留10位有效数字'},
                 weightNumberCan: {type: 'error', msg: '粘贴的加权系数总和不能大于1'},
             };
             const range = info.cellRange;
@@ -354,18 +359,17 @@ $(document).ready(() => {
                             bPaste = false;
                             continue;
                         }
-                        const num = parseFloat(validText);
-                        // if (validText !== null && (num < 0 || !/^(\d{1,10}|\d{1,7}\.\d{1,3})?$/.test(num))) {
-                        //     toastMessageUniq(getPasteHint(hint.numberCan, hintRow));
-                        //     bPaste = false;
-                        //     continue;
-                        // }
-                        if (validText !== null && (num < 0 || !/^(\d{1,10})?$/.test(num))) {
+                        const num = parseFloat(validText.toPrecision(10));
+                        if (validText !== null && num < 0) {
                             toastMessageUniq(getPasteHint(hint.numberCan, hintRow));
                             bPaste = false;
                             continue;
-                        } else if (validText !== null && !/^(\d{1,7}\.\d{1,3})?$/.test(num)) {
-                            toastMessageUniq(getPasteHint(hint.numberCan3, hintRow));
+                        } else if (validText !== null) {
+                            if(!Number.isInteger(num) && !/^(\d{1,10}\.\d{1,3})?$/.test(num)) {
+                                toastMessageUniq(getPasteHint(hint.numberCan3, hintRow));
+                            } else if (validText.toString().length > 11) {
+                                toastMessageUniq(getPasteHint(hint.numberCan4, hintRow));
+                            }
                             // SpreadJsObj.reLoadRowData(info.sheet, info.row);
                             // return;
                             validText = ZhCalc.round(num, 3);