需求1:对单据中的分录中一个字段进行监听,当点击这个字段时进行校验判断其他字段是否为空。
需求2:对业务类别字段进行过滤。
需求3: 选择某个业务类别字段后,带出这个字段下所属的费用类型
需求2代码:
public void onLoad() throws Exception {
super.onLoad();
final KDTable shareEntry = (KDTable)DEPUtils.findComponetByName((Container)this, "shareEntry");
final KDBizPromptBox operationType = (KDBizPromptBox)shareEntry.getColumn("operationType").getEditor().getComponent();
final EntityViewInfo view = new EntityViewInfo();
final FilterInfo filterInfo = new FilterInfo();
filterInfo.getFilterItems().add(new FilterItemInfo("operationType.id", (Object)"select fid from T_BC_OperationType where fisenable ='1' and fcompanyid ='00000000-0000-0000-0000-000000000000CCE7AED4'", CompareType.INNER));
view.setFilter(filterInfo);
operationType.setEntityViewInfo(view);
this.setEntryOrgPromptBox();
}
需求3代码与需求1代码:
一、将事件写在initListener()方法里去调用,因为我这个是在点击字段的时候就要去判断,所以写在了editStarted方法里,如果是操作完字段后再执行逻辑,那就写在editStopped方法里
protected void initListener() {
super.initListener();
final KDTable shareEntry = (KDTable)DEPUtils.findComponetByName((Container)this, "shareEntry");
shareEntry.addKDTEditListener((KDTEditListener)new KDTEditAdapter() {
public void editStarted(final KDTEditEvent e) {
try {
PayRequestBillEditUICTEx.this.f7_editStarted(e, e.getRowIndex(), e.getColIndex());
}
catch (Exception exc) {
PayRequestBillEditUICTEx.this.handUIException((Throwable)exc);
}
}
public void editStopped(final KDTEditEvent e) {
try {
PayRequestBillEditUICTEx.this.f7_editStopped(e, e.getRowIndex(), e.getColIndex());
}
catch (Exception exc) {
PayRequestBillEditUICTEx.this.handUIException((Throwable)exc);
}
}
});
this.prmtPayment.addDataChangeListener((DataChangeListener)new DataChangeListener() {
public void dataChanged(final DataChangeEvent paramDataChangeEvent) {
PayRequestBillEditUICTEx.this.prmtPayment_daChanged(paramDataChangeEvent);
}
});
}
二、逻辑内容写在f7_editStarted方法里
protected void f7_editStarted(final KDTEditEvent e, final int rowIndex, final int colIndex) throws EASBizException, BOSException {
final KDTable shareEntry = (KDTable)DEPUtils.findComponetByName((Container)this, "shareEntry");
final KDBizPromptBox KDexpenseType = (KDBizPromptBox)shareEntry.getColumn("expenseType").getEditor().getComponent();
if (colIndex == shareEntry.getColumnIndex("expenseType")) {
try {
Object operationType = shareEntry.getCell(rowIndex, "operationType").getValue();
if(operationType == null || "".equals(operationType)){
MsgBox.showInfo("请先选择业务类别!");
e.setCancel(true);
}else{
//filterInfo对expenseType费用类型进行过滤,过滤条件是根据业务类别
final OperationTypeInfo operationTypeInfo = (OperationTypeInfo)operationType;
BOSUuid id = operationTypeInfo.getId();
final EntityViewInfo view = new EntityViewInfo();
final FilterInfo filterInfo = new FilterInfo();
filterInfo.getFilterItems().add(new FilterItemInfo("operationType.id", "select fid from T_BC_OperationType where fid = '"+new ObjectUuidPK(id)+"'", CompareType.INNER));
view.setFilter(filterInfo);
KDexpenseType.setEntityViewInfo(view);
}
}
catch (Exception exc) {
PayRequestBillEditUICTEx.this.handUIException((Throwable)exc);
}
}
}