驗證某個用戶是否擁有某個權限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