var easImporter = JavaImporter();
easImporter.importPackage(Packages.com.kingdee.bos.dao.query);
easImporter.importPackage(Packages.com.kingdee.bos.ctrl.extendcontrols);
easImporter.importPackage(Packages.com.kingdee.bos.metadata.entity);
easImporter.importPackage(Packages.com.kingdee.bos.metadata.query.util);
easImporter.importPackage(Packages.com.kingdee.bos.util);
with(easImporter){
// var prmtDept = pluginCtx.getKDBizPromptBox("prmtperson");//获取F7 pluginCtx.getKDBizPromptBox("prmtperson");
// var filterInfo = new FilterInfo();
// var entityViewInfo = new EntityViewInfo();
// var org = pluginCtx.getUIContext().get("sysContext").getCurrentCtrlUnit();//获取当前CU
com.kingdee.eas.util.client.MsgBox.showInfo(org.get("Id"));
// filterInfo.getFilterItems().add(new FilterItemInfo("CU.id",org.get("Id"),CompareType.EQUALS));//按CU过滤
// entityViewInfo.setFilter(filterInfo);
// prmtDept.setEntityViewInfo(entityViewInfo);
// pluginCtx.getKDBizPromptBox("prmtperson");
//由订单下推的时候带出省份 地址 电话
if (pluginCtx.getOprtState() == "ADDNEW" || pluginCtx.getOprtState()=="EDIT" ){
if(null!=pluginCtx.getKDBizPromptBox("prmtCustomer").getValue()){
var customerId = pluginCtx.getKDBizPromptBox("prmtCustomer").getValue().getId();
var bizOrgUnit = pluginCtx.getKDBizPromptBox("prmtCustomer").getValue().getNumber();
//地址, 电话,收货人,省份id
var sql=" select top 1 CFKDTEXTFIELD,CFKDTEXTFIELD2,CFKDTEXTFIELD1,CFPRMTPROVICEID from T_IM_SaleIssueBill where FCUSTOMERID='"+customerId+"' order by FCREATETIME desc ";
var result666=SQLExecutorFactory.getRemoteInstance(sql).executeSQL( );
while(result666.next()){
var CFKDTEXTFIELD=result666.getString("CFKDTEXTFIELD");
var CFKDTEXTFIELD2=result666.getString("CFKDTEXTFIELD2");
var CFKDTEXTFIELD1=result666.getString("CFKDTEXTFIELD1");
var CFPRMTPROVICEID=result666.getString("CFPRMTPROVICEID");
}
if(CFKDTEXTFIELD==undefined){
CFKDTEXTFIELD="";
}
if(CFKDTEXTFIELD2==undefined){
CFKDTEXTFIELD2="";
}
if(CFKDTEXTFIELD1==undefined){
CFKDTEXTFIELD1="";
}
if(CFPRMTPROVICEID==undefined){
CFPRMTPROVICEID="";
}
sql4="select FID, FName_L2,FNumber from T_BD_Province where fid = ( select FProvince from T_BD_Customer where FID =(select fid from T_BD_Customer where FNumber='"+bizOrgUnit+"'))";
var result7=SQLExecutorFactory.getRemoteInstance(sql4).executeSQL( );
while(result7.next()){
var FID=result7.getString("FID") ;
}
if(FID==undefined){
FID="";
}
pluginCtx.getKDTextField("txtkDTextField").setText(CFKDTEXTFIELD); //地址
pluginCtx.getKDTextField("txtkDTextField2").setText(CFKDTEXTFIELD2); //电话
pluginCtx.getKDTextField("txtkDTextField1").setText(CFKDTEXTFIELD1); //收货人
var prmtprovice=pluginCtx.getKDBizPromptBox("prmtprmtprovice");
var pk = new com.kingdee.bos.dao.ormapping.ObjectUuidPK(FID);
var pro=com.kingdee.eas.basedata.assistant.ProvinceFactory.getRemoteInstance();
prmtprovice.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();
// var sql= " select top 1 FContactPerson from T_BD_CustomerLinkMan where FCUSTOMERSALEID in( select FID from T_BD_CustomerSaleInfo where FControlUnitID ='"+ordId+"' and FCustomerID=( select FID from T_BD_CUSTOMER where FNumber='"+bizOrgUnit+"' ) ) order by FContactPerson ";
// var result=SQLExecutorFactory.getRemoteInstance(sql).executeSQL( );
//
// while(result.next()){
// var result2=result.getString("FContactPerson")
// }
com.kingdee.eas.util.client.MsgBox.showInfo( result2);
// if(result2==undefined){
// result2="";
// }
// pluginCtx.getKDTextField("txtkDTextField1").setText(result2);
//
// //根据客户编码带出地址
// var sql2= " select top 1 FADDRESS_L1 from T_BD_CustomerDlvAddress where FCUSTOMERSALEINFOID in( select FID from T_BD_CustomerSaleInfo where FControlUnitID ='"+ordId+"' and FCustomerID=( select FID from T_BD_CUSTOMER where FNumber='"+bizOrgUnit+"' ) ) order by FADDRESS_L1 ";
// var result4=SQLExecutorFactory.getRemoteInstance(sql2).executeSQL( );
// while(result4.next()){
// var result5=result4.getString("FADDRESS_L1")
// }
// if(result5==undefined){
// result5="";
// }
// pluginCtx.getKDTextField("txtkDTextField").setText(result5);
//
// //根据客户编码带出电话
// var sql3= " select top 1 FPHONE from T_BD_CustomerLinkMan where FCUSTOMERSALEID in( select FID from T_BD_CustomerSaleInfo where FControlUnitID ='"+ordId+"' and FCustomerID=( select FID from T_BD_CUSTOMER where FNumber='"+bizOrgUnit+"' ) ) order by FPHONE ";
// var result6=SQLExecutorFactory.getRemoteInstance(sql3).executeSQL( );
// while(result6.next()){
// var result7=result6.getString("FPHONE")
com.kingdee.eas.util.client.MsgBox.showInfo(result7);
// }
// if(result7==undefined){
// result7="";
// }
// pluginCtx.getKDTextField("txtkDTextField2").setText(result7);
//根据客户带出省份字段
// sql4="select FID, FName_L2,FNumber from T_BD_Province where fid = ( select FProvince from T_BD_Customer where FID =(select fid from T_BD_Customer where FNumber='"+bizOrgUnit+"'))";
// var result7=SQLExecutorFactory.getRemoteInstance(sql4).executeSQL( );
// while(result7.next()){
// var result8=result7.getString("FName_L2");
// var FID=result7.getString("FID") ;
// var FNumber=result7.getString("FNumber") ;
// }
// if(result8==undefined){
// result8="";
// }
// if(FID==undefined){
// FID="";
// }
// if(FNumber==undefined){
// FNumber="";
// }
//地址, 电话,收货人,省份id
var sql=" select top 1 CFKDTEXTFIELD,CFKDTEXTFIELD2,CFKDTEXTFIELD1,CFPRMTPROVICEID from T_IM_SaleIssueBill where FCUSTOMERID='"+customerId+"' order by FCREATETIME desc ";
var result666=SQLExecutorFactory.getRemoteInstance(sql).executeSQL( );
while(result666.next()){
var CFKDTEXTFIELD=result666.getString("CFKDTEXTFIELD");
var CFKDTEXTFIELD2=result666.getString("CFKDTEXTFIELD2");
var CFKDTEXTFIELD1=result666.getString("CFKDTEXTFIELD1");
var CFPRMTPROVICEID=result666.getString("CFPRMTPROVICEID");
}
if(CFKDTEXTFIELD==undefined){
CFKDTEXTFIELD="";
}
if(CFKDTEXTFIELD2==undefined){
CFKDTEXTFIELD2="";
}
if(CFKDTEXTFIELD1==undefined){
CFKDTEXTFIELD1="";
}
if(CFPRMTPROVICEID==undefined){
CFPRMTPROVICEID="";
}
sql4="select FID, FName_L2,FNumber from T_BD_Province where fid = ( select FProvince from T_BD_Customer where FID =(select fid from T_BD_Customer where FNumber='"+bizOrgUnit+"'))";
var result7=SQLExecutorFactory.getRemoteInstance(sql4).executeSQL( );
while(result7.next()){
var FID=result7.getString("FID") ;
}
if(FID==undefined){
FID="";
}
pluginCtx.getKDTextField("txtkDTextField").setText(CFKDTEXTFIELD); //地址
pluginCtx.getKDTextField("txtkDTextField2").setText(CFKDTEXTFIELD2); //电话
pluginCtx.getKDTextField("txtkDTextField1").setText(CFKDTEXTFIELD1); //收货人
var prmtprovice=pluginCtx.getKDBizPromptBox("prmtprmtprovice");
var pk = new com.kingdee.bos.dao.ormapping.ObjectUuidPK(FID);
var pro=com.kingdee.eas.basedata.assistant.ProvinceFactory.getRemoteInstance();
prmtprovice.setValue(pro.getValue(pk));
}
});
var setPurchaseGroupF7Funcation = function(event,methodName){
if(methodName == "equals"){ return this == event;}
var kdtEntrys = pluginCtx.getKDTable("detailTable");
var rowIndex = kdtEntrys.getSelectManager().getActiveRowIndex();
var colIndex = kdtEntrys.getSelectManager().getActiveColumnIndex();
if (rowIndex < 0) { return; }
if(methodName == "editStarting"){
if (kdtEntrys.getColumn("hesuan").getColumnIndex() == colIndex) {
var purchaseOrgUnitId = "null";
var company = pluginCtx.getUIContext().get("sysContext").getCurrentFIUnit();
if (company !=null){
purchaseOrgUnitId = company.getId().toString();}
//com.kingdee.eas.util.client.MsgBox.showInfo(purchaseOrgUnitId);
//F7的过滤条件
var viewInfo = new com.kingdee.bos.metadata.entity.EntityViewInfo();
var filterInfo = new com.kingdee.bos.metadata.entity.FilterInfo();
filterInfo.getFilterItems().add(new FilterItemInfo("id"," select FID from T_BD_GeneralAsstActType where FGroupID='5uUAAAAAMVsF0s0M'",CompareType.INNER));
// filterInfo.appendFilterItem("CU.id", purchaseOrgUnitId);
viewInfo.setFilter(filterInfo);
var bizBox = pluginCtx.getKDTable("detailTable").getColumn("hesuan").getEditor().getComponent();
bizBox.setEntityViewInfo(viewInfo);
bizBox.getQueryAgent().resetRuntimeEntityView(); }
}
};
pluginCtx.getKDTable("detailTable").addKDTEditListener(setPurchaseGroupF7Funcation);
//分录的监听事件===========pluginCtx.getKDTable("detailTable");
//============================================================================
var table = pluginCtx.getKDTable("detailTable");
table.addKDTPropertyChangeListener(function(event,methodName){
if(methodName == "equals"){
return this ==event;
}
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("exp"==colName){
// com.kingdee.eas.util.client.MsgBox.showInfo(11111111);
// var exp= curRow.getCell("exp").getValue();
// Calendar calendar = java.util.Calendar.getInstance();
// calendar.setTime(new SimpleDateFormat("yyyy-MM-dd").parse(exp));
// var new java.sql.Timestamp(exp);
// pluginCtx.getKDDatePicker("dateCreateTime");
// com.kingdee.eas.util.client.MsgBox.showInfo(calendar);
}
}
}
});
}