/*************************************** ListUI常用代码 ************************************************/
btnVoucher.setVisible(true);
btnVoucher.setEnabled(true);
tblMain.getColumn("select").getStyleAttributes().setLocked(false);
tblMain.getColumn("entrys.fiShip.name").getStyleAttributes().setHided(true);
tblMain.getHead().getRow(0).getCell(0).setValue("安通物流有限公司投保装船清单");
tblMain.getHeadRow(0).setHeight(50);
tblMain.getHeadRow(0).getStyleAttributes().setBold(true);
tblMain.getHeadRow(0).getStyleAttributes().setFontSize(18);
tblMain.getHeadRow(1).getStyleAttributes().setFontSize(11);
tblMain.getHeadRow(2).getStyleAttributes().setFontSize(10);
tblMain.getHeadRow(2).setHeight(35);
kdtEntry.getColumn("deviationRete").getStyleAttributes().setNumberFormat("#,###.00");
kDTable1.getColumn("unitActualCost").getStyleAttributes().setBackground(com.kingdee.bos.ctrl.common.CtrlUtil.Color.parseColor("#F5DEB3")); //
kDTable1.getViewManager().setFreezeView(0,3); //控制列跟着滚动条一起移动
tblMain.getColumn("claimantTotal").getStyleAttributes().setHorizontalAlign(HorizontalAlignment.RIGHT);
tblMain.getSelectManager().setSelectMode(KDTSelectManager.MULTIPLE_CELL_SELECT); //选中数据的模式,默认选中一行
tblMain.getColumn("delayEffectiveTime").getStyleAttributes().setNumberFormat("yyyy-MM-dd HH:MM:ss"); //设置日期格式
tblMain.getColumn("select").setMergeable(false);//把默认合并的列设为 false
tblMain.setColumnMoveable(true); //设置鼠标拖动列位跟着移动
kdtEntrys.getLayoutManager().scrollToShow(0, 0); 设置滚动条对应的内容位置
kdtEntrys.getLayoutManager()这个方法就有关于滚动条的设置了
//列的融合
tblMain.gerGroupManager().setGroup(true);
tblMain.getColumn("number").setGroup(true);
tblMain.gerGroupManager().group();
CATableUtils.apendFootRow(tblMain, new String[] {"paymentAmount"}); //合计项
tblMain.getColumn("ship").setWidth(150); //设置列宽
="Page " + getPageNumber() //单据获取当前页
SQLExecutorFactory.getRemoteInstance("/*dialect*/ ".intern() + sql.toString()).executeSQL(); //只查询不执行,返回的是结果集。
DbUtil.execute(ctx, sql1); // 执行sql;
com.kingdee.eas.fi.arap.util.DBUtil.executeBatch(ctx, sql, updateList); // 执行sql;
this.uiWindow.close(); // 关闭界面
Distinct sql查询时去重复 /*dialect*/ sql方言
this.setUITitle("投保单"); //设置界面标题(list、edit)
kdtEntrys_detailPanel.setTitle("费用明细"); // 设置分录标题
btnCreateICBill.setText("生成索赔单"); //设置按钮名字
this.kdtEntrys.removeKDTMouseListener(this.kdtEntrys.getSortMange());//屏蔽分录双击排序功能 所有列
tblMain.getColumn(i).setSortable(false); //屏蔽分录双击排序功能 单个
FilterInfo otherFilter = com.kingdee.eas.framework.FrameWorkUtils.getF7FilterInfoByAuthorizedOrg(com.kingdee.eas.basedata.org.OrgType.getEnum("Admin"),"OrgUnit.id",true); //系统的组织隔离
/*************************************** 统计行 ************************************************/
列表界面上添加 统计行
在query中字段有是否是统计字段(isSumField)扩展属性,设为true,主键定义上添加id,叙事薄中就自动汇总了
//添加合计栏
KDTFootManager footmgr = new KDTFootManager(kdtE2);
footmgr.addFootView();
kdtE2.setFootManager(footmgr);
kdtE2.addFootRow(0);
IRow row = footmgr.getFootRow(0);
row.getCell(0).setValue("合计:");
//设置合计字段(重视父类方法)
protected void setTableToSumField() {
setTableToSumField(kdtE1, new String[] { "ContractAmount" });
super.setTableToSumField();
}
完整代码
IRow row = tblMain.addRow();
row.getStyleAttributes().setBackground(new Color(236, 255, 255));
row.getCell(0).setValue("合 计 栏 :");
row.getStyleAttributes().setBold(true);
row.getStyleAttributes().setFontColor(Color.RED);
BigDecimal sum1 = new BigDecimal("0.00"),sum2 = new BigDecimal("0.00");
BigDecimal sum3 =new BigDecimal("0.00"),sum4=new BigDecimal("0.00");
for (int i=0;i<tblMain.getRowCount();i++) {
//合计最后俩栏
if (tblMain.getCell(i, 1).getValue()!=null &&
!tblMain.getCell(i, 1).getValue().equals("")) {
tblMain.getCell(i, 1).setValue(((BigDecimal)tblMain.getCell(i, 1).getValue()).setScale(2));
sum1 = sum1.add((BigDecimal)tblMain.getCell(i, 1).getValue());
}
if (tblMain.getCell(i, 2).getValue()!=null &&
!tblMain.getCell(i, 2).getValue().equals("")) {
tblMain.getCell(i, 2).setValue(((BigDecimal)tblMain.getCell(i, 2).getValue()).setScale(2));
sum2 = sum2.add((BigDecimal)tblMain.getCell(i, 2).getValue());
}
}
row.getCell(1).setValue(sum1.setScale(2));
row.getCell(2).setValue(sum2.setScale(2));
/*************************************** 统计行 ************************************************/
/*************************************** 审批 ************************************************/
public void actionUnAudit_actionPerformed(ActionEvent e) throws Exception {
super.actionUnAudit_actionPerformed(e);
this.checkSelected();
String ids = "";
int size = tblMain.getSelectManager().size();
IInsuranceClaimant insuranceFactory = InsuranceClaimantFactory.getRemoteInstance();
for(int i=0;i<size;i++){
KDTSelectBlock block = tblMain.getSelectManager().get(i);
for(int j=block.getTop();j<=block.getBottom();j++){
IRow row = tblMain.getRow(j);
Object id =row.getCell("id").getValue();
if(UIRuleUtil.isNotNull(id)){
InsuranceClaimantInfo inInfo = insuranceFactory.getInsuranceClaimantInfo(new ObjectUuidPK(id.toString()));
if(!inInfo.getICstatus().toString().equals(ICstatus.auditPass.getAlias())){
MsgBox.showInfo("只有审核通过的数据才能反审批...");
SysUtil.abort();
}
ids += "'"+id.toString()+"',";
}
}
}
if(!ids.equals("")){
ids = ids.substring(0,ids.length()-1);
if(MsgBox.YES == MsgBox.showConfirm2("你确定要对此单据进行反审批吗?")){
InsuranceClaimantFactory.getRemoteInstance().unAudit(ids);
}
}else{
MsgBox.showInfo("请选择需要反审批的数据...");
abort();
}
}
/*************************************** 列表加载完以后执行的方法 ************************************************/
protected void afterTableFillData(KDTDataRequestEvent e) {
for(int i = e.getFirstRow();i<=e.getLastRow();i++){
IRow row = tblMain.getRow(i);
ICell cell = row.getCell("ICstatus");
if(cell.getValue().toString().equals(ICstatus.auditPass.getAlias())){
cell.getStyleAttributes().setFontColor(Color.red);
}
}
super.afterTableFillData(e);
}
/*************************************** 查询过滤 ************************************************/
private void doQuery() throws BOSException {
FilterInfo filter = new FilterInfo();
if(UIRuleUtil.isNotNull(prmtShipName.getValue())){
ShipBaseInfo shInfo = (ShipBaseInfo) prmtShipName.getValue();
filter.getFilterItems().add(new FilterItemInfo("entrys.shipName.name",shInfo.getName().trim(),CompareType.LIKE));
}
if(UIRuleUtil.isNotNull(txtVoyage.getText())){
filter.getFilterItems().add(new FilterItemInfo("entrys.voyage",txtVoyage.getText().trim()));
}
if(UIRuleUtil.isNotNull(txtBoxNumber.getText())){
filter.getFilterItems().add(new FilterItemInfo("entrys.boxNumber.number",txtBoxNumber.getText().trim()));
}
if(UIRuleUtil.isNotNull(txtBillLaingNumber.getText())){
filter.getFilterItems().add(new FilterItemInfo("entrys.billLaingNumber",txtBillLaingNumber.getText().trim()));
}
if(UIRuleUtil.isNotNull(kdBillStatus.getSelectedItem()) && kdBillStatus.getSelectedIndex()!=-1){
ICstatus status = (ICstatus) kdBillStatus.getSelectedItem();
filter.getFilterItems().add(new FilterItemInfo("ICstatus",status.getValue()));
}
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
if (UIRuleUtil.isNotNull(pkStartDate.getValue())) {
String startdate = format.format(pkStartDate.getValue());
startdate = startdate + " 00:00:00";
filter.getFilterItems().add(new FilterItemInfo("claimantDate",startdate,CompareType.GREATER_EQUALS));
}
if(UIRuleUtil.isNotNull(pkEndDate.getValue())){
String enddate = format.format(pkEndDate.getValue());
enddate = enddate + " 23:59:59";
filter.getFilterItems().add(new FilterItemInfo("claimantDate", enddate,CompareType.LESS_EQUALS));
filter.getFilterItems().add(new FilterItemInfo("hrpBizType",0,CompareType.EQUALS));
filter.getFilterItems().add(new FilterItemInfo("hrpBizType",null,CompareType.IS));
filter.getFilterItems().add(new FilterItemInfo("isCreateModel",1,CompareType.EQUALS));
filter.setMaskString("#0 OR #1 AND #2");//条件为or #0的'0表示filter的第一个过滤条件'
}
mainQuery.setFilter(filter);
execQuery();
}
//
protected void beforeExcutQuery(EntityViewInfo ev) {
if (SysContext.getSysContext().getCurrentStorageUnit() != null) {
String storageOrgUnitId = SysContext.getSysContext().getCurrentStorageUnit().getId().toString();
ServiceFileSetUpInfo serviceFileSetUpInfo = UtilByMy.getServiceInfo(storageOrgUnitId);
if(serviceFileSetUpInfo == null){
MsgBox.showInfo("请切换到服务部操作!");
SysUtil.abort();
}
FilterInfo fi = new FilterInfo();//建立过滤条件
fi.getFilterItems().add(new FilterItemInfo("serviceDept.id", serviceFileSetUpInfo.getId(), CompareType.EQUALS));
try {
fi.mergeFilter(ev.getFilter(), "AND");
} catch (BOSException e) {
e.printStackTrace();
}
ev.setFilter(fi);
}
super.beforeExcutQuery(ev);
//在单据的ListUI界面覆盖getDefaultFilterForQuery()方法
@Override
protected FilterInfo getDefaultFilterForQuery() {
FilterInfo filter = super.getDefaultFilterForQuery();
FullOrgUnitInfo orgUnitInfo = getSelectedOrgUnitInfo();
if (orgUnitInfo != null){
//添加组织过滤
filter.getFilterItems().add(
new FilterItemInfo("reqDept.longNumber", orgUnitInfo.getLongNumber() + "%", CompareType.LIKE));
}
//添加过滤
filter.getFilterItems().add(new FilterItemInfo("isInvalid", 0, CompareType.EQUALS));
return filter;
public void actionQuery_actionPerformed(ActionEvent e) throws Exception
{
super.actionQuery_actionPerformed(e);
EntityViewInfo ev1 = getMainQuery();
SorterItemCollection sorter = new SorterItemCollection();
SorterItemInfo item = new SorterItemInfo("bizDate"); //默认排序字段名
item.setSortType(SortType.DESCEND);
sorter.add(item);
ev1.setSorter(sorter);
tblMain.getLayoutManager().scrollRowToShow(0);
this.refresh(e);
}
/*************************************** KDTABLEA 表格点击 ************************************************/
if(btnCostModel.isSelected() && e.getType() == 1 && e.getClickCount() == 2){
// e.getType() == 1 必须点击表格里面 e.getClickCount() == 2 点击次数
int i = kDTable1.getSelectManager().getActiveRowIndex();
String Id = kDTable1.getCell(i, "id").getValue().toString();
SysRjUtil.openShipFeeCostSettle(this, Id);
}
/*************************************** 打印查询sql ************************************************/
界面加载、刷新等操作都会调用该方法。
protected void tblMain_doRequestRowSet(RequestRowSetEvent e) {
int start = ((Integer)e.getParam1()).intValue();
int length = ((Integer)e.getParam2()).intValue() - start + 1;
try
{
IQueryExecutor queryExecutor = QueryExecutorFactory.getRemoteInstance(this.mainQueryPK);
queryExecutor.option().isAutoIgnoreZero = true;
queryExecutor.option().isAutoTranslateBoolean = true;
queryExecutor.option().isAutoTranslateEnum = true;
IRowSet rowSet = queryExecutor.executeQuery(start, length);
logger.info(queryExecutor.getSQL());//打印SQL
e.setRowSet(rowSet);
}
catch (Exception ee)
{
MsgBox.showError(ee.getMessage());
SysUtil.abort();
}
}
/**
*可以指定当前窗口的打开模式,默认情况下不用指定
* UIFactoryName.MODEL,UIFactoryName.NEWWIN,UIFactoryName.NEWTAB
*/
protected String getEditUIModal(){
return UIFactoryName.MODEL;
}
据单据头做botp转换,需要自己在单据的序时簿代码中添加 相关的代码设置
有分录的单据ListUI中,点击“关联生成”后,可不可以实现选中一条记录就生成包含所有分录的目标单据
public void actionCreateTo_actionPerformed(ActionEvent e) throws Exception {
setDAPTrans(true);
super.actionCreateTo_actionPerformed(e);
setDAPTrans(false);
}
在程序中给F7增加过滤参数,发现有组织隔离的F7,比如养户档案,得到F7的Filter后增加一个FilterItemInfo条件,调试的时候/没有看到我加的条件,只看到了框架做的组织隔离的条件?(适用于序时簿的过滤)##
protected FilterInfo getDefaultFilterForQuery()
{
FilterInfo info =super.getDefaultFilterForQuery();
FilterInfo info1 = new FilterInfo();
info.merge(info1,"AND");
}
/**
* 描述:批次加载数据
* @param e
*/
protected void kdtTable_doRequestRowSet(RequestRowSetEvent e)
{
int start = ((Integer) e.getParam1()).intValue();
int length = (((Integer) e.getParam2()).intValue() - start) + 1;
try
{
queryExecutor.setObjectView(getDefaultEntityView());
com.kingdee.jdbc.rowset.IRowSet rowSet = queryExecutor.executeQuery(start, length);
e.setRowSet(rowSet);
}
catch (Exception exc)
{
ExceptionHandler.handle(exc);
}
}
//虚模式分页
table.getDataRequestManager().setDataRequestMode(KDTDataRequestManager.VIRTUAL_MODE_PAGE);
listui 中,枚举值 显示为枚举值,不是别名
protected IQueryExecutor getQueryExecutor(IMetaDataPK queryPK, EntityViewInfo viewInfo) {
IQueryExecutor executor= super.getQueryExecutor(queryPK, viewInfo);
executor.option().isAutoTranslateEnum =true;
return executor;
}
设置界面不可放大、缩小
/**
* 设置界面不可放大、缩小
*/
protected String getEditUIModal() {
String openModel = UIConfigUtility.getOpenModel();
if (openModel != null) {
return openModel;
}
return UIFactoryName.MODEL;
}
行与列的融合
//1.行合并
//获取KDTable合并管理器
KDTMergeManager merge = kdtEntry.getMergeManager();
//传入融合的开始行,开始列,结束行,结束列,融合方式
//融合行时传入的 开始列 = 结束列,融合方式为 FREE_ROW_MERGE 自由融合行
merge.mergeBlock(startRowIndex, colIndex, endRowIndex, colIndex, KDTMergeManager.FREE_ROW_MERGE);
//2.列合并
//融合列时传入的 开始行 = 结束行,融合方式为 FREE_COLUMN_MERGE 自由融合列
merge.mergeBlock(rowIndex, startColIndex, rowIndex, endColIndex, KDTMergeManager.FREE_COLUMN_MERGE);
//3.还有一些其他的系统定义好的融合方式
//可以根据需要传入不同的参数来进行自由融合
public static final int NO_MERGE = 0;
public static final int FREE_ROW_MERGE = 1;
public static final int FREE_COLUMN_MERGE = 2;
public static final int FREE_MERGE = 3;
public static final int SPECIFY_MERGE = 4;
public static final int GROUP_MERGE = 5;
//注意:融合行时 融合方式不能传入 融合列 的融合方式,这样会没有效果,融合列时同样也不能传入 融合行 的融合方式
去掉组织隔离
@Override
protected boolean isIgnoreCUFilter(){
return false;
}
@Override
protected FilterInfo getDefaultFilterForQuery() {
FilterInfo newfilter = new FilterInfo();
CompanyOrgUnitInfo currentFIUnit = SysContext.getSysContext().getCurrentFIUnit();
newfilter.getFilterItems().add(new FilterItemInfo("FICompany.id", currentFIUnit.getId(),CompareType.EQUALS));
FilterInfo oldfilter = super.getDefaultFilterForQuery();
if(oldfilter.getFilterItems().size()>0){
try {
oldfilter.mergeFilter(newfilter, "AND");
} catch (BOSException e) {
e.printStackTrace();
}
} else {
oldfilter = newfilter;
}
return oldfilter;
}
叙事薄滚动条设置
//滚动条支持三种状态 自动 隐藏 显示
public static final int SCROLL_STATE_AUTO=0;//自动根据数据判断是否显示或隐藏
public static final int SCROLL_STATE_HIDE=1;//隐藏
public static final int SCROLL_STATE_SHOW=2;//显示
设置滚动条状态
//设置垂直滚动条
table.setScrollStateVertical(KDTStyleConstants.SCROLL_STATE_HIDE);
//设置水平滚动条
table.setscrollStateHorizon(KDTStyleConstants.SCROLL_STATE_HIDE);
更换滚动条
//更换垂直滚动条
table.getLayoutManager().setVerticalScrollBar(new JScrollBar(JScrollBar.HORIZONTAL));
//更换水平滚动条
table.getLayoutManager().setHorizonScrollBar(new JScrollBar(JScrollBar.HORIZONTAL));