问题背景
例如手头有个功能,需要维护一波自定义核算项目,然后再单据的分录中带出这个自定义核算项目。
解决方案
接下来就是代码show time了
protected void storeFieldsBefore() throws Exception {
super.storeFieldsBefore();
//表格工具,辅助输出row的所有cell字段,你才知道怎么去row.getCell("xxxx")
TableUtils.listTableKeys(kdtEntry);
//遍历所有行row
for(int i=0;i<this.kdtEntry.getRowCount();i++)
{
IRow row=kdtEntry.getRow(i);
//获取并转化对应的列cell
MaterialInfo matInfo=(MaterialInfo)row.getCell("materialNumber").getValue();
if(matInfo!=null){
FilterInfo filter = new FilterInfo();
filter.getFilterItems().add(new FilterItemInfo("material.id", matInfo.getId().toString(), CompareType.EQUALS));
SelectorItemCollection sic = super.getSelectors();
sic.remove(new SelectorItemInfo("id"));
sic.add(new SelectorItemInfo("helpSpecifications.id"));
sic.add(new SelectorItemInfo("helpSpecifications.name"));
sic.add(new SelectorItemInfo("helpSpecifications.number"));
EntityViewInfo view = new EntityViewInfo();
view.setFilter(filter);
view.setSelector(sic);
//查询物料的采购信息tab下面的详情
MaterialPurchasingCollection mpList=MaterialPurchasingFactory.getRemoteInstance().getMaterialPurchasingCollection(view);
if(mpList.size()>0){
MaterialPurchasingInfo mpInfo=mpList.get(0);
//找到对应的值,直接赋值给F7/自定义核算项目,前提是dep加了这个字段并且设置为"自定义核算项目"
row.getCell("helpSpecifications").setValue(mpInfo.get("helpSpecifications"));
}
}
}
}