业务场景:打开新页面,并在新页面填充数据。
可以在新页面的onLoad方法中获取前一页面提供的参数,然后解析当前页面的表格,填充数据。
/**
* 加载界面时,填充拆分明细数据
*/
@Override
public void onLoad() throws Exception {
super.onLoad();
setUITitle("拆分明细");
SplitBillInfo billModel = (SplitBillInfo) getUIContext().get("billModel");
fillData(billModel); //填充数据
}
/**
* 填充界面数据
*/
private void fillData(SplitBillInfo billModel) {
tblMain.checkParsed(); //重新解析表格
SplitBillEntryCollection entrys = billModel.getEntrys(); //分录集合
if(entrys == null || entrys.isEmpty()) return;
for(int i = 0; i < entrys.size(); i++){
SplitBillEntryInfo entry = entrys.get(i); //分录对象
SplitBillEntryDEntryCollection details = entry.getDEntrys(); //子分录集合
for(int j = 0; j < details.size(); j++){
IRow row = tblMain.addRow();
SplitBillEntryDEntryInfo detail = details.get(j); //子分录对象
AccountViewInfo account = detail.getAccount();
row.getCell("account").setValue(account.getNumber() + "," + account.getName()); //报账科目
row.getCell("costOrg").setValue(detail.getCostOrg().getName()); //费用承担部门
row.getCell("amount").setValue(detail.getAmount()); //报账金额
row.getCell("orgUnit").setValue(detail.getOrgUnit().getName()); //下辖机构
row.getCell("splitAmount").setValue(detail.getSplitAmount()); //拆分金额
row.getCell("remark").setValue(detail.getRemark()); //备注
}
}
// 添加合计
IRow footRow = tblMain.addRow();
footRow.getCell("account").setValue("合计");
footRow.getCell("splitAmount").setValue(billModel.getTotal()); //拆分金额合计
footRow.getStyleAttributes().setBold(true);
}
前一页面,打开新页面,传递参数对应的代码:
/**
* 拆分明细查看
*/
@SuppressWarnings("unchecked")
@Override
public void actionDetail_actionPerformed(ActionEvent e) throws Exception {
List ids = getSelectedIdValues();
if(ids == null || ids.isEmpty()){
MsgBox.showInfo(this, "请选择记录行!");
abort();
}
String billId = (String) ids.get(0);
EntityViewInfo view = new EntityViewInfo();
SelectorItemCollection selector = new SelectorItemCollection();
selector.add(new SelectorItemInfo("*"));
selector.add(new SelectorItemInfo("entrys.DEntrys.*"));
selector.add(new SelectorItemInfo("entrys.DEntrys.account.number"));
selector.add(new SelectorItemInfo("entrys.DEntrys.account.name"));
selector.add(new SelectorItemInfo("entrys.DEntrys.costOrg.name"));
selector.add(new SelectorItemInfo("entrys.DEntrys.orgUnit.name"));
FilterInfo filter = new FilterInfo();
filter.getFilterItems().add(new FilterItemInfo("id", billId));
view.setSelector(selector);
view.setFilter(filter);
ISplitBill service = SplitBillFactory.getRemoteInstance();
SplitBillCollection coll = service.getSplitBillCollection(view);
UIContext uiContext = new UIContext(ui); //上下文
uiContext.put("billModel", coll.get(0));
IUIWindow win = null;
String uiFactoryName = UIFactoryName.NEWWIN; //NEWWIN时打开新窗口
String className = SplitBillDetailUI.class.getName(); //UI界面对应的类名,如:DemoListUI.class.getName()
win = UIFactory.createUIFactory(uiFactoryName).create(className, uiContext);
win.show();
}