Browse Source

1. 合同支付,表达式框复制粘贴时,过滤空格、回车换行符等
2. 合同支付,表达式框,编辑本期金额表达式后,提交表达式时,检查表达式是否合法

MaiXinRong 5 years ago
parent
commit
8b1f1547ec
2 changed files with 17 additions and 3 deletions
  1. 16 2
      app/public/js/stage_pay.js
  2. 1 1
      app/view/stage/pay.ejs

+ 16 - 2
app/public/js/stage_pay.js

@@ -848,7 +848,13 @@ $(document).ready(() => {
             const data = {};
             if (field === 'expr') {
                 data.type = 'stage';
-                data.updateData = { pid: select.pid, tp: null, expr: newValue }
+                data.updateData = { pid: select.pid, tp: null, expr: newValue };
+                const [valid, msg] = paySpreadObj._checkSExpr(select, newValue, data.updateData);
+                if (!valid) {
+                    toastr.warning(msg);
+                    this.value = select.expr;
+                    return;
+                }
             } else if (field === 'sexpr') {
                 data.type = 'info';
                 data.updateData = {id: select.pid};
@@ -876,7 +882,10 @@ $(document).ready(() => {
                 loadUpdateDealPays(result);
                 SpreadJsObj.reLoadSheetData(paySpread.getActiveSheet());
             });
-        })
+        });
+        // $('#expr').bind('onpaste', function (e) {
+        //     console.log(e);
+        // });
     }
 
     const deadlineObj = {
@@ -1186,3 +1195,8 @@ $(document).ready(() => {
         });
     })
 });
+const pasteExpr = function (e, obj) {
+    const text = e.clipboardData.getData('text');
+    e.preventDefault();
+    obj.value = obj.value + trimInvalidChar(_.trim(text));
+};

+ 1 - 1
app/view/stage/pay.ejs

@@ -15,7 +15,7 @@
                         <div class="input-group-prepend">
                             <span class="input-group-text" id="basic-addon1">表达式</span>
                         </div>
-                        <input type="text" class="form-control m-0" <% if (stage.readOnly) { %> readonly="" <% } %> id="expr">
+                        <input type="text" class="form-control m-0" <% if (stage.readOnly) { %> readonly="" <% } %> id="expr" onpaste="pasteExpr(event, this);">
                     </div>
                 </div>
             </div>