平常开发时常涉及到一些表的点击事件,如双击字段时处理什么逻辑,三击表时根据ID打开界面什么。
1:添加表的点击事件。
2:
/**
* 表的单击事件
*/
@Override
protected void kDTable1_tableClicked(KDTMouseEvent e) throws Exception {
super.kDTable1_tableClicked(e);
//点击次数 点击某列
if(e.getClickCount() >= 3){
int index = kDTable1.getSelectManager().getActiveRowIndex();
if(index!=0){
String id=kDTable1.getCell(index, "id").getValue().toString();
//不同ID打开对应界面
openWindow(this,id);
}
}
}
/**
* 停止编辑表事件
*/
@Override
protected void kDTable1_editStopped(KDTEditEvent e) throws Exception {
super.kDTable1_editStopped(e);
int rowIndex= e.getRowIndex();
int colIndex = e.getColIndex();
if(e.getColIndex()==kDTable1.getColumnIndex("updateCost")){
IRow row = kDTable1.getRow(rowIndex);
if (UIRuleUtil.isNotNull(row.getCell("updateCost").getValue())) {
// "unitActualCost","actualCost","FTABLENAME","FENTRYID","FISREWORK","BASEUNITACTUALCOST"
if(!"0".equals(row.getCell("updateCost").getValue().toString())){
BigDecimal amount=new BigDecimal(row.getCell("updateCost").getValue().toString());
BigDecimal qty=new BigDecimal(row.getCell("qty").getValue().toString());
BigDecimal actualCost=amount.multiply(qty);
row.getCell("unitActualCost").setValue(amount);
row.getCell("actualCost").setValue(actualCost);
}else{
row.getCell("unitActualCost").setValue(BigDecimal.ZERO);
row.getCell("actualCost").setValue(BigDecimal.ZERO);
}
}
}
}
/**
*
* @Title: openWindow
* @Description: TODO(根据异常单界面ID打开对应界面)
* @return void 返回类型
* @throws
*/
private void openWindow(CoreUI parentUI,String id) {
HashMap<String, String> map=new HashMap<String, String>();
Class clazz=null;
String bosType = new ObjectUuidPK(id).getObjectType().toString();
if(bosType.equals(new PurInWarehsBillInfo().getBOSType().toString())){
clazz=PurInWarehsBillEditUI.class;
}else if(bosType.equals(new ManufactureRecBillInfo().getBOSType().toString())){
clazz=ManufactureRecBillEditUI.class;
}else if(bosType.equals(new OtherInWarehsBillInfo().getBOSType().toString())){
clazz=OtherInWarehsBillEditUI.class;
}else if(bosType.equals(new MoveInWarehsBillInfo().getBOSType().toString())){
clazz=MoveInWarehsBillEditUI.class;
}else if(bosType.equals(new MaterialReqBillInfo().getBOSType().toString())){
clazz=MaterialReqBillEditUI.class;
}else if(bosType.equals(new SaleIssueBillInfo().getBOSType().toString())){
clazz=SaleIssueBillEditUI.class;
}else if(bosType.equals(new MoveIssueBillInfo().getBOSType().toString())){
clazz=MoveIssueBillEditUI.class;
}else if(bosType.equals(new OtherIssueBillInfo().getBOSType().toString())){
clazz=OtherIssueBillEditUI.class;
}
map.put("ID", id);
try {
CAUIHelper.openDialog(this, clazz, map, OprtState.VIEW);
} catch (Exception e) {
e.printStackTrace();
}
}