chenshilong 7 年之前
父節點
當前提交
35e9e7190b

+ 1 - 0
web/building_saas/main/html/main.html

@@ -899,6 +899,7 @@
                             <button class="btn btn-secondary btn-sm" id="divOpr">/</button>
                             <button class="btn btn-secondary btn-sm" id="divOpr">/</button>
                             <button class="btn btn-secondary btn-sm" id="leftOpr">(</button>
                             <button class="btn btn-secondary btn-sm" id="leftOpr">(</button>
                             <button class="btn btn-secondary btn-sm" id="rightOpr">)</button>
                             <button class="btn btn-secondary btn-sm" id="rightOpr">)</button>
+                            <span id="errorInfo" style="margin-left:15px;"></span>
                         </p>
                         </p>
                     </div>
                     </div>
                     <div class="row" id="cbRowDiv">
                     <div class="row" id="cbRowDiv">

+ 19 - 9
web/building_saas/main/js/models/calc_program.js

@@ -909,6 +909,7 @@ const rationCalcBases = {
 };
 };
 
 
 let analyzer = {
 let analyzer = {
+    error: '',
     standard: function(expr){
     standard: function(expr){
         let str = expr;
         let str = expr;
         str = str.replace(/\s/g, "");               // 去空格、去中文空格
         str = str.replace(/\s/g, "");               // 去空格、去中文空格
@@ -985,14 +986,16 @@ let analyzer = {
         let expr = me.standard(dispExpr);
         let expr = me.standard(dispExpr);
         let invalidChars = /[^0-9\u4e00-\u9fa5\+\-\*\/\(\)\.\[\]FL%]/g;
         let invalidChars = /[^0-9\u4e00-\u9fa5\+\-\*\/\(\)\.\[\]FL%]/g;
         if (invalidChars.test(expr)){
         if (invalidChars.test(expr)){
-            hintBox.infoBox('错误提示',`表达式中含有${hintBox.font('无效字符')}!`,1);
+            analyzer.error = `表达式中含有${hintBox.font('无效字符')}!`;
+            // hintBox.infoBox('错误提示',`表达式中含有${hintBox.font('无效字符')}!`,1);
             return false;
             return false;
         };
         };
 
 
         let i = expr.search(/\df/ig);   // 4F3
         let i = expr.search(/\df/ig);   // 4F3
         let j = expr.search(/\d\[/ig);  // 4[定额基价人工费]
         let j = expr.search(/\d\[/ig);  // 4[定额基价人工费]
         if (i > -1 || j > -1){
         if (i > -1 || j > -1){
-            hintBox.infoBox('错误提示', `表达式中${hintBox.font('缺少运算符')}!`, 1);
+            analyzer.error = `表达式中${hintBox.font('缺少运算符')}!`;
+            // hintBox.infoBox('错误提示', `表达式中${hintBox.font('缺少运算符')}!`, 1);
             return false;
             return false;
         }
         }
 
 
@@ -1001,26 +1004,30 @@ let analyzer = {
         let pattBase = new RegExp(/\[[\u4E00-\u9FA5]+\]/gi);
         let pattBase = new RegExp(/\[[\u4E00-\u9FA5]+\]/gi);
         let arrBase = expr.match(pattBase);
         let arrBase = expr.match(pattBase);
         if (arrCn && !arrBase){
         if (arrCn && !arrBase){
-            hintBox.infoBox('错误提示', `定额基数必须用中括号${hintBox.font('[]')}括起来!`, 1);
+            analyzer.error = `定额基数必须用中括号${hintBox.font('[]')}括起来!`;
+            // hintBox.infoBox('错误提示', `定额基数必须用中括号${hintBox.font('[]')}括起来!`, 1);
             return false;
             return false;
         };
         };
         if (arrCn && arrBase && (arrCn.length != arrBase.length)){
         if (arrCn && arrBase && (arrCn.length != arrBase.length)){
             for (let cn of arrCn){
             for (let cn of arrCn){
                 let tempBase = `[${cn}]`;
                 let tempBase = `[${cn}]`;
                   if (!arrBase.includes(tempBase)){
                   if (!arrBase.includes(tempBase)){
-                      hintBox.infoBox('错误提示', `定额基数“${hintBox.font(cn)}”必须用中括号${hintBox.font('[]')}括起来!`, 1);
+                      analyzer.error = `定额基数“${hintBox.font(cn)}”必须用中括号${hintBox.font('[]')}括起来!`;
+                      // hintBox.infoBox('错误提示', `定额基数“${hintBox.font(cn)}”必须用中括号${hintBox.font('[]')}括起来!`, 1);
                       return false;
                       return false;
                   }
                   }
             };
             };
             // 这里要加一个保险。因为上面的 for 循环在“主材费 + [主材费]” 情况下有Bug
             // 这里要加一个保险。因为上面的 for 循环在“主材费 + [主材费]” 情况下有Bug
-            hintBox.infoBox('错误提示', `定额基数必须用中括号${hintBox.font('[]')}括起来!`, 1);
+            analyzer.error =`定额基数必须用中括号${hintBox.font('[]')}括起来!`;
+            // hintBox.infoBox('错误提示', `定额基数必须用中括号${hintBox.font('[]')}括起来!`, 1);
             return false;
             return false;
         };
         };
         if (arrBase){
         if (arrBase){
             for (let base of arrBase){
             for (let base of arrBase){
                 let baseName = base.slice(1, -1);
                 let baseName = base.slice(1, -1);
                 if (!rationCalcBases[baseName]){
                 if (!rationCalcBases[baseName]){
-                    hintBox.infoBox('错误提示', `定额基数${hintBox.font('[' +baseName + ']')}末定义!`, 1);
+                    analyzer.error = `定额基数${hintBox.font('[' +baseName + ']')}末定义!`;
+                    // hintBox.infoBox('错误提示', `定额基数${hintBox.font('[' +baseName + ']')}末定义!`, 1);
                     return false;
                     return false;
                 }
                 }
             };
             };
@@ -1031,18 +1038,21 @@ let analyzer = {
             let num = F.slice(1);
             let num = F.slice(1);
             if (num > template.calcItems.length){
             if (num > template.calcItems.length){
                 let s = hintBox.font('F'+num);
                 let s = hintBox.font('F'+num);
-                hintBox.infoBox('错误提示', `表达式中 “${hintBox.font(s)}” 行号引用错误!`, 1);
+                analyzer.error = `表达式中 “${hintBox.font(s)}” 行号引用错误!`;
+                // hintBox.infoBox('错误提示', `表达式中 “${hintBox.font(s)}” 行号引用错误!`, 1);
                 return false;
                 return false;
             };
             };
         };
         };
 
 
         let expression = me.getExpression(expr, template);
         let expression = me.getExpression(expr, template);
         if (me.isCycleCalc(expression, itemID, template)){
         if (me.isCycleCalc(expression, itemID, template)){
-            hintBox.infoBox('错误提示', `表达式中有${hintBox.font('循环计算')}!`, 1);
+            analyzer.error = `表达式中有${hintBox.font('循环计算')}!`;
+            // hintBox.infoBox('错误提示', `表达式中有${hintBox.font('循环计算')}!`, 1);
             return false;
             return false;
         };
         };
         if (!testValue(expression)){
         if (!testValue(expression)){
-            hintBox.infoBox('错误提示', `表达式中有${hintBox.font('语法错误')}!`, 1);
+            analyzer.error = `表达式中有${hintBox.font('语法错误')}!`;
+            // hintBox.infoBox('错误提示', `表达式中有${hintBox.font('语法错误')}!`, 1);
             return false;
             return false;
         };
         };
 
 

+ 4 - 0
web/building_saas/main/js/views/calc_base_view.js

@@ -314,6 +314,9 @@ let calcBaseView = {
                                 $.bootstrapLoading.end();
                                 $.bootstrapLoading.end();
                             }
                             }
                         });
                         });
+                    }
+                    else{
+                        $('#errorInfo').html(analyzer.error);
                     };
                     };
                 }
                 }
                 else
                 else
@@ -408,6 +411,7 @@ $(document).ready(function () {
     });
     });
 
 
     $('#qd-jsjs').on('hidden.bs.modal', function () {
     $('#qd-jsjs').on('hidden.bs.modal', function () {
+        $('#errorInfo').text('');
         //清空输入框
         //清空输入框
         calcBaseView.inputExpr.val('');
         calcBaseView.inputExpr.val('');
         calcBaseView.workBook.destroy();
         calcBaseView.workBook.destroy();