销售出库单脚本

var easNames = JavaImporter();
easNames.importPackage(Packages.com.kingdee.bos.dao.query);
easNames.importPackage(Packages.java.math);
with(easNames){ 
var table = pluginCtx.getKDTable("detailTable");
table.addKDTPropertyChangeListener(function(event,methodName){
 if(methodName == "equals"){
  return event.toString().length()==9;
 }
 if(methodName == "propertyChange"){
   if ((event.getType() == com.kingdee.bos.ctrl.kdf.table.KDTStyleConstants.BODY_ROW)
   && (event.getPropertyName()== "cellValue")){
    var curRow =  table.getRow(event.getRowIndex());
    var colName=table.getColumn(event.getColIndex()).getKey();
          
//计算运费小计   用的系统的数量字段  到时候这个计量单位应该选择的是 吨
         if("householdsName"==colName||"qty"==colName||"Tonfreight"==colName||"Freightadjustment"==colName){
        if(null!=curRow.getCell("householdsName").getValue()){
               var householdsName1 = curRow.getCell("householdsName").getValue().getNumber(); //用户编号
                  var  sql="   select  FADDRESS, CFKDNUMBERTEXTFIELD  from T_BD_Customer where   FNUMBER='"+householdsName1+"' ";
                  var aaaa=SQLExecutorFactory.getRemoteInstance(sql).executeSQL( );
                    var  name="";
                    var adress="";
                      while(aaaa.next()){
                     	 adress=aaaa.getString("FADDRESS");//地址
                     	 dun=aaaa.getString("CFKDNUMBERTEXTFIELD");//吨运费
                     	}
            	     curRow.getCell("Deliveryaddress").setValue(adress); 
            	     curRow.getCell("Tonfreight").setValue(dun); 
              	}
                  	
                      var qty=curRow.getCell("qty").getValue(); //得到数量
//                      com.kingdee.eas.util.client.MsgBox.showInfo(qty);
                      var Tonfreight=curRow.getCell("Tonfreight").getValue(); //得到吨运费
                      var Freightadjustment=curRow.getCell("Freightadjustment").getValue(); //得到运费调整金额
                        if(null==Tonfreight){
                        	  Tonfreight=0;
                        	}
                        	  if(null==Freightadjustment){
                        	  Freightadjustment=0;
                        	}
                        	
                      var Totalfreight=Tonfreight*qty;
                      //先得到运费小计
                     Totalfreight1=new  java.math.BigDecimal(Totalfreight.toString());//运费小计
                     Freightadjustment1=new  java.math.BigDecimal(Freightadjustment.toString());//运费调整金额
                     var Totalfreight2=Totalfreight1.add(Freightadjustment1);
                     curRow.getCell("Totalfreight").setValue(Totalfreight2);  
                  }

  //===================================================================================================
		 		 
               if("basePrice"==colName ){         	
               	var mat = curRow.getCell("materialNum").getValue();                	
               	var lot = curRow.getCell("lot").getValue();
				var unit = curRow.getCell("unit").getValue();
               	
               	if(mat!=null)
               	{         
					var sql=" select FBASECONVSRATE from T_BD_MULTIMEASUREUNIT where FMATERIALID = '"
						+ mat.get("id") +"' and FMEASUREUNITID = '"+ unit.get("id") +"' ";
					var rate = new BigDecimal(0);
					var rs = SQLExecutorFactory.getRemoteInstance(sql).executeSQL( );
					while(rs.next()){
						rate = new BigDecimal( rs.getString("FBASECONVSRATE"));
					}

               		//基本单位含税单价
               		var basePrice = new BigDecimal (curRow.getCell("basePrice").getValue());
	                   	//含税单价

					var taxPrice = new BigDecimal( basePrice * rate);
					curRow.getCell("actualTaxPrice").setValue(taxPrice);
					curRow.getCell("taxPrice").setValue(taxPrice);		
					
               		//数量
               		var qty = new BigDecimal(curRow.getCell("qty").getValue());               		
//               		com.kingdee.eas.util.client.MsgBox.showInfo(qty);

               		if (qty!="0.00")
               		{

						
						//基本数量
	               		var baseQty = new BigDecimal( curRow.getCell("baseQty").getValue());
						//税率
						var taxRate = new BigDecimal(curRow.getCell("taxRate").getValue());
						//价税合计
						var allAmt = new BigDecimal ( basePrice * baseQty );
						//税额
						var taxAmt = new BigDecimal ((allAmt/(1+taxRate))*taxRate); 
						//金额
						var amt = new BigDecimal(allAmt - taxAmt);
						//不含税单价
						var price = new BigDecimal ( amt / qty );		

		                     //含税单价
//						var taxPrice = new BigDecimal(allAmt / qty);
	
//						curRow.getCell("actualTaxPrice").setValue(taxPrice);
//						curRow.getCell("taxPrice").setValue(taxPrice);
						
						curRow.getCell("taxAmount").setValue(allAmt);					
						curRow.getCell("localTaxAmount").setValue(allAmt);
						
						//localAmount amount
						curRow.getCell("localAmount").setValue(amt);
						curRow.getCell("amount").setValue(amt);
	
	 					//localTax tax
						curRow.getCell("localTax").setValue(taxAmt);
						curRow.getCell("tax").setValue(taxAmt);
	
						//price taxPrice actualPrice actualTaxPrice
						curRow.getCell("price").setValue(price);
						curRow.getCell("actualPrice").setValue(price);
					

               		}
 
               	}                 
               }
//=====================================================================================================
              //mz add 2018-01-06 materialNum 
            if("materialNum"==colName){ 
               	  var  Big="";
                  	  var  contractNumber=pluginCtx.getKDTextField("txtkDTextField").getText();
                       if(null==contractNumber||""==contractNumber){
                       	 
                       	}else{
                       		 	   var materialId=curRow.getCell("materialNum").getValue().getId(); //物料的内码
                  	 //根据物料的编码去查看是否是带有大鸭料
                  	  var sql="  select    FMATERIALGROUPID  from     T_BD_MATERIALGROUPDETIAL  where  FMATERIALID ='"+materialId+"'";
                        var bbb=SQLExecutorFactory.getRemoteInstance(sql).executeSQL( );
                        var isBig="";
                  	     while(bbb.next()){
                     	 isBig=bbb.getString("FMATERIALGROUPID");
                   
                     	  //如果包含 内码“10YAAAABfwjHn8BC”  大鸭料的分类标准内码
                     	     if("10YAAAABfwjHn8BC".equals(isBig)){
//                     	     	 com.kingdee.eas.util.client.MsgBox.showInfo("大鸭料10YAAAABfwjHn8BC"+isBig );
                         	var  sql=" select FPRICE_2  from T_DUC_BreedingContract where   FNUMBER='"+contractNumber+"'  " ;
                         	  var bbb=SQLExecutorFactory.getRemoteInstance(sql).executeSQL( );
                         
                  	       while(bbb.next()){
                     	  Big=bbb.getDouble("FPRICE_2");
                     	}
//                     		 com.kingdee.eas.util.client.MsgBox.showInfo("大鸭料价格:"+Big );
                     	  curRow.getCell("price").setValue(new BigDecimal(Big));  
                     	   curRow.getCell("taxPrice").setValue(new BigDecimal(Big));  
//                           选择物料的时候 系统会默认把价格置为0
                     	  	
//                     	  curRow.getCell("Deliveryaddress").setValue(Big);   	
                        } 
                       //如果包含 内码“10YAAAABfwfHn8BC” 小鸭料的分类标准
                       if("10YAAAABfwfHn8BC".equals(isBig)){
//                       	com.kingdee.eas.util.client.MsgBox.showInfo("小鸭料10YAAAABfwfHn8BC"+isBig );
                           	var  sql=" select FPRICE_1  from T_DUC_BreedingContract where   FNUMBER='"+contractNumber+"'  " ;
                         	  var bbb=SQLExecutorFactory.getRemoteInstance(sql).executeSQL( );
                  	       while(bbb.next()){
                     	  Big=bbb.getDouble("FPRICE_1");
                     	}
//                new BigDecimal   com.kingdee.eas.util.client.MsgBox.showInfo("小鸭料价格:"+Big );
                     	 curRow.getCell("price").setValue(new BigDecimal(Big));  
                     	 curRow.getCell("taxPrice").setValue(new BigDecimal(Big));  
                     	} 
                     	
                  	}
                       		
                       		}
   }
 //===================================================================================================
                  if("supplier"==colName){
               var  contractNumber=pluginCtx.getKDTextField("txtkDTextField").getText();
                   if(null==contractNumber||""==contractNumber){
                       	}else{
                   //当前公司的组织内码
                       var company = pluginCtx.getUIContext().get("sysContext").getCurrentCtrlUnit().getId().toString(); 
              	   var materialId=curRow.getCell("materialNum").getValue().getId(); //物料的内码
                    //根据物料编码,供应商编码,业务日期去查出该物料的批次号
                    var  Bizdaate=pluginCtx.getKDDatePicker("dateBizDate").getValue().toString();//业务日期

                      function Todate(num) { //Fri Oct 31 18:00:00 UTC+0800 2008
            num = num + "";
            var date = "";
            var month = new Array();
            month["Jan"] = "01"; month["Feb"] = "02"; month["Mar"] = "03"; month["Apr"] = "04"; month["May"] = "05"; month["Jun"] = "06";
            month["Jul"] = "07"; month["Aug"] ="08"; month["Sep"] = "09"; month["Oct"] = 10; month["Nov"] = 11; month["Dec"] = 12;
            var week = new Array();
            week["Mon"] = "一"; week["Tue"] = "二"; week["Wed"] = "三"; week["Thu"] = "四"; week["Fri"] = "五"; week["Sat"] = "六"; week["Sun"] = "日";
            str = num.split(" ");
            date = str[5].toString();
           date=date.substring(date.length-2);
            date = date+month[str[1]]  + str[2];
            return date;
        }
                   var formatStr=Todate(Bizdaate );  
                  var supplier=curRow.getCell("supplier").getValue().getNumber(); //供应商的内码
                  var flot=supplier+"-"+formatStr;//批号
                
                  var sql11=" select  sum (FCURSTOREQTY) as  FCURSTOREQTY   from T_IM_Inventory   where FCOMPANYORGUNITID='"+company+"'     and  FSTORESTATUSID='181875d5-0105-1000-e000-012ec0a812fd62A73FA5'  and FMATERIALID='"+materialId+"'   and    FLOT='"+flot+"'";
                  //给该物料的批次  数量填充值
                     var FCURSTOREQTYsql=SQLExecutorFactory.getRemoteInstance(sql11).executeSQL( );
                        var  FCURSTOREQTY="";
                  	     while(FCURSTOREQTYsql.next()){
                     	 FCURSTOREQTY=FCURSTOREQTYsql.getDouble("FCURSTOREQTY");
                  	     }
                  curRow.getCell("qty").setValue(new BigDecimal(FCURSTOREQTY));  
                  curRow.getCell("lot").setValue( flot);      
              	}

                 
                   //=============================================================
//               if(null!=curRow.getCell("materialNum").getValue()&&null!=curRow.getCell("lot").getValue()){
//               //销售出库单里的单位采购成本,根据物料,批次确定 
//                 var materialId2=curRow.getCell("materialNum").getValue().getId(); //物料的内码
//               //  var supplier2=curRow.getCell("supplier").getValue().getId(); //供应商的内码
//                 var lot2=curRow.getCell("lot").getValue(); //批次
//                 var sql2=" select      FACTUALCOST ,   FQTY   from   T_IM_PurInWarehsEntry  where FMaterialID='"+materialId2+"'  and  FLot='"+lot2+"'  and  FBaseStatus='2' and Rownum='1' ";//单位采购成本' 
//              //   com.kingdee.eas.util.client.MsgBox.showInfo(sql2+"=======供应商=======");
//                  var FCURSTOREQTYsql2=SQLExecutorFactory.getRemoteInstance(sql2).executeSQL( );
//                  var FACTUALCOST=0;
//                  var FQTY2=0;
//                   	     while(FCURSTOREQTYsql2.next()){
//                     	 FACTUALCOST=FCURSTOREQTYsql2.getDouble("FACTUALCOST");//实际成本
//                     	 FQTY2=FCURSTOREQTYsql2.getDouble("FQTY");//数量
//                  }   
//                    // com.kingdee.eas.util.client.MsgBox.showInfo(FQTY2);
//                    // com.kingdee.eas.util.client.MsgBox.showInfo(FACTUALCOST);
//                     if(FQTY2!=0&&FACTUALCOST!=0&&null!=FACTUALCOST&&null!=FQTY2){
//                   var FACTUALCOST=new java.math.BigDecimal(FACTUALCOST.toString());
//                var  FQTY2=new java.math.BigDecimal(FQTY2.toString());   
//                    //com.kingdee.eas.util.client.MsgBox.showInfo("bb2");
//               var  bb2= FACTUALCOST.divide(FQTY2);
//              // com.kingdee.eas.util.client.MsgBox.showInfo("bb2"+bb2);
//               curRow.getCell("unitActualCost").setValue(bb2); //单位实际成本赋值
//               curRow.getCell("actualCost").setValue(new BigDecimal(bb2*qty)); //实际成本赋值
//                     	} else{
//                curRow.getCell("unitActualCost").setValue(new java.math.BigDecimal(0.000000)); //单位实际成本赋值
//             curRow.getCell("actualCost").setValue(new java.math.BigDecimal(0.000000)); //实际成本赋值
//                     		}
//         
//                }
                   //=========================================================================================
                       		}
                        
                     		
              if("lot"==colName){
              	     var  contractNumber=pluginCtx.getKDTextField("txtkDTextField").getText();
                   if(null==contractNumber||""==contractNumber){
                       	}else{
                  //com.kingdee.eas.util.client.MsgBox.showInfo("触发"+curRow.getCell("lot").getValue());
              if(null!=curRow.getCell("materialNum").getValue()&&null!=curRow.getCell("lot").getValue()){
               //销售出库单里的单位采购成本,根据物料,供应商,批次确定。这三个信息少一个的,就不提取出来。
                 var materialId2=curRow.getCell("materialNum").getValue().getId(); //物料的内码
               //  var supplier2=curRow.getCell("supplier").getValue().getId(); //供应商的内码
                 var lot2=curRow.getCell("lot").getValue(); //批次
                 var sql2=" select      FACTUALCOST ,   FQTY   from   T_IM_PurInWarehsEntry  where FMaterialID='"+materialId2+"'  and  FLot='"+lot2+"'   and  FBaseStatus='2' and Rownum='1' ";//单位采购成本' 
               // com.kingdee.eas.util.client.MsgBox.showInfo(sql2);
                  var FCURSTOREQTYsql2=SQLExecutorFactory.getRemoteInstance(sql2).executeSQL( );
                  var FACTUALCOST=0;
                  var FQTY2=0;
                   	     while(FCURSTOREQTYsql2.next()){
                     	 FACTUALCOST=FCURSTOREQTYsql2.getDouble("FACTUALCOST");//实际成本
                     	 FQTY2=FCURSTOREQTYsql2.getDouble("FQTY");//数量
                  }   
                    // com.kingdee.eas.util.client.MsgBox.showInfo(FQTY2);
                    // com.kingdee.eas.util.client.MsgBox.showInfo(FACTUALCOST);
                     if(FQTY2!=0&&FACTUALCOST!=0&&null!=FACTUALCOST&&null!=FQTY2){
                   var FACTUALCOST=new java.math.BigDecimal(FACTUALCOST.toString());
                var  FQTY2=new java.math.BigDecimal(FQTY2.toString());   
                    //com.kingdee.eas.util.client.MsgBox.showInfo("bb2");
               var  bb2= FACTUALCOST.divide(FQTY2);
              // com.kingdee.eas.util.client.MsgBox.showInfo("bb2"+bb2);
               curRow.getCell("unitActualCost").setValue(bb2); //单位实际成本赋值
               var qty=curRow.getCell("qty").getValue();//分录里面的数量
               curRow.getCell("actualCost").setValue(new BigDecimal(bb2*qty)); //实际成本赋值
                     	}else{
                curRow.getCell("unitActualCost").setValue(new java.math.BigDecimal(0.000000)); //单位实际成本赋值
             curRow.getCell("actualCost").setValue(new java.math.BigDecimal(0.000000)); //实际成本赋值
                     		}
         
                }
            
                       		}
              	
              	}              		    	
   }
 }
});
//====================================================================================================
//下推销售出库单时计算 根据养殖户得到吨运费, 拿到数量 ,计算运费
  if ( pluginCtx.getOprtState()=="EDIT" ){
     var table = pluginCtx.getKDTable("detailTable");
	var rowCount = table.getRowCount();
	for(var i=0;i<rowCount;i++){
		if(null!=table.getCell(i,"householdsName").getValue()){
			     var householdsName1=table.getCell(i,"householdsName").getValue().getNumber(); //用户编号
	 var  sql="   select  FADDRESS, CFKDNUMBERTEXTFIELD  from T_BD_Customer where   FNUMBER='"+householdsName1+"' ";
                  var aaaa=SQLExecutorFactory.getRemoteInstance(sql).executeSQL( );
                    var  name="";
                    var adress="";
                      while(aaaa.next()){
                     	 adress=aaaa.getString("FADDRESS");//地址
                     	 dun=aaaa.getString("CFKDNUMBERTEXTFIELD");//吨运费
                     	}
            	     table.getCell(i,"Deliveryaddress").setValue(adress); 
            	     table.getCell(i,"Tonfreight").setValue(dun); 
                     var qty=table.getCell(i,"qty").getValue(); //得到数量
//                      com.kingdee.eas.util.client.MsgBox.showInfo(adress);
                      var Tonfreight=table.getCell(i,"Tonfreight").getValue(); //得到吨运费
                     var Freightadjustment=table.getCell(i,"Freightadjustment").getValue(); //得到运费调整金额
                        if(null==Tonfreight){
                        	  Tonfreight=0;
                        	}
                        	  if(null==Freightadjustment){
                        	  Freightadjustment=0;
                        	}
                      var Totalfreight=Tonfreight*qty;
                    //先得到运费小计
                     Totalfreight1=new  java.math.BigDecimal(Totalfreight.toString());//运费小计
                     Freightadjustment1=new  java.math.BigDecimal(Freightadjustment.toString());//运费调整金额
                     var Totalfreight2=Totalfreight1.add(Freightadjustment1);
                      table.getCell(i,"Totalfreight").setValue(Totalfreight2);  
			}
 
		}	

 //===============================下推时根据客户带出  销售人员  销售组(岗位)====================================
 


        //获取送货客户的值;
          //F7控件增加值改变监听   pluginCtx.getKDBizPromptBox("prmtperson");
          //选出客户字段直接带出
 
          var org = pluginCtx.getUIContext().get("sysContext").getCurrentCtrlUnit();//获取当前CU
          var ordId=org.get("Id");
 var customerId =  pluginCtx.getKDBizPromptBox("prmtCustomer").getValue().getId();
     // var bizOrgUnit =  pluginCtx.getKDBizPromptBox("prmtCustomer").getValue().getNumber();
//地址, 电话,收货人,省份id
         var sql="    select   FMOBILE     from  T_BD_CustomerLinkMan     where  FCUSTOMERSALEID  =(select  fid    from  T_BD_CustomerSaleInfo where  FSALEORGID ='" + ordId + "'  and  FCUSTOMERID ='" +customerId+ "' ) ";  
                 var result666=SQLExecutorFactory.getRemoteInstance(sql).executeSQL( );  
                      while(result666.next()){
                           var CFKDTEXTFIELD=result666.getString("FMOBILE");   
                           }    
                      
                              if(CFKDTEXTFIELD==undefined){
                              CFKDTEXTFIELD="";
                            	}  
          pluginCtx.getKDTextField("txtkehudianhua").setText(CFKDTEXTFIELD);   //电话    ;
         //==根据客户监听带出 客户销售页签里面的销售员,再根据销售员带出岗位
          
       var sqlemp="  select fid from T_BD_Person where fid =(    select   FPERSONID  from  T_BD_CustomerSaler   where  FCUSTOMERSALEID  =(select  fid    from  T_BD_CustomerSaleInfo where  FSALEORGID ='" + ordId + "'  and  FCUSTOMERID ='" +customerId+ "' ))  ";
    //  com.kingdee.eas.util.client.MsgBox.showInfo(sqlemp);
        var resultemp=SQLExecutorFactory.getRemoteInstance(sqlemp).executeSQL( );  
       
                     var fid="";
                            var  prmtemp=pluginCtx.getKDBizPromptBox("prmtemp");
                              prmtemp.setValue(null);//先清空再赋值
                               var  prmtsaleDuty=pluginCtx.getKDBizPromptBox("prmtsaleDuty");   
                               prmtsaleDuty.setValue(null);
                      while(resultemp.next()){
                            fid=resultemp.getString("fid"); 
                          
           	            var pk = new com.kingdee.bos.dao.ormapping.ObjectUuidPK(fid);
                           var pro= com.kingdee.eas.basedata.person.PersonFactory.getRemoteInstance();
                          prmtemp.setValue(pro.getValue(pk));  
                           }    
                          
                   
                     
           //根据销售员带出岗位
                   var  sqldept=" select a.FID as fempid, c.FID as fposid, d.FID as fdeptid, d.FControlUnitID as fcompid from T_BD_Person a left join  T_ORG_PositionMember b on a.FID = b.FPersonID  left join T_ORG_Position c on b.FPositionID = c.FID  left join T_ORG_Admin d on c.FAdminOrgUnitID = d.FID  left join T_PM_User e on a.FID = e.FPersonId   where   a.fid ='"+fid+"'   and   b.FISPRIMARY=1  "         	
                 var fposid="";
                    var resultdept=SQLExecutorFactory.getRemoteInstance(sqldept).executeSQL( );  
                      while(resultdept.next()){
                            fposid=resultdept.getString("fposid"); 
                           var  prmtsaleDuty=pluginCtx.getKDBizPromptBox("prmtsaleDuty");   
           	            var pk = new com.kingdee.bos.dao.ormapping.ObjectUuidPK(fposid);      
                           var pro= com.kingdee.eas.basedata.org.PositionFactory.getRemoteInstance();
                           prmtsaleDuty.setValue(pro.getValue(pk));  
                           }    
                          
                         
                           
    

//=============================================================================================================================================

 



		
  }
//====================================================================================	    
   
    
        //获取送货客户的值;
          //F7控件增加值改变监听   pluginCtx.getKDBizPromptBox("prmtperson");
          //选出客户字段直接带出
       pluginCtx.getKDBizPromptBox("prmtCustomer").addDataChangeListener(function (event,methodName)
         {  
         	if("equals"== methodName){
         		return this==event;
         		}
         	else if("dataChanged"==methodName) {
          var org = pluginCtx.getUIContext().get("sysContext").getCurrentCtrlUnit();//获取当前CU
          var ordId=org.get("Id");
//  
 var customerId =  pluginCtx.getKDBizPromptBox("prmtCustomer").getValue().getId();
     // var bizOrgUnit =  pluginCtx.getKDBizPromptBox("prmtCustomer").getValue().getNumber();
//地址, 电话,收货人,省份id
         var sql="    select   FMOBILE     from  T_BD_CustomerLinkMan     where  FCUSTOMERSALEID  =(select  fid    from  T_BD_CustomerSaleInfo where  FSALEORGID ='" + ordId + "'  and  FCUSTOMERID ='" +customerId+ "' ) ";  
                 var result666=SQLExecutorFactory.getRemoteInstance(sql).executeSQL( );  
                      while(result666.next()){
                           var CFKDTEXTFIELD=result666.getString("FMOBILE");   
                           }    
                      
                              if(CFKDTEXTFIELD==undefined){
                              CFKDTEXTFIELD="";
                            	}  
          pluginCtx.getKDTextField("txtkehudianhua").setText(CFKDTEXTFIELD);   //电话    ;
         //==根据客户监听带出 客户销售页签里面的销售员,再根据销售员带出岗位
       var sqlemp="  select fid from T_BD_Person where fid =(    select   FPERSONID  from  T_BD_CustomerSaler   where  FCUSTOMERSALEID  =(select  fid    from  T_BD_CustomerSaleInfo where  FSALEORGID ='" + ordId + "'  and  FCUSTOMERID ='" +customerId+ "' ))  ";
    //  com.kingdee.eas.util.client.MsgBox.showInfo(sqlemp);
        var resultemp=SQLExecutorFactory.getRemoteInstance(sqlemp).executeSQL( );  
       
                     var fid="";
                            var  prmtemp=pluginCtx.getKDBizPromptBox("prmtemp");
                              prmtemp.setValue(null);//先清空再赋值
                               var  prmtsaleDuty=pluginCtx.getKDBizPromptBox("prmtsaleDuty");   
                               prmtsaleDuty.setValue(null);
                      while(resultemp.next()){
                            fid=resultemp.getString("fid"); 
                          
           	            var pk = new com.kingdee.bos.dao.ormapping.ObjectUuidPK(fid);
                           var pro= com.kingdee.eas.basedata.person.PersonFactory.getRemoteInstance();
                          prmtemp.setValue(pro.getValue(pk));  
                           }                                        
         			}
                         
           });

         //根据销售员监听带出岗位
            pluginCtx.getKDBizPromptBox("prmtemp").addDataChangeListener(function (event,methodName){
  	     if("equals"== methodName){
         		return this==event;
         		}
         	else if("dataChanged"==methodName) {
         		var fid=pluginCtx.getKDBizPromptBox("prmtemp").getValue().getId();
               var  sqldept=" select a.FID as fempid, c.FID as fposid, d.FID as fdeptid, d.FControlUnitID as fcompid from T_BD_Person a left join  T_ORG_PositionMember b on a.FID = b.FPersonID  left join T_ORG_Position c on b.FPositionID = c.FID  left join T_ORG_Admin d on c.FAdminOrgUnitID = d.FID  left join T_PM_User e on a.FID = e.FPersonId   where   a.fid ='"+fid+"'   and   b.FISPRIMARY=1  "         	
                 var fposid="";
                    var resultdept=SQLExecutorFactory.getRemoteInstance(sqldept).executeSQL( );  
                      while(resultdept.next()){
                            fposid=resultdept.getString("fposid"); 
                           var  prmtsaleDuty=pluginCtx.getKDBizPromptBox("prmtsaleDuty");   
           	            var pk = new com.kingdee.bos.dao.ormapping.ObjectUuidPK(fposid);      
                           var pro= com.kingdee.eas.basedata.org.PositionFactory.getRemoteInstance();
                           prmtsaleDuty.setValue(pro.getValue(pk));  
                           }    
         	}
            	});
       







           

//=============================================================================================================================================
     


       if(null!=pluginCtx.getKDBizPromptBox("prmtCFDRIVER")){
   pluginCtx.getKDBizPromptBox("prmtCFDRIVER").addDataChangeListener(function(e,methodName){
   	if("equals"==methodName){
   		 return this==e;
   		}else if("dataChanged"==methodName){
   		       var driverNumber= pluginCtx.getKDBizPromptBox("prmtCFDRIVER").getValue().getNumber();
   		  
   			var  sql="  select  CFTEAMLEADER ,CFCarNo  from CT_DUC_CarInfomation where  FNUMBER ='"+driverNumber+"' ";
   			  var  name="";
   			  var carno="";
   			  var aaaa=SQLExecutorFactory.getRemoteInstance(sql).executeSQL( );
   			       while(aaaa.next()){
                     	 name=aaaa.getString("CFTEAMLEADER");//
                     	 carno=aaaa.getString("CFCarNo");//
                     	}
                     	 
                   pluginCtx.getKDTextField("txtkDTextField1").setText(name);
                   pluginCtx.getKDTextField("txtkDTextField2").setText(carno);
   			}
});
          	}






}
 

 

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值