用友nc65 uap开发参照多选后显示问题解决
前面一篇博客中已经提到了参照面板选中多个,但是选中多个后无法在显示在面板上。此时我们应该对其做些处理。主要思路是拿到参照面板的主键,用逗号隔开保存到数据库,显示的时候用逗号分割取出来。
1.保存到数据库时用逗号隔开
SplitPact[] splitVos = (SplitPact[]) vo.getChildren(SplitPact.class);
if (splitVos != null && splitVos.length > 0) {
String houseTemp = "";
String strTemp1 = "";
for (int i = 0; i<splitVos.length; i++) {
if(!strTemp1.equals((String)splitVos[i].getPk_house()))
houseTemp = houseTemp+(String)splitVos[i].getPk_house()+",";
strTemp1 = (String)splitVos[i].getPk_house();
}
houseTemp = houseTemp.substring(0, houseTemp.length()-1);
// 将用逗号隔开的数据保存到房产字段
bill.setAttributeValue("pk_allhouses", houseTemp);
2.打开面板时,显示:
需要重写billListView
<!--====== 视图元素:[PUBAPP列表视图控件(ShowUpableBillListView)实例对象] ============== -->
<bean id="billListView" class="nc.ui.fdc_pr.h303201525.ace.view.BillNewListView"
init-method="initUI">
<property name="model">
<ref bean="bmModel" />
</property>
<property name="multiSelectionEnable" value="true" />
<property name="multiSelectionMode" value="1" />
<property name="templateContainer" ref="templateContainer" />
</bean>
billListView类代码:
package nc.ui.fdc_pr.h303201525.ace.view; import java.util.List; import nc.ui.pub.beans.UIRefPane; import nc.ui.pub.beans.constenum.DefaultConstEnum; import nc.ui.pub.bill.BillListData; import nc.ui.pub.bill.BillListPanel; import nc.ui.pubapp.uif2app.view.ShowUpableBillListView; import nc.ui.uif2.AppEvent; import nc.ui.uif2.model.BillManageModel; import nc.vo.fdc_pr.h303201525.AggBill; import nc.vo.fdc_pr.h303201525.Bill; import nc.vo.pub.CircularlyAccessibleValueObject; public class BillNewListView extends ShowUpableBillListView{ private static final long serialVersionUID = 1L; @Override public void initUI() { super.initUI(); flag = false; } @Override public void handleEvent(AppEvent event) { super.handleEvent(event); showMultHoseOrCust(event); } boolean flag = false; public void showMultHoseOrCust(AppEvent event) { List dlist = getModel().getData();//获得面板数据 if(dlist==null||dlist.size()==0)return; int rows=getBillListPanel().getHeadTable().getRowCount(); for (int i = 0; i < rows; i++){ //获得当前行vo CircularlyAccessibleValueObject hvo = getBillListPanel().getHeadBillModel().getBodyValueRowVO(i, Bill.class.getName()); String pk_head=hvo.getAttributeValue("pk_head")+""; //大于5因为null if(pk_head==null||pk_head.trim().length()<5)continue; String pkhous=""; String build=""; for(int h=0;h<dlist.size();h++){ Object billvo = dlist.get(h); if(billvo==null){ continue; } if(billvo instanceof AggBill){ AggBill aggvo = (AggBill)billvo; String pkhead = aggvo.getParentVO().getPrimaryKey(); if(pk_head.trim().equals(pkhead.trim())){ //取出要分割的参照数据 pkhous = aggvo.getParentVO().getPk_allhouses(); build = aggvo.getParentVO().getBuild(); break; } } } if(pkhous==null||pkhous.trim().length()<5)continue; String[] resultpks = pkhous.split(",");//拆分 UIRefPane refPene =(UIRefPane) getBillListPanel().getHeadItem("pk_allhouses").getComponent(); refPene.setPKs(resultpks); DefaultConstEnum refEnum = new DefaultConstEnum(pkhous, refPene.getRefShowName()); getBillListPanel().getHeadBillModel().setValueAt(refEnum, i, "pk_allhouses");//赋值 if(build==null||build.trim().length()<5){ continue; } String[] buildpks = build.split(","); UIRefPane buildrefPene =(UIRefPane) getBillListPanel().getHeadItem("build").getComponent(); buildrefPene.setPKs(buildpks); DefaultConstEnum buildrefEnum = new DefaultConstEnum(build, buildrefPene.getRefShowName()); getBillListPanel().getHeadBillModel().setValueAt(buildrefEnum, i, "build"); } flag = true; } }