1. 表头
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;
}
}
2.表体
@SuppressWarnings("serial")
public class CheckscheduleBillListView extends ShowUpableBillListView {
boolean flag = false;
@Override
public void initUI() {
super.initUI();
flag = false;
}
@Override
public void handleEvent(AppEvent event) {
super.handleEvent(event);
try {
this.showMultiSelectItems(event);
} catch (BusinessException e) {
e.printStackTrace();
}
}
/**
* 多选字段信息显示
* @param event
* @throws BusinessException
*/
public void showMultiSelectItems(AppEvent event) throws BusinessException {
try{
//获得面板数据
List dlist = this.getModel().getData();
if(dlist==null || dlist.size()==0) {
return;
}
//获取选中行
int rowIndex = getBillListPanel().getHeadTable().getSelectedRow();
if (rowIndex < 0){
rowIndex = 0;
}
//获取选中行数据
AggCheckscheduleHVO billVO = (AggCheckscheduleHVO) dlist.get(rowIndex);
//获取检验派工表体数据
CheckscheduleBVO[] bvos = (CheckscheduleBVO[]) billVO.getChildren(CheckscheduleBVO.class);
//获取表体行数
int bodyRows = this.getBillListPanel().getBodyBillModel("pk_body").getRowCount();
for(int i=0;i<bodyRows;i++){
CircularlyAccessibleValueObject hvo = getBillListPanel().getBodyBillModel().getBodyValueRowVO(i,CheckscheduleBVO.class.getName());
String pk_body = hvo.getAttributeValue("pk_body") + "";
if (pk_body == null || pk_body.trim().length() < 5){
continue;
}
String psndocID = "";
if(bvos != null && bvos.length>0){
for(int b=0;b<bvos.length;b++){
CheckscheduleBVO bvo = bvos[b];
if (bvo == null) {
continue;
}
if(bvo instanceof CheckscheduleBVO){
String bodyId = bvo.getPk_body();
if(bodyId==null) break;
if (pk_body.trim().equals(bodyId.trim())) {
psndocID = bvo.getPsndoc_id();
break;
}
}
}
}
if (psndocID == null || psndocID.trim().length() < 5){
continue;
}
String[] resultpks = psndocID.split(",");
UIRefPane refPene = (UIRefPane) getBillListPanel().getBodyItem("pk_body", "psndoc_name").getComponent();
refPene.setPKs(resultpks);
DefaultConstEnum refEnum = new DefaultConstEnum(psndocID, refPene.getRefShowName());
this.getBillListPanel().getBodyBillModel("pk_body").setValueAt(refEnum, i, "psndoc_name");
}
flag = true;
}catch(Exception e){
e.printStackTrace();
}
}
}
3.重写BillForm
@SuppressWarnings("serial")
public class CheckscheduleBillForm extends ShowUpableBillForm {
public CheckscheduleBillForm() {
super();
}
@Override
public void initUI() {
super.initUI();
// 排序
// this.getBillCardPanel().getBillModel("pk_body").setSortColumn(new String[] { "crowno" });
}
@Override
public void setValue(Object object) {
super.setValue(object);
// 设置多选字段信息
try {
this.showMultiSelectItems();
} catch (BusinessException e) {
e.printStackTrace();
}
}
/**
* 多选字段信息显示
*
* @throws BusinessException
*/
public void showMultiSelectItems() throws BusinessException {
Object obj = this.getModel().getSelectedData();
if (obj == null) {
return;
}
AggCheckscheduleHVO billvo = (AggCheckscheduleHVO) obj;
CheckscheduleBVO[] bvos = (CheckscheduleBVO[]) billvo.getChildren(CheckscheduleBVO.class);
if (bvos == null || bvos.length == 0) {
return;
}
int row = this.getBillCardPanel().getBillModel().getRowCount();
for (int i = 0; i < row; i++) {
String pk_body = (String) this.getBillCardPanel().getBillModel().getValueAt(i, "pk_body");
if (pk_body == null) {
continue;
}
for (int j = 0; j < bvos.length; j++) {
if (bvos[j].getPk_body() != null && bvos[j].getPk_body().equals(pk_body)) {
// 人员
String psninfo_value = bvos[j].getPsndoc_id();
String psninfo_name = bvos[j].getPsndoc_name();
if (psninfo_value == null || "".equals(psninfo_value)) {
psninfo_name = "";
}
DefaultConstEnum psninfo_constenum = new DefaultConstEnum(psninfo_value, psninfo_name);
this.getBillCardPanel().getBillModel().setValueAt(psninfo_constenum, i, "psndoc_name");
break;
}
}
break;
}
}
}