验证某个用户是否拥有某个权限java
BOSUuid userId=SysContext.getSysContext().getCurrentUserInfo().getId(); BOSUuid orgId=SysContext.getSysContext().getCurrentOrgUnit().getId(); ObjectUuidPK userPK = new ObjectUuidPK(userId); ObjectUuidPK orgPK = new ObjectUuidPK(orgId); com.kingdee.eas.base.permission.IPermission perm= null; try { perm =PermissionFactory.getRemoteInstance(); perm.hasFunctionPermission(userPK, orgPK, "custom_qua_QuaTarget_addnew"); } catch (Exception e) { e.printStackTrace(); }
经过id获取bostypeapp
BOSUuid id = BOSUuid.read(billId); BOSObjectType type = id.getType();
经过bostype获取实体、tableide
BOSObjectType bosobjecttype = BOSObjectType.create(bostype); IMetaDataLoader metadataloader = MetaDataLoaderFactory.getLocalMetaDataLoader(ctx); EntityObjectInfo entity = metadataloader.getEntity(bosobjecttype); //获取实体对象object IObjectValue ov = null; String objectClassName = entity.getObjectValueClass(); try { Class objectClass = Class.forName(objectClassName); ov = (IObjectValue) objectClass.newInstance(); } catch (ClassNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (InstantiationException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IllegalAccessException e) { // TODO Auto-generated catch block e.printStackTrace(); } //获取table String tableName = entity.getTable().getName();
经过人员获取职位信息ui
部门能够经过职位getAdminOrgUnit获取 /** * 经过人员获取职位 * @param info * @return * @throws EASBizException * @throws BOSException */ public PositionInfo getPositionByPerson(PersonInfo info)throws EASBizException, BOSException { EntityViewInfo view = new EntityViewInfo(); SelectorItemCollection sic = new SelectorItemCollection(); sic.add(new SelectorItemInfo("id")); sic.add(new SelectorItemInfo("position.adminOrgUnit.id")); sic.add(new SelectorItemInfo("position.adminOrgUnit.name")); sic.add(new SelectorItemInfo("person.id")); sic.add(new SelectorItemInfo("person.name")); sic.add(new SelectorItemInfo("person.number")); sic.add(new SelectorItemInfo("position.id")); sic.add(new SelectorItemInfo("position.number")); sic.add(new SelectorItemInfo("position.name")); sic.add(new SelectorItemInfo("position.job.id")); sic.add(new SelectorItemInfo("position.job.number")); sic.add(new SelectorItemInfo("position.job.name")); view.setSelector(sic); FilterInfo filter = new FilterInfo(); filter.getFilterItems().add(new FilterItemInfo("person.id", info.getId() + "")); filter.getFilterItems().add(new FilterItemInfo("isPrimary", new Integer(1))); view.setFilter(filter); PositionMemberCollection col = PositionMemberFactory.getRemoteInstance().getPositionMemberCollection(view); if ((col != null) && (col.size() > 0) && (col.get(0) != null)) { return col.get(0).getPosition(); } return null; }
控件相关经常使用代码 beginthis
禁用f7历史记录spa
prmtbox.setHistoryRecordEnabled(false);
f7设置过滤条件code
EntityViewInfo view = new EntityViewInfo(); //过滤条件 FilterInfo filter = new FilterInfo(); filter.getFilterItems().add(new FilterItemInfo("freightBoxType","XY")); view.setFilter(filter); //排序 SorterItemCollection sii = new SorterItemCollection(); view.setSorter(sii); sii.add(new SorterItemInfo("number")); sii.get(0).setSortType(SortType.DESCEND); //设置f7过滤条件 prmtbox.setEntityViewInfo(view); prmtbox.getQueryAgent().resetRuntimeEntityView();
多语言文本框取值orm
txtDescription.getSelectedItemData();
打开新窗口对象
public static void openTabWin(CoreUI parentUI, Class clazz, Map params, String oprtState) throws Exception { UIContext uiContext = new UIContext(parentUI); uiContext.putAll(params); IUIWindow win = UIFactory.createUIFactory(UIFactoryName.NEWTAB).create(clazz.getName(), uiContext, null, oprtState); win.show(); }
去掉关闭eas页面时校验是否修改的提示排序
@Override public boolean checkBeforeWindowClosing() { return true; }
控件相关经常使用代码 end
KDTable经常使用代码 begin
表格行高度自适应 显示多行文本
//设置表格内容支持多行文本显示 tblMain.getStyleAttributes().setWrapText(true); //设置行高自适应 KDTableHelper.autoFitRowHeight(tblMain, _row.getRowIndex()); //ListUI能够这样处理 @Override protected void afterTableFillData(KDTDataRequestEvent e) { for (int i = e.getFirstRow(); i <= e.getLastRow(); i++) { KDTableHelper.autoFitRowHeight(tblMain, i); } }
表格滚动到某一行
table.getLayoutManager().scrollRowToShow(rowIndex);
格式化列数字显示格式
/** * 格式化指定的列为数字类型 * @param table * @param key 列名 * @param format */ public static void formatTableNumber(KDTable table, String key, String format) { table.getColumn(key).getStyleAttributes().setNumberFormat(format); table.getColumn(key).getStyleAttributes().setHorizontalAlign(Styles.HorizontalAlignment.RIGHT); }
设置点击列头自动排序
/** * 描述: 设置须要排序的列. * * @param tbl * @param keys 列名称 */ public static void setSortColumnKeys(KDTable tbl, String[] keys) { if (null == keys || 0 == keys.length) { return; } KDTSortManager sortManager = new KDTSortManager(tbl); sortManager.setSortAuto(true); sortManager.setClickCount(1); for (int i = 0; i < keys.length; i++) { IColumn col = tbl.getColumn(keys[i]); if (null == col) { continue; } col.setSortable(true); } }
设置表格冻结列
/** * 冻结列 * @param table * @param colname * @param rowindex */ public static void setTableFreeze(KDTable table, String colname) { if(table.getColumn(colname)!=null){ table.getViewManager().setFreezeView(-1,table.getColumnIndex(colname)+1); } }
设置table F7列的字段显示格式
ObjectValueRender ovr=new ObjectValueRender(); ovr.setFormat(new BizDataFormat("$number$/$name$")); myTable.getColumn("columnKey").setRenderer(ovr);
单据中的分录表格若是对应计算逻辑的事件时,用键盘的删除或复制功能操做表格会不进事件致使bug,处理方式为去除表格的复制删除等功能。
ActionMap actionMap = table.getActionMap(); actionMap.remove("Cut"); actionMap.remove("Delete"); actionMap.remove("Paste");
table新增右键菜单
/** * 描述:给table新增右键菜单,建议:在super.onLoad()以后调用 * * @param ui * 能够为"this" * @param table * 需绑定右键菜单的table * @param action * 需绑定的事件 * @param menuName * 菜单名 */ public static void appendMenuToTable(CoreUI ui, KDTable table, Action action, String menuName) { PopupMenuManager mgr; if (ui.getPopupMenuManager(table) != null) { mgr = ui.getPopupMenuManager(table); } else { mgr = ui.createPopupMenuManager(table); } MenuSection section = new MenuSection(menuName); mgr.addMenuSection(section); section = mgr.findMenuSection(menuName); action.putValue("Name", menuName); section.insertAfter(action); }
单据list表格 枚举字段自动转换为枚举名
IQueryExecutor executor = super.getQueryExecutor(queryPK, viewInfo); executor.option().isAutoTranslateEnum = true;
单据list表格 金额字段为0,不显示空白,显示0
IQueryExecutor executor = super.getQueryExecutor(queryPK, viewInfo); qe.option().isAutoIgnoreZero = false;
光标聚焦到单元格
tbl.getEditManager().editCellAt(row.getRowIndex(), colIndex);
KDTable经常使用代码 end