Purchase Payment Application 2.0

<script type="text/javascript">
        WfForm.bindFieldChangeEvent("field8083,field8084", function(obj,id,value){//主表字段变化时提醒
            mainCheck();
            
        });
        WfForm.bindDetailFieldChangeEvent("field8095",function(id,rowIndex,value){//明细字段变化时提醒
            detailCheck();
        });        
        
      WfForm.registerCheckEvent(WfForm.OPER_SAVE+","+WfForm.OPER_SUBMIT,function(callback){//提交或保存时提醒
          if(mainCheck()==1 && detailCheck()==1){
              callback();
          }else{
              return
          }
        });
        //callback();    
        function mainCheck(){//校验主表字段
            var bankName = WfForm.getFieldValue("field8083");//银行名称
            var bankAcct = WfForm.getFieldValue("field8084");//银行账户号码
            if(bankName.length < 5){
                WfForm.showConfirm("The bank name of this Supplier is incomplete, the payment will be impacted, please contact Purchase department!"+"<br/>"+"您所选供应商的银行名称不完整,将会影响财务付款,所以系统阻止您提交,请联系采购部门!");
            }else if(bankAcct.length < 6){
                WfForm.showConfirm("The bank account of this Supplier is incomplete, the payment will be impacted, please contact Purchase department!"+"<br/>"+"您所选供应商的银行账户不完整,将会影响财务付款,所以系统阻止您提交,请联系采购部门!");
                return false;
            }else{
              return true;
            }
        }
        
        
        
        function detailCheck(){//校验明细表字段
            var rowArr = WfForm.getDetailAllRowIndexStr("detail_1").split(",");//
            var Arr1 = []; 
          var x=0;
          var Arr2 = [];
          var y=0;
                for(var i=0 ; i<rowArr.length ; i++){
                    var rowIndex = rowArr[i];                    
                    if(rowIndex !== ""){
            var rowNum = WfForm.getDetailRowSerailNum("detail_1", rowIndex);    //获取明细1下标为rowIndex的行序号
            var v1 = rmoney(WfForm.getFieldValue("field8095_"+rowIndex));
            var v2 = rmoney(WfForm.getFieldValue("field8088_"+rowIndex));
            var v4 = WfForm.getFieldValue("field8577_"+rowIndex);
                        if(v1/v2<-0.1&&v4==1){
              Arr1[x]=rowNum;
              x++;
                          WfForm.changeFieldAttr("field8061", 3);
                        }
                             //WfForm.showConfirm("The payment amount of material line "+Arr1+" exceeds the amount of the PR by 10%, please describe the change quantity and price between PR and actual invoice, this PR will go to plant manager for sepcial approval!"+"<br/>"+"原材料明细行第"+Arr1+"行的累计付款金额已超出采购申请单总金额10%,请在备注中详细描述数量及单价变化,此付款将流转倒工厂经理特批!");
                        if(v1<0&&v4!=1) {
                          Arr2[y]=rowNum;
              y++;
                             //WfForm.showConfirm("The payment amount of line "+rowNum+" exceeds the total amount of the PR, please add a additional PR!"+"<br/>"+"明细行第"+rowNum+"行的累计付款金额已超出采购申请单总金额,请补填PR!");
                             //return false;
                        }
                    }
                }
                  if(Arr1.length>0){
                    //alert(Arr1)
                    console.log('不合规行号:'+Arr1);
            //WfForm.showConfirm("The payment amount of material in line "+Arr1+" exceeds the amount of the PR by 10%, please describe the change quantity and price between PR and actual invoice, this PR will go to plant manager for sepcial approval!"+"<br/>"+"原材料明细行第"+Arr1+"行的累计付款金额已超出采购申请单总金额10%,请在备注中详细描述数量及单价变化,此付款将流转倒工厂经理特批!");
                    alert("The payment amount of material in line "+Arr1+" exceeds the amount of the PR by 10%, please describe the change quantity and price between PR and actual invoice, this PR will go to plant manager for sepcial approval!"+"\n"+"原材料明细行第"+Arr1+"行的累计付款金额已超出采购申请单总金额10%,请在备注中详细描述数量及单价变化,此付款将流转倒工厂经理特批!")
                    WfForm.changeFieldValue("field9239", {value:"The payment amount of material line "+Arr1+" exceeds the amount of the PR by 10%, please double check!"});
                    WfForm.changeFieldValue("field9241", {value:1});
                    return true
                  }else{
                    WfForm.changeFieldValue("field9241", {value:0});
                  }
                  
                  if(Arr2.length>0){
                    //alert(Arr2)
                    console.log('不合规行号:'+Arr2);
                  WfForm.showConfirm("The payment amount of line "+Arr2+" exceeds the total amount of the PR, please add a additional PR!"+"<br/>"+"明细行第"+Arr2+"行的累计付款金额已超出采购申请单总金额,请补填PR!");
                    //WfForm.changeFieldValue("field9239", {value:"The payment amount of line "+Arr2+" exceeds the total amount of the PR!"});
                    //WfForm.changeFieldValue("field9241", {value:1});
                    return false
                  }else{
                    WfForm.changeFieldValue("field9239", {value:""});
                    WfForm.changeFieldValue("field9241", {value:0});
                  }
        }
        //金额千分位转换为浮点数
        function rmoney(s) {
              s = s.toString();
              return parseFloat(s.replace(/[^\d\.-]/g, ""));
            }
            
</script>

 

posted @ 2022-07-13 10:01  巴拉拉没多少能量  阅读(218)  评论(0编辑  收藏  举报