一、EAS客户端常用代码

一.列表界面常用代码

tblMain作为框架为Iist列表界面中的kdTable绑定的变量,通过它可以访问到列表上的每一行、每一列,可以做数据检查,控制,格式化,行合并等操作

1.1初始化用户自己定义的查询过滤框(系统默认为每个定义的列表生成了通用过滤框,如果采用系统通用过滤框,则不需要实现下面的方法)

dialog可在bos中继承CustomerQueryPanelUI新建用户自定义的过滤框,

 

在B0s中发布该元数据后,可以实例化该类并引用,在生成的dialog类中继承方法getFilterInfo(),并实现用户想要的过滤条件,应用框
架会在取数时调用dialog类自动获取过滤条件,在ListUI类中重载方法initCommonQueryDialog

在Bos中发布该元数据后,可以实例化该类并引用
在生成的dialog类中继承方法getFilterInfo(,并实现用户想要的过滤条件,应用框
架会在取数时调用dialog类自动获取过滤条件
在ListUI类中重载方法initCommonQueryDialog
protected CommonQueryDialog initCommonQueryDialogO){
dialog super.initCommonQueryDialogO;
try
{
dialog.addUserPanel(getUserPanelO);
dialog.setShowFilter(true);
dialog.setShowSorter(true);
dialog.setHeight(380);
dialog.setWidth(500);
dialog.setTitle(客户自定义过滤框");
} catch (Exception e){ handUlException(e); } return dialog:
}
protected CustomerQueryPanel getUserPanel() throws Exception{ if(this.userPanel =null) this.userPanel = new PurOrderQueryUI(); userPanel.onLoadO; retum this.userPanel;
}
如上,可以实现通过在通用过滤界面上增加自定义的过滤框实现对列表数据的过滤

 1.2设置列表界面的默认过滤条件,可用来过滤列表数据,也可以直接设置mainQuery的值实现过滤

protected EntityViewInfo getInitDefaultSolution()
{
    EntityViewInfo ev new EntityViewInfoO);
    FilterInfo filter new FilterInfo():
    给filter赋过滤条件项
    ev.setFilter(filter):
    retum ev;
}

1.3设置是否在调入列表界面之前先出过滤框

protected boolean initDefaultFilter()
{
  return true;  
}

1.4客户端对审核的操作

//应用框架预定义了一个审核操作actionAuditing
public void actionAuditing_actionPerformed(ActionEvent e)throws Exception
{
  //检查单据状态
  if (!checkStatus(tblMain,BillStatusEnum.SUBMITED))
  {
    MsgBox.showInfo(this,
    Day4Resource.getStrResource("isNotSubmitStatus")):
    //状态不正确,终止处理
    SysUtil.abortO):
  }
  IPurOrder purorder=(IPurOrder)getBizInterfaceO;
  String[] billldlist=getSelectedListld();
  //常用的弹出对话框方法
  int i MsgBox.showConfirm2(this,"sureAudit"):
  if (i==MsgBox.OK)
  {
    //审核操作
    purOrder.audit(new ObjectStringPK(bill));
    //完成其他业务逻控制
    //新列表界面
    actionRefresh actionPerformed(null);
  }
}

 

1.5列表关联生成

public void actionCreateTo actionPerformed(ActionEvent e)throws Exception{
  checkSelected():
//未审核单据不能关联生成
if (!checkStatus(tblMain,BillStatusEnum.AUDITED))
  MsgBox.showInfo(this,"billlsUnAudited"):
  SysUtil.abor():
//有系统调用配置好的bop’规则
super.actionCreateTo actionPerformed(e);
}

 

1.6动态调用UI界面,并在UI之间传递变量

