laiguoran 4 лет назад
Родитель
Сommit
ff39a40fc8
2 измененных файлов с 41 добавлено и 34 удалено
  1. 27 22
      app/public/js/schedule_plan.js
  2. 14 12
      app/public/js/schedule_stage_gcl.js

+ 27 - 22
app/public/js/schedule_plan.js

@@ -203,7 +203,7 @@ $(function () {
             if (info.sheet.zh_setting) {
                 const select = SpreadJsObj.getSelectObject(info.sheet);
                 const col = info.sheet.zh_setting.cols[info.col];
-                const validText = is_numeric(info.editingText) ? parseFloat(info.editingText) : (info.editingText ? trimInvalidChar(info.editingText) : null);
+                let validText = is_numeric(info.editingText) ? parseFloat(info.editingText) : (info.editingText ? trimInvalidChar(info.editingText) : null);
                 const orgValue = select[col.field];
                 if (orgValue == validText || ((!orgValue || orgValue === '') && (validText === ''))) {
                     SpreadJsObj.reLoadRowData(info.sheet, info.row);
@@ -220,23 +220,25 @@ $(function () {
                 let plan_tp = 0;
                 // 判断输入位数,提示
                 if (mode === 'tp') {
-                    const reg = new RegExp('^([-]?)\\d+(\\.\\d{0,'+ parseInt(tenderInfo.decimal.tp) +'})?$');
+                    const reg = new RegExp('^([-]?)\\d+$');
                     if (validText !== null && (!reg.test(validText))) {
-                        toastr.error('输入金额小数位数不能大于' + tenderInfo.decimal.tp + '位');
-                        SpreadJsObj.reLoadRowData(info.sheet, info.row);
-                        return;
+                        // toastr.error('输入金额请为整数');
+                        // SpreadJsObj.reLoadRowData(info.sheet, info.row);
+                        // return;
+                        validText = ZhCalc.round(validText, 0);
                     }
-                    plan_gcl = select.dgn_price && select.dgn_price !== 0 ? ZhCalc.round(ZhCalc.div(validText, select.dgn_price), tenderInfo.decimal.up) : 0;
+                    plan_gcl = select.dgn_price && select.dgn_price !== 0 ? ZhCalc.round(ZhCalc.div(validText, select.dgn_price), 3) : 0;
                     plan_tp = validText;
                 } else {
-                    const reg = new RegExp('^([-]?)\\d+(\\.\\d{0,'+ parseInt(tenderInfo.decimal.up) +'})?$');
+                    const reg = new RegExp('^([-]?)\\d+$');
                     if (validText !== null && (!reg.test(validText))) {
-                        toastr.error('输入工程量小数位数不能大于' + tenderInfo.decimal.up + '位');
-                        SpreadJsObj.reLoadRowData(info.sheet, info.row);
-                        return;
+                        // toastr.error('输入工程量小数位数不能大于3位');
+                        // SpreadJsObj.reLoadRowData(info.sheet, info.row);
+                        // return;
+                        validText = ZhCalc.round(validText, 3);
                     }
                     plan_gcl = validText;
-                    plan_tp = select.dgn_price && select.dgn_price !== 0 ? ZhCalc.round(ZhCalc.mul(validText, select.dgn_price), tenderInfo.decimal.tp) : 0;
+                    plan_tp = select.dgn_price && select.dgn_price !== 0 ? ZhCalc.round(ZhCalc.mul(validText, select.dgn_price), 0) : 0;
                 }
                 select[col.field] = validText;
                 const updateData = {
@@ -280,7 +282,7 @@ $(function () {
             }
             const select = SpreadJsObj.getSelectObject(info.sheet);
             const col = info.sheet.zh_setting.cols[range.col];
-            const validText = is_numeric(info.pasteData.text) ? parseFloat(info.pasteData.text) : (info.pasteData.text ? trimInvalidChar(info.pasteData.text) : null);
+            let validText = is_numeric(info.pasteData.text) ? parseFloat(info.pasteData.text) : (info.pasteData.text ? trimInvalidChar(info.pasteData.text) : null);
             const orgValue = select[col.field];
             if (orgValue == validText || ((!orgValue || orgValue === '') && (validText === ''))) {
                 SpreadJsObj.reLoadRowData(info.sheet, info.row);
@@ -297,23 +299,26 @@ $(function () {
             let plan_tp = 0;
             // 判断输入位数,提示
             if (mode === 'tp') {
-                const reg = new RegExp('^([-]?)\\d+(\\.\\d{0,'+ parseInt(tenderInfo.decimal.tp) +'})?$');
+                const reg = new RegExp('^([-]?)\\d+$');
                 if (validText !== null && (!reg.test(validText))) {
-                    toastr.error('粘贴的金额小数位数不能大于' + tenderInfo.decimal.tp + '位');
-                    SpreadJsObj.reLoadRowData(info.sheet, info.cellRange.row, info.cellRange.rowCount);
-                    return;
+                    // toastr.error('粘贴的金额小数位数不能大于0位');
+                    // SpreadJsObj.reLoadRowData(info.sheet, info.cellRange.row, info.cellRange.rowCount);
+                    // return;
+                    validText = ZhCalc.round(validText, 0);
                 }
-                plan_gcl = select.dgn_price && select.dgn_price !== 0 ? ZhCalc.round(ZhCalc.div(validText, select.dgn_price), tenderInfo.decimal.up) : 0;
+                plan_gcl = select.dgn_price && select.dgn_price !== 0 ? ZhCalc.round(ZhCalc.div(validText, select.dgn_price), 3) : 0;
                 plan_tp = validText;
             } else {
-                const reg = new RegExp('^([-]?)\\d+(\\.\\d{0,'+ parseInt(tenderInfo.decimal.up) +'})?$');
+                // const reg = new RegExp('^([-]?)\\d+(\\.\\d{0,3})?$');
+                const reg = new RegExp('^([-]?)\\d+$');
                 if (validText !== null && (!reg.test(validText))) {
-                    toastr.error('粘贴的工程量小数位数不能大于' + tenderInfo.decimal.up + '位');
-                    SpreadJsObj.reLoadRowData(info.sheet, info.cellRange.row, info.cellRange.rowCount);
-                    return;
+                    // toastr.error('粘贴的工程量小数位数不能大于3位');
+                    // SpreadJsObj.reLoadRowData(info.sheet, info.cellRange.row, info.cellRange.rowCount);
+                    // return;
+                    validText = ZhCalc.round(validText, 3);
                 }
                 plan_gcl = validText;
-                plan_tp = select.dgn_price && select.dgn_price !== 0 ? ZhCalc.round(ZhCalc.mul(validText, select.dgn_price), tenderInfo.decimal.tp) : 0;
+                plan_tp = select.dgn_price && select.dgn_price !== 0 ? ZhCalc.round(ZhCalc.mul(validText, select.dgn_price), 0) : 0;
             }
             select[col.field] = validText;
             const updateData = {

+ 14 - 12
app/public/js/schedule_stage_gcl.js

@@ -202,7 +202,7 @@ $(function () {
             if (info.sheet.zh_setting) {
                 const select = SpreadJsObj.getSelectObject(info.sheet);
                 const col = info.sheet.zh_setting.cols[info.col];
-                const validText = is_numeric(info.editingText) ? parseFloat(info.editingText) : (info.editingText ? trimInvalidChar(info.editingText) : null);
+                let validText = is_numeric(info.editingText) ? parseFloat(info.editingText) : (info.editingText ? trimInvalidChar(info.editingText) : null);
                 const orgValue = select[col.field];
                 if (orgValue == validText || ((!orgValue || orgValue === '') && (validText === ''))) {
                     SpreadJsObj.reLoadRowData(info.sheet, info.row);
@@ -215,14 +215,15 @@ $(function () {
                 }
                 const yearmonth = col.field.split('_')[0];
                 // 判断输入位数,提示
-                const reg = new RegExp('^([-]?)\\d+(\\.\\d{0,'+ parseInt(tenderInfo.decimal.up) +'})?$');
+                const reg = new RegExp('^([-]?)\\d+$');
                 if (validText !== null && (!reg.test(validText))) {
-                    toastr.error('输入工程量小数位数不能大于' + tenderInfo.decimal.up + '位');
-                    SpreadJsObj.reLoadRowData(info.sheet, info.row);
-                    return;
+                    // toastr.error('输入工程量小数位数不能大于3位');
+                    // SpreadJsObj.reLoadRowData(info.sheet, info.row);
+                    // return;
+                    validText = ZhCalc.round(validText, 3);
                 }
                 const sj_gcl = validText;
-                const sj_tp = select.dgn_price && select.dgn_price !== 0 ? ZhCalc.round(ZhCalc.mul(validText, select.dgn_price), tenderInfo.decimal.tp) : 0;
+                const sj_tp = select.dgn_price && select.dgn_price !== 0 ? ZhCalc.round(ZhCalc.mul(validText, select.dgn_price), 0) : 0;
                 select[col.field] = validText;
                 const updateData = {
                     lid: select.ledger_id,
@@ -261,7 +262,7 @@ $(function () {
             }
             const select = SpreadJsObj.getSelectObject(info.sheet);
             const col = info.sheet.zh_setting.cols[range.col];
-            const validText = is_numeric(info.pasteData.text) ? parseFloat(info.pasteData.text) : (info.pasteData.text ? trimInvalidChar(info.pasteData.text) : null);
+            let validText = is_numeric(info.pasteData.text) ? parseFloat(info.pasteData.text) : (info.pasteData.text ? trimInvalidChar(info.pasteData.text) : null);
             const orgValue = select[col.field];
             if (orgValue == validText || ((!orgValue || orgValue === '') && (validText === ''))) {
                 SpreadJsObj.reLoadRowData(info.sheet, info.row);
@@ -274,14 +275,15 @@ $(function () {
             }
             const yearmonth = col.field.split('_')[0];
             // 判断输入位数,提示
-            const reg = new RegExp('^([-]?)\\d+(\\.\\d{0,'+ parseInt(tenderInfo.decimal.up) +'})?$');
+            const reg = new RegExp('^([-]?)\\d+$');
             if (validText !== null && (!reg.test(validText))) {
-                toastr.error('粘贴的工程量小数位数不能大于' + tenderInfo.decimal.up + '位');
-                SpreadJsObj.reLoadRowData(info.sheet, info.cellRange.row, info.cellRange.rowCount);
-                return;
+                // toastr.error('粘贴的工程量小数位数不能大于3位');
+                // SpreadJsObj.reLoadRowData(info.sheet, info.cellRange.row, info.cellRange.rowCount);
+                // return;
+                validText = ZhCalc.round(validText, 3);
             }
             const sj_gcl = validText;
-            const sj_tp = select.dgn_price && select.dgn_price !== 0 ? ZhCalc.round(ZhCalc.mul(validText, select.dgn_price), tenderInfo.decimal.tp) : 0;
+            const sj_tp = select.dgn_price && select.dgn_price !== 0 ? ZhCalc.round(ZhCalc.mul(validText, select.dgn_price), 0) : 0;
             select[col.field] = validText;
             const updateData = {
                 lid: select.ledger_id,