1、设置序时簿背景颜色
@Override
protected void afterTableFillData(KDTDataRequestEvent e) {
// TODO Auto-generated method stub
super.afterTableFillData(e);
for(int i = e.getFirstRow();i<=e.getLastRow();i++){
IRow row = tblMain.getRow(i);
ICell cell = row.getCell("bizDate");
Boolean fivouchered = (Boolean) row.getCell("Fivouchered").getValue();
Date bizDate = (Date) cell.getValue();
row.getCell("bizDate");
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
try {
Date parse = simpleDateFormat.parse("2021-01-30");
if(bizDate.compareTo(parse)<=0){
if(!fivouchered){
row.getCell("Fivouchered").getStyleAttributes().setBackground(Color.gray);
}
}
} catch (ParseException e1) {
e1.printStackTrace();
}
}
}
2、设置序时簿显示 不忽略0
protected IQueryExecutor getQueryExecutor(IMetaDataPK pk,
EntityViewInfo viewInfo) {
IQueryExecutor queryExecutor = super.getQueryExecutor(pk, viewInfo);
queryExecutor.option().isAutoIgnoreZero = false; // 不自动忽略数值零
return queryExecutor;
}
3、编辑界面分录表格点击事件
@Override
protected void kdtEntrys2_tableClicked(KDTMouseEvent e) throws Exception {
if(prmtcustomer.getValue() == null)throw new EASBizException(new NumericExceptionSubItem("0002","请先选择客户"));
}
4、编辑界面页面全屏
super.onLoad();
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
setPreferredSize(new Dimension(screenSize.width-450,screenSize.height-300));
5、字段设置颜色
this.txtinvoicedAmt.setCustomForegroundColor( Color.red);
6、分录设置标题
this.kdtEntrys_detailPanel.setTitle("发票");
7、刷新单据的序时簿界面
// disposeUIWindow();
Object uiObj = this.getUIContext().get(UIContext.OWNER); // 刷新序时薄界面
if (uiObj != null && uiObj instanceof HWReqBillListUI) {
((HWReqBillListUI) uiObj).refreshList();
}
8、分录编辑F7 编辑结束事件
protected void kdtEntrys2_editStopped(KDTEditEvent e)
9、分录的f7过滤
CustomerInfo customerInfo = (CustomerInfo) this.prmtcustomer.getValue();
KDBizPromptBox prmtHfPerson = (KDBizPromptBox) kdtEntrys2.getColumn("TempInWarehsBill").getEditor().getComponent(); //获取表格特定列绑定的F7
EntityViewInfo view = new EntityViewInfo();
prmtHfPerson.setQueryInfo("com.kingdee.eas.wastedisposal.hwd.app.TempInWarehsBilChooseQuery");
FilterInfo filter = new FilterInfo(); //过滤条件
filter.getFilterItems().add(new FilterItemInfo("customer.id", customerInfo.getId())); //条件1,#0
//filter.getFilterItems().add(new FilterItemInfo("status", BizStatusEnum.NORMAL_VALUE)); //条件2,#1
//filter.getFilterItems().add(new FilterItemInfo("status", BizStatusEnum.FROZEN_VALUE)); //条件3,#2
//filter.setMaskString("#0 and (#1 or #2)"); //3个过滤条件设定关系
view.setFilter(filter);
prmtHfPerson.setEntityViewInfo(view); //F7重新设定视图
10、分录字段设置小数显示位数、设置锁定
kdtEntrys.getColumn("price").getStyleAttributes().setNumberFormat("#,##0.##########");
kdtEntrys.getColumn("taxPrice").getStyleAttributes().setNumberFormat("#,##0.##########");
kdtEntrys.getColumn("amount").getStyleAttributes().setLocked(false);
kdtEntrys.getColumn("taxAmount").getStyleAttributes().setLocked(false);
kdtEntrys.getColumn("invoicedAmt").getStyleAttributes().setLocked(false);
11、bean方法中处理凭证反写
@Override
protected void _reverseSave(Context ctx, IObjectPK srcBillPK,
IObjectValue srcBillVO, BOTBillOperStateEnum billOperStateEnum,
IObjectValue relationInfo) throws BOSException, EASBizException {
reverseSave(ctx, srcBillPK, srcBillVO, billOperStateEnum, relationInfo);
super._reverseSave(ctx, srcBillPK, srcBillVO, billOperStateEnum, relationInfo);
}
public static void reverseSave(Context ctx, IObjectPK srcBillPK, IObjectValue srcBillVO, BOTBillOperStateEnum bOTBillOperStateEnum, IObjectValue bOTRelationInfo) throws BOSException, EASBizException {
BOTRelationInfo relation = (BOTRelationInfo) bOTRelationInfo;
BOSObjectType bosType = BOSUuid.read(relation.getDestObjectID()).getType();
if (bosType.equals((new VoucherInfo()).getBOSType())) {
CoreBillBaseInfo model = (CoreBillBaseInfo) srcBillVO;
// 删除凭证
if (bOTBillOperStateEnum.equals(BOTBillOperStateEnum.DELETE)) {
//model.put(FLD_FIVOUCHERED, new Integer(0));
// 以下设置单据的凭证信息
model.put("VOUCHERNUMBER", null);
//model.put(FLD_VOUCHERDATE, null);
}
// 生成凭证
else {
String voucherID = relation.getDestObjectID();
VoucherInfo voucherInfo = (VoucherInfo) VoucherFactory.getLocalInstance(ctx).getValue(new ObjectStringPK(voucherID));
//model.put(FLD_FIVOUCHERED, voucherInfo.getNumber() );
// 以下设置单据的凭证信息
model.put("VOUCHERNUMBER", voucherInfo.getNumber());
// model.put(FLD_VOUCHERDATE, voucherInfo.getBookedDate());
}
BOSObjectType bosObjectType = srcBillVO.getBOSType();
ICoreBillBase iCoreBillBase = (ICoreBillBase) BOSObjectFactory.createBOSObject(ctx, bosObjectType);
iCoreBillBase.reverseSave(srcBillPK, (CoreBillBaseInfo) srcBillVO);
}
}
12、序时簿设置字段精度显示
this.tblMain.getColumn("entrys.noTaxPrice").getStyleAttributes().setNumberFormat("0.########");
this.tblMain.getColumn("entrys.noTaxPrice").setWidth(160);
13、标准F7 比如物料 客户 供应商 实现
职员两种效果
HashMap map = new HashMap();
map.put(PersonF7UI.ALL_ADMIN, "YES");
map.put(PersonF7UI.DEFAULT_SHOW_ALL, "YES");
prmtbusinessManager.setSelector(new PersonPromptBox(null, map));
//第二种
prmtbusinessManager.setQueryInfo("com.kingdee.eas.basedata.person.app.F7PersonQuery");
FIPersonPromptBox personf7 = new FIPersonPromptBox(this);
prmtbusinessManager.setSelector(personf7);
//第三种
prmtfirstParty.setHasCUDefaultFilter(true);
FIPersonPromptBox personf7 = new FIPersonPromptBox(this);
prmtbusinessManager.setSelector(personf7);
F7 专用选择界面的设置
public void setF7Selector() throws Exception
{
KDBizPromptBox bizPromptBox = new KDBizPromptBox();//
CoreUIObject ui = null;// 父界面对象
CompanyOrgUnitInfo companyInfo = null; // 当前财务组织
// 客户
bizPromptBox.setSelector(new GeneralKDPromptSelectorAdaptor(bizPromptBox, new
F7CustomerTreeDetailListUI(), ui));
// 供应商
bizPromptBox.setSelector(new GeneralKDPromptSelectorAdaptor(bizPromptBox, new
F7SupplierTreeDetailListUI(), ui));
// 物料
bizPromptBox.setSelector(new GeneralKDPromptSelectorAdaptor(bizPromptBox, new
F7MaterialTreeListUI(), ui));
// 职员
HashMap map = new HashMap();
map.put(PersonF7UI.ALL_ADMIN, "YES");
bizPromptBox.setSelector(new PersonPromptBox(ui, map));
// 公司
CompanyF7 org = new CompanyF7(ui);
org.setRootUnitID("");
bizPromptBox.setSelector(new CompanyF7(ui));
// 成本中心
bizPromptBox.setSelector(new CostCenterF7(ui));
// 行政组织
bizPromptBox.setSelector(new AdminF7(ui));
// 采购组织
bizPromptBox.setSelector(new PurchaseF7(ui));
// 库存组织
bizPromptBox.setSelector(new StorageF7(ui));
// 销售组织
bizPromptBox.setSelector(new SaleF7(ui));
// 利润中心组织
bizPromptBox.setSelector(new ProfitCenterF7(ui));
final KDBizPromptBox objPrmt = new KDBizPromptBox();
F7BaseSelector selector = null;//new F7BaseSelector(this, null, objPrmt);
objPrmt.setVisible(true);
objPrmt.setEditable(true);
objPrmt.setEditFormat("$number$");
objPrmt.setCommitFormat("$number$;$name$");
objPrmt.setDisplayFormat("$name$");
if(tblName.equalsIgnoreCase("T_BD_Customer")){//客户
objPrmt.setQueryInfo("com.kingdee.eas.basedata.master.cssp.app.F7CustomerQuery");
selector = new F7CustomerSimpleSelector(this, objPrmt);
objPrmt.setSelector(selector);
}else if(tblName.equalsIgnoreCase("T_BD_Supplier")){//供应商
objPrmt.setQueryInfo("com.kingdee.eas.basedata.master.cssp.app.F7SupplierQuery");
selector = new F7SupplierSimpleSelector(this, objPrmt);
objPrmt.setSelector(selector);
}else if(tblName.equalsIgnoreCase("T_BD_AccountBanks")){//银行帐户
objPrmt.setQueryInfo("com.kingdee.eas.basedata.assistant.app.F7AccountBankQuery");
}else if(tblName.equalsIgnoreCase("T_ORG_Company")){//公司
objPrmt.setQueryInfo("com.kingdee.eas.basedata.org.app.CompanyQuery");
}else if(tblName.equalsIgnoreCase("T_BD_Material")){//物料
objPrmt.setQueryInfo("com.kingdee.eas.basedata.master.material.app.F7MaterialBaseInfoQuery");
}else if(tblName.equalsIgnoreCase("T_BD_Person")){//职员
objPrmt.setQueryInfo("com.kingdee.eas.basedata.person.app.F7PersonQuery");
FIPersonPromptBox personf7 = new FIPersonPromptBox(this);
objPrmt.setSelector(personf7);
}else if(tblName.equalsIgnoreCase("T_ORG_CostCenter")){//成本中心
objPrmt.setQueryInfo("com.kingdee.eas.basedata.org.app.CostCenterOrgUnitQuery4AsstAcct");
}else if(tblName.equalsIgnoreCase("T_BD_Project")){//项目
objPrmt.setQueryInfo("com.kingdee.eas.basedata.assistant.app.F7ProjectQuery");
}else if(tblName.equalsIgnoreCase("T_BD_GeneralAsstActType")){//自定义核算项
objPrmt.setQueryInfo("com.kingdee.eas.basedata.master.auxacct.app.F7GeneralAsstActTypeQuery");
AuxAccountUtils.assignGeneralBizPromptBox(objPrmt, grp.getId().toString(), true, this);
//GLf7Utils.assignSelector(objPrmt, grp, aat.getHgAttribute(), at.isForCompany(), false, null, this, at.isUseLongNumber());
}else {//其他
}
14、F7控件设置cu过滤
prmtfirstParty.setHasCUDefaultFilter(true);
15、获取分录合计
IRow footRow = kdtEntrys.getFootManager().getFootRow(0);
BigDecimal amount = new BigDecimal(footRow.getCell("amount").getValue().toString());
BigDecimal qty = new BigDecimal(footRow.getCell("qty").getValue().toString());
16、查询扩展报表的发布路径
select * from t_bas_definereport where fname_l2 like '%低%'
17、数据库插入web菜单
// 客户话菜单
geninsert select * from T_PM_MainMenuItem where FName_L2='自定义项目'
//web菜单
geninsert select * from T_JP_Page where FID='18581f64-696f-4975-81cd-410991d6c5d1'
18、F7弹框界面 银行账号脱敏实现 复制标准query修改
( SELECT CONCAT ( CONCAT ( LEFT ( CFBANKACCOUNT , 4 ) , '*******' ) , CONCAT ( '*******' , right ( CFBANKACCOUNT , 4 ) ) ) as bankAccount FROM T_BC_CollectionAccount where CFBANKACCOUNT = #0 )
19、下拉框监听
@Override
public void onLoad() throws Exception {
super.onLoad();
bizTypeListener();
}
/**
* 下拉列表监听
* 该方法需放入 onLoad() 方法中
*/
public void bizTypeListener() {
bizType.addItemListener(new ItemListener(){
@Override
public void itemStateChanged(ItemEvent e) {
/**
* bizType 单据界面下拉列表控件名称
* getSelectedItem() 获取下拉列表选中的值
* AcpBizType 自定义的枚举类
*/
AcpBizType type = (AcpBizType) bizType.getSelectedItem();
}
});
}
20、EAS BOS 代码隐藏分录列、锁定列、锁定单元格
kdtEntry.getColumn("unit").getStyleAttributes().setHided(true);//隐藏列
kdtEntry.getColumn("unit").getStyleAttributes().setLocked(true);//锁定列使不可编辑
kdtEntry.getCell(rowIndex, "unit").getStyleAttributes().setLocked(true);//锁定单元格
21、设置字段必填 及必填背景色
txtsettlementAmount.setBackground(new Color(255,255,220));
txtsettlementedAmount.setRequired(true);
22、分录设置必填 及 背景色
kdtEntrys.getColumn("price").setRequired(true);
kdtEntrys.getColumn("price").getStyleAttributes().setBackground(new Color(255,255,220));
23、 含税金额 不含税金额 税率计算逻辑
//数量 不含税单价 税率 监听
if ("qty".equalsIgnoreCase(kdtEntrys.getColumn(colIndex).getKey())|| "price".equalsIgnoreCase(kdtEntrys.getColumn(colIndex).getKey())|| "tax".equalsIgnoreCase(kdtEntrys.getColumn(colIndex).getKey()) ) {
BigDecimal price = kdtEntrys.getCell(rowIndex, "price").getValue() == null ?BigDecimal.ZERO:(BigDecimal)kdtEntrys.getCell(rowIndex, "price").getValue();
BigDecimal qty = kdtEntrys.getCell(rowIndex, "qty").getValue() == null ?BigDecimal.ZERO:(BigDecimal)kdtEntrys.getCell(rowIndex, "qty").getValue();
//含税单价=不含税价格*(1+税率)
BigDecimal tax = kdtEntrys.getCell(rowIndex, "tax").getValue() == null ?BigDecimal.ZERO:(BigDecimal)kdtEntrys.getCell(rowIndex, "tax").getValue();
BigDecimal taxrate = tax.divide(new BigDecimal("100"),2,BigDecimal.ROUND_HALF_UP);
BigDecimal taxPrice = price.multiply(new BigDecimal("1").add(taxrate)).setScale(10,BigDecimal.ROUND_HALF_UP);
//税额=不含税价格*税率*数量
BigDecimal taxAmt = price.multiply(taxrate).multiply(qty).setScale(2,BigDecimal.ROUND_HALF_UP);
//含税金额=含税单价*数量
BigDecimal payment = taxPrice.multiply(qty).setScale(2,BigDecimal.ROUND_HALF_UP);
//不含税金额 =金额-税额
BigDecimal amt = payment.subtract(taxAmt);
kdtEntrys.getCell(rowIndex, "taxPrice").setValue(taxPrice);
kdtEntrys.getCell(rowIndex, "taxAmt").setValue(taxAmt);
kdtEntrys.getCell(rowIndex, "amt").setValue(amt);
kdtEntrys.getCell(rowIndex, "payment").setValue(payment);
}
//数量 含税单价 监听
if ("qty".equalsIgnoreCase(kdtEntrys.getColumn(colIndex).getKey())|| "taxPrice".equalsIgnoreCase(kdtEntrys.getColumn(colIndex).getKey()) ) {
BigDecimal taxPrice = kdtEntrys.getCell(rowIndex, "taxPrice").getValue() == null ?BigDecimal.ZERO:(BigDecimal)kdtEntrys.getCell(rowIndex, "taxPrice").getValue();
BigDecimal qty = kdtEntrys.getCell(rowIndex, "qty").getValue() == null ?BigDecimal.ZERO:(BigDecimal)kdtEntrys.getCell(rowIndex, "qty").getValue();
BigDecimal payment=qty.multiply(taxPrice).setScale(2, BigDecimal.ROUND_HALF_UP); //开票金额 开票金额=含税单价*数量
//不含税价格=含税单价/(1+税率)
BigDecimal tax = kdtEntrys.getCell(rowIndex, "tax").getValue() == null ?BigDecimal.ZERO:(BigDecimal)kdtEntrys.getCell(rowIndex, "tax").getValue();
BigDecimal taxrate = tax.divide(new BigDecimal("100"),2,BigDecimal.ROUND_HALF_UP);
BigDecimal price=taxPrice.divide (new BigDecimal("1").add(taxrate),10,BigDecimal.ROUND_HALF_UP);
//税额=含税单价/(1+税率)*税率*数量
//税额=不含税价格*税率*数量
BigDecimal taxAmt = price.multiply(taxrate).multiply(qty).setScale(2,BigDecimal.ROUND_HALF_UP);
//不含税金额 =金额-税额
BigDecimal amt = payment.subtract(taxAmt);
kdtEntrys.getCell(rowIndex, "price").setValue(price);
kdtEntrys.getCell(rowIndex, "taxAmt").setValue(taxAmt);
kdtEntrys.getCell(rowIndex, "amt").setValue(amt);
kdtEntrys.getCell(rowIndex, "payment").setValue(payment);
}
24、eas里客户端保存,提交里增加校验规则和必填
protected void verifyInput(ActionEvent e)