private void makePurOrderUl(PurOrderInfo srcBillInfo)throws EASBizException,UlException,BOSException,Exception{
String destBillEditUIClassName ="com.kingdee....PurOrderEditUl":
Map map new UIContext(this);
map.put("srcBillID",sreBillInfo.getldO.toString();
map.put(UIContext.OWNER,this);
map.put("srcBillBOSTypeString",destBillInfo.getBOSTypeO):
IUIWindow uiWindow = null
//UIFactoryName.MODEL为弹出模式
uiWindow UIFactory.createUIFactory(UIFactoryName.MODEL).create(destBillEditUIClassName,map,null,
OprtState.ADDNEW):
//可对创建的i进行操作
//((CoreBillEditUI).uiWindow.getUIObject().
//setMakeRelations(btpResult.getBOTRelationCollection():
//开始展现UI
uiWindow.sho();
}

 1.7 关于编码规则

//是否存在编码规则
protected boolean isCodeRuleEnable(IObjectValue objValue)throws EASBizException,BOSException{
  String companyld=OrgInnerUtils.getCurCompany();
  ICodingRuleManager codeRuleMgr = null:
  codeRuleMgr = CodingRuleManagerFactory.getRemotelnstance();
  return codeRuleMgr.isExist(objValue,companyld);
}
//得到自动编码
protected String getAutoCode(IObjectValue objValue)throws EASBizException,BOSException{
  String companyld =  OrgInnerUtils.getCurCompany();
  ICodingRuleManager codeRuleMgr =  null:
  codeRuleMgr=CodingRuleManagerFactory.getRemoteInstance();
  if(codeRuleMgr.isUselntermitNumber(objValue,companyld)){
    return codeRuleMgr.readNumber(objValue,companyld);
  }else{
    return codeRuleMgr.getNumber(objValue,companyld);
  }
}

1.8如何得到当前选中行的id

//得到当前选中行的id
public String[] getSelectedListld(){
    checkSelected();
    //SelectManager是kdtable中行管理类
    ArrayList blocks = tbIMain.getSelectManager().getBlocks();
    ArrayList idList =  new ArrayListo);
    Iterator iter  = blocks.iterator();
    while (iter.hasNext()){
        KDTSelectBlock block =(KDTSelectBlock)iter.nextO:
        int top  = block.getTop();
        int bottom =  block.getBottom();
                for (int rowlndex top;rowlndex <bottom;rowlndex++){
            ICell cell = tblMain.getRow(rowIndex).getCell(getKeyFieldName():
            if(!idList.contains(cell.getValue()){
                idList.add(cell.getValue();
            }
        }
    }
    String[] listld = null;
    if (idList !=null &idList.size()>0){
        Iterator iterat = idList.iterator():
        listld = new String[idList.size()];
        int index =0;
    while (iterat.hasNext()){
        listld[index]=(String)iterat.nextO;
        index++;
        }
    }
    retum listld;
}

 

1.9关于数字精度的设置

private void changeShowData(int fistRow,int lastRow)throws EASBizException,BOSException{
  for (int i=fistRow:i<=lastRow:i++){
      IRow row=tbIMain.getRow(i);    
      //根据币别设置精度
      ICell cell  = row.getCell("columnName");
      //假定精度为2
      int precision =2;
      if (cell !=null && cell.getValue()!=null){
          try{
              precision = Integer.parselnt(cell.getValue0.toString());
              }catch (Exception e){
              precision = 2;
          }
    }     
//当该行的币别精度不能于原币精度时才更改精度     if (precision !=basePrecision){     for (int j=0;j <rowcount;j++){     tblMain.getColumn("billDate").getStyleAttributes().setNumberFormat("%{yyyy-MM-dd}t");     tbIMain.getColumn("debitFor").getStyleAttribute().setNumberFormat("%r{#,##0.00}f");     tbIMain.getColumn("debitFor").getStyleAttributes().setHorizontalAlign(HorizontalAlignment.RIGHT);     tbIMain.getColumn("endBalanceFor").getStyleAttributes().setNumberFormat("%r{#,##0.00)f");     tbIMain.getColumn("endBalanceFor").getStyleAttributes().setHorizontalAlign(HorizontalAlignment.RIGHT);     }     }   } }

 

1.10返回当前列表的主键

protected String getKeyFieldName(){
    retum "id":
}

 

1.11返回列表界面对应的编辑界面名称

1.11返回列表界面对应的编辑界面名称
protected String getEditUIName(){
    return client.PurOrderEditUl.class.getName();
}

 

1.12返回远程调用接口

protected com.kingdee.eas.framework.ICoreBase getBizInterface()throws Exception{
    return PurOrderFactory.getRemoteInstance():
}

 1.13 在列表页面打开编辑页面

public void actionEdit_actionPerformed(ActionEvent e) throws Exception {
        IObjectPK pk = new ObjectUuidPK(BOSUuid.read(getSelectedKeyValue()));
        FundsMoveBillInfo info = FundsMoveBillFactory.getRemoteInstance().getFundsMoveBillInfo(pk);
        boolean isOnlineOA = OARequestUtil.isOnlineCompany(info.getCompany().getId().toString(), EasOAConstant.BosType_FundsMoveBill);
        //已上线OA公司的已审核单子可以修改金额和业务日期
        if (isOnlineOA) {
            IUIWindow uiWindow = null;
            UIContext uiContext = new UIContext(this);
            /* 4366 */     uiContext.put("ID", getSelectedKeyValue());
            String editUIStr ="com.kingdee.eas.fi.cas.client.FundsMoveBillEditUI";
            //UIFactoryName.MODEL为弹出模式
            String aString = super.getEditUIName();
//            uiWindow = UIFactory.createUIFactory(UIFactoryName.NEWTAB).create(editUIStr,uiContext,null,OprtState.EDIT);
            uiWindow = UIFactory.createUIFactory(UIFactoryName.NEWTAB).create(super.getEditUIName(),uiContext,null,OprtState.EDIT);
            //开始展现UI
            uiWindow.show();
        }else{
            super.actionEdit_actionPerformed(e);
        }
    }

 

posted @ 2023-06-13 16:20  凉了记忆  阅读(229)  评论(0编辑  收藏  举报