String name = e.getProperty().getName(); //获取单据体值变化的属性名称 int rowIndex = e.getChangeSet()[0].getRowIndex(); //获取单据体值变化的行 long orgId = RequestContext.get().getOrgId(); //获取当前登录组织 long orgId = RequestContext.get().getOrgId(); //获取当前登录用户 String billNo = CodeRuleServiceHelper.getNumber(BdBatchConstant.FORMBILLID, info, null); //获取单据编码 String[] billnos = CodeRuleServiceHelper.getBatchNumber(BdBatchConstant.FORMBILLID, info, null,5);//批量获取单据编码 this.getView().invokeOperation("refresh"); //调用刷新按钮 this.getView().setEnable(false,new String[]{"name", "number}); //控件是否可编辑 this.getView().setVisible(Boolean.FALSE, new String[]{ZB_PIGFARM, ZB_PIGFIELD}); //隐藏 ((FieldEdit) this.getControl(ZB_PIGFARM)).setMustInput(false); //设置必录 HashMap<String, Object> itemMap = new HashMap<>(); itemMap.put(ClientProperties.Editable, true); //设置文本是否可编辑的属性 itemMap.put(ClientProperties.ShowEditButton, true); //设置文本是否展示点击按钮的属性 fieldMap.put(ClientProperties.BackColor, "green"); //设置背景色 this.getView().updateView("控件名称"); //刷新指定控件 fieldMap.put("item", itemMap); //把属性添加到控件中 this.getView().updateControlMetadata("kdec_textfield", fieldMap); //同步指定元数据到文本控件
//设置日期格式 this.getView().updateControlMetadata(CommonRptConst.SBT_STARTDATE, MapUtil.of(ClientProperties.Item, MapUtil.of(ClientProperties.Mask, "YYYY-MM")));
int rowIndex = this.getModel()getEntryCurrentRowIndex("key") //获取焦点行索引
int entryRowCount = this.getModel().getEntryRowCount("key"); //获取总行数
this.getModel().deleteEntryData("key"); //删除行
this.getModel().deleteEntryRow("key", rowIndex); //删除制定行
this.getModel().createNewEntryRow("key"); //新增行
this.getModel().batchCreateNewEntryRow("key", rows); //批量新增行
EntryGrid entryGrid = this.getControl("treeentryentity"); //设置单据体指定行的背景色
entryGrid.setRowBackcolor("yellow", new int[]{0}); //设置单据体指定单元格的背景色
ArrayList<CellStyle> cellStyles = new ArrayList<>();
CellStyle cellStyle = new CellStyle();
cellStyle.setFieldKey("textfield1");
cellStyle.setRow(0); cellStyle.setBackColor("blue");
cellStyles.add(cellStyle);
entryGrid.setCellStyle(cellStyles);
BillList list = this.getControl("");
//获取选中行IDS
Object[] pks = list.getSelectedRows().getPrimaryKeyValues();
EntityType type = list.getEntityType();
//删除刷新
DeleteServiceHelper.delete(type, pks);
list.refreshData();
sys_gid(1,1)//sql获取单据ID
//使用列子
INSERT INTO yzpc.tk_zb_pc_batchpig ( fid, fk_zb_code) values (sys_gid(1,1), "224331")
//枚举构建
String productionType = OrgUnitUtil.getProductionType(RequestContext.get().getOrgId());
//免疫类型下拉项:默认为后备免疫和补免
List<ComboItem> comboItems = new ArrayList<>();
if (ProductionTypeEnum.FATTEN_FARM.getValue().equals(productionType) || ProductionTypeEnum.FATTEN_FIELD.getValue().equals(productionType)) {
comboItems.add(ImmuTypeEnum.ROUTINE_IMMUNITY.buildComboItem());
comboItems.add(ImmuTypeEnum.EMERGENCY_IMMUNITY.buildComboItem());
ComboEdit comboEdit = this.getControl(ZB_IMMUTYPE);
comboEdit.setComboItems(comboItems);
this.getView().setEnable(true, new String[]{ZB_IMMUTYPE});
}else {
comboItems.add(ImmuTypeEnum.RESERVE_IMMUNITY.buildComboItem());
ComboEdit comboEdit = this.getControl(ZB_IMMUTYPE);
comboEdit.setComboItems(comboItems);
}
this.getView().setEnable(false, i, "xxx"); //设置单据行不可能编辑
//IFarme控件 链接嵌入
String url="https://www.biadu.com"
IFrame iFrame=this.getview().getcontrol("key");
IFrameMessage message=new IFrameMessage();件
message.setContent("green");
message.setType("anything");
message.setorigin("*");
iFrame.setSrc(url);
iFrame.postMessage(message);
//对象查询过滤
QFilter statusFilter = new QFilter(BaseConstant.STATUS, QCP.equals, STATUS_AUDITED);
QFilter enableFilter = new QFilter(BaseConstant.ENABLE, QCP.equals, Boolean.TRUE);
QFilter filter = new QFilter(KEY_PARENT, QCP.equals, parentId);
QFilter[] qFilters = new QFilter[]{statusFilter, enableFilter, filter};
String orderBy = "createtime asc";
String fields = "id, number, name, longnumber, level, fullname, isleaf, parent";
DynamicObject[] objects = BusinessDataServiceHelper.load("zb_pc_ingredientstype", fields, qFilters, orderBy);
//对象查询过滤
QFilter statusFilter = new QFilter(BaseConstant.STATUS, QCP.equals, STATUS_AUDITED);
QFilter enableFilter = new QFilter(BaseConstant.ENABLE, QCP.equals, Boolean.TRUE);
QFilter filter = new QFilter(KEY_PARENT, QCP.equals, parentId);
QFilter[] qFilters = new QFilter[]{statusFilter, enableFilter, filter};
String orderBy = "createtime asc";
String fields = "id, number, name, longnumber, level, fullname, isleaf, parent";
DynamicObject[] objects = BusinessDataServiceHelper.load("zb_pc_ingredientstype", fields, qFilters, orderBy);
//根据ID查询
BusinessDataServiceHelper.loadSingle(colls[0].getPkValue(), FORMBILLID, ALLPROPERTY);
//枚举构建
String productionType = OrgUnitUtil.getProductionType(RequestContext.get().getOrgId());
//免疫类型下拉项:默认为后备免疫和补免
List<ComboItem> comboItems = new ArrayList<>();
if (ProductionTypeEnum.FATTEN_FARM.getValue().equals(productionType) || ProductionTypeEnum.FATTEN_FIELD.getValue().equals(productionType)) {
comboItems.add(ImmuTypeEnum.ROUTINE_IMMUNITY.buildComboItem());
comboItems.add(ImmuTypeEnum.EMERGENCY_IMMUNITY.buildComboItem());
ComboEdit comboEdit = this.getControl(ZB_IMMUTYPE);
comboEdit.setComboItems(comboItems);
this.getView().setEnable(true, new String[]{ZB_IMMUTYPE});
}else {
comboItems.add(ImmuTypeEnum.RESERVE_IMMUNITY.buildComboItem());
ComboEdit comboEdit = this.getControl(ZB_IMMUTYPE);
comboEdit.setComboItems(comboItems);
this.getView().setEnable(false, new String[]{ZB_IMMUTYPE});
}
//对象查询过滤
QFilter statusFilter = new QFilter(BaseConstant.STATUS, QCP.equals, STATUS_AUDITED);
QFilter enableFilter = new QFilter(BaseConstant.ENABLE, QCP.equals, Boolean.TRUE);
QFilter filter = new QFilter(KEY_PARENT, QCP.equals, parentId);
QFilter[] qFilters = new QFilter[]{statusFilter, enableFilter, filter};
String orderBy = "createtime asc";
String fields = "id, number, name, longnumber, level, fullname, isleaf, parent";
DynamicObject[] objects = BusinessDataServiceHelper.load("zb_pc_ingredientstype", fields, qFilters, orderBy);
//对象查询过滤
QFilter statusFilter = new QFilter(BaseConstant.STATUS, QCP.equals, STATUS_AUDITED);
QFilter enableFilter = new QFilter(BaseConstant.ENABLE, QCP.equals, Boolean.TRUE);
QFilter filter = new QFilter(KEY_PARENT, QCP.equals, parentId);
QFilter[] qFilters = new QFilter[]{statusFilter, enableFilter, filter};
String orderBy = "createtime asc";
String fields = "id, number, name, longnumber, level, fullname, isleaf, parent";
DynamicObject[] objects = BusinessDataServiceHelper.load("zb_pc_ingredientstype", fields, qFilters, orderBy);
//根据ID查询
BusinessDataServiceHelper.loadSingle(colls[0].getPkValue(), FORMBILLID, ALLPROPERTY);
//F7的过滤
/**
* 注册监听
* @param e
*/
@Override
public void registerListener(EventObject e) {
super.registerListener(e);
//栋舍
BasedataEdit buildingEdit = this.getControl(WaterCleanConstant.ZB_BUILDING);
if(buildingEdit != null){
buildingEdit.addBeforeF7SelectListener(new BeforeF7SelectListener() {
@Override
public void beforeF7Select(BeforeF7SelectEvent beforeF7SelectEvent) {
buildingF7Filter(beforeF7SelectEvent);
}
});
}
}
@Override
public void beforeF7Select(BeforeF7SelectEvent beforeF7SelectEvent) {
// String name = beforeF7SelectEvent.getProperty().getName();
// switch(name) {
// case RunRecordConstant.RUNRECORDPIG_ET_ZB_BUILDING:
// buildingF7Filter(beforeF7SelectEvent);
// break;
// default:
// break;
// }
}
/**
* 栋舍F7过滤
* @param evt
*/
private void buildingF7Filter(BeforeF7SelectEvent evt) {
ListShowParameter listShowParameter = (ListShowParameter) evt.getFormShowParameter();
List<QFilter> qFilters = listShowParameter.getListFilterParameter().getQFilters();
//根据分场过滤栋舍档案
DynamicObject fieldOb = (DynamicObject) this.getModel().getValue(WaterCleanConstant.ZB_PIGFIELD);
if(fieldOb != null){
qFilters.add(new QFilter("zb_pigfieldname.id", QCP.equals, fieldOb.get("id")));
qFilters.add(new QFilter(BaseConstant.STATUS, QCP.equals, BillStatusEnum.AUDIT.getValue()));
qFilters.add(new QFilter(BaseConstant.ENABLE, QCP.equals, Boolean.TRUE));
}else{
qFilters.add(new QFilter("zb_pigfieldname.id", QCP.equals, null));
}
}
页面跳转:
@Override
public void click(EventObject evt) {
super.click(evt);
Control source=(Control)evt.getSource();
if (StringUtils.equals(SaleBillConstant.Salebill_piget_Pigarchives, source.getKey())) {
EntryGrid entryGrid = this.getView().getControl(SaleBillConstant.EntryEntityId_zb_ps_salebill_et);
int[] rowIndexs = entryGrid.getSelectRows();
if(rowIndexs.length<1){
this.getView().showMessage("请先点击一条分录行");
return;
}
//创建弹出页面对象,FormShowParameter表示弹出页面为动态表单
FormShowParameter showParameter = new FormShowParameter();
showParameter.setFormId(SaleBillConstant.SalepigArchives);
//设置参数
//耳牌号
DynamicObject entryRowEntity = this.getModel().getEntryRowEntity(SaleBillConstant.EntryEntityId_zb_ps_salebill_et, rowIndexs[0]);
DynamicObject batchfile = entryRowEntity.getDynamicObject(SaleBillConstant.Salebill_et_Batchfile);
if(Objects.isNull(batchfile)){
showParameter.setCustomParam(SaleBillConstant.Salebill_et_Batchfile,null);
}else{
showParameter.setCustomParam(SaleBillConstant.Salebill_et_Batchfile, batchfile.getLong("id"));
}
//猪场
DynamicObject pigframInfo = (DynamicObject) this.getModel().getValue(SaleBillConstant.Pigfram);
if(pigframInfo!=null) {
DynamicObject[] pigfarm = BusinessDataServiceHelper.load("zb_pc_pigfarm", "id", new QFilter("zb_stockorg.id", QCP.equals, pigframInfo.getLong("id")).toArray());
if (pigfarm.length > 0){
showParameter.setCustomParam(SaleBillConstant.Pigfram, pigfarm[0].getLong("id"));
}else{
this.getView().showErrorNotification("当前猪场组织查找不到猪场档案");
return;
}
//分场
if(this.getModel().getValue(SaleBillConstant.Pigfield)!=null &&
!"".equals(this.getModel().getValue(SaleBillConstant.Pigfield))){
DynamicObject pigfieldInfo = (DynamicObject) this.getModel().getValue(SaleBillConstant.Pigfield);
DynamicObject[] pigfield = BusinessDataServiceHelper.load("zb_pc_pigfield", "id", new QFilter("zb_stockorg.id", QCP.equals, pigfieldInfo.getLong("id")).toArray());
if (pigfield.length > 0) {
showParameter.setCustomParam(SaleBillConstant.Pigfield, pigfield[0].getLong("id"));
}else{
this.getView().showErrorNotification("当前分场组织查找不到分场档案");
return;
}
}else{
showParameter.setCustomParam(SaleBillConstant.Pigfield,null);
}
//设置选择模式
showParameter.setCustomParam("selectType",0);
this.getPageCache().put("selectType","0");
//CloseCallBack参数:回调插件,回调标识
showParameter.setCloseCallBack(new CloseCallBack(this, SaleBillConstant.Salebill_piget_Pigarchives));
//设置弹出页面打开方式,支持模态,新标签等
showParameter.getOpenStyle().setShowType(ShowType.Modal);
//弹出页面对象赋值给父页面
this.getView().showForm(showParameter);
}
}
}
//1. 弹出动态表单-FormShowParameter
//创建弹出页面对象,FormShowParameter表示弹出页面为动态表单
FormShowParameter showParameter = new FormShowParameter();
//设置弹出哪个动态表单
showParameter.setFormId("kded_suppliesapplynew");
//设置弹出页面标题
showParameter.setCaption("物品新增申请界面");
//设置子页面关闭回调参数,回调标识为XXX
showParameter.setCloseCallBack(new CloseCallBack(this,"XXX"));
//设置弹出页面的打开方式,支持模态,新标签等
showParameter.getOpenStyle().setShowType(ShowType.Modal);
//设置弹出页面的大小,高600宽800
StyleCss inlineStyleCss = new StyleCss();
inlineStyleCss.setHeight("600");
inlineStyleCss.setWidth("800");
showParameter.getOpenStyle().setInlineStyleCss(inlineStyleCss);
//弹出动态表单页面
this.getView().showForm(showParameter);
备注:其他弹出界面的设置页面关闭回调参数、设置弹出页面的大小样式都是一样的代码,后面可能不会重复写。
//2.弹出单据界面-BillShowParameter
//创建弹出单据页面对象,BillShowParameter 表示弹出页面为单据页面
BillShowParameter billShowParameter = new BillShowParameter();
//设置弹出的单据标识
billShowParameter.setFormId("kded_supsinventorybill");
//设置弹出单据页面的标题
billShowParameter.setCaption("办公用品库存单列表界面");
//设置弹出单据的pk,如没有这行,则打开的是单据新增界面
billShowParameter.setPkId(KEY_PKID);
//设置弹出单据页面的打开方式
billShowParameter.getOpenStyle().setShowType(ShowType.Modal);
//设置弹出单据页面的大小,高600宽800
StyleCss inlineStyleCss = new StyleCss();
inlineStyleCss.setHeight("600");
inlineStyleCss.setWidth("800");
billShowParameter.getOpenStyle().setInlineStyleCss(inlineStyleCss);
//弹出单据页面
this.getView().showForm(billShowParameter);
//弹出列表界面-ListShowParameter
//创建弹出列表界面对象,ListShowParameter 表示弹出页面为列表界面
ListShowParameter listShowParameter = new ListShowParameter();
//设置FormId,列表的FormId固定为"bos_list"
listShowParameter.setFormId("bos_list");
//设置BillFormId,为列表所对应单据的标识
listShowParameter.setBillFormId("kded_supsinventorybill");
//设置弹出页面标题
listShowParameter.setCaption("办公用品库存单列表界面");
//设置弹出页面的打开方式
listShowParameter.getOpenStyle().setShowType(ShowType.Modal);
//设置为不能多选,如果为true则表示可以多选
listShowParameter.setMultiSelect(false);
//设置子页面关闭回调参数,回调标识为XXX
listShowParameter.setCloseCallBack(new CloseCallBack(this, "XXX"));
//弹出列表界面
this.getView().showForm(listShowParameter);
//弹出F7选择界面
//创建弹出列表界面对象,ListShowParameter 表示弹出页面为列表界面
ListShowParameter listShowParameter = new ListShowParameter();
//设置F7列表表单模板
listShowParameter.setFormId("bos_templatetreelistf7");
//设置BillFormId为基础资料的标识
listShowParameter.setBillFormId("kded_supplies");
//设置弹出页面标题
listShowParameter.setCaption("物品F7选择界面");
//设置弹出页面的打开方式
listShowParameter.getOpenStyle().setShowType(ShowType.Modal);
//设置打开页面的大小
StyleCss inlineStyleCss = new StyleCss();
inlineStyleCss.setHeight("580");
inlineStyleCss.setWidth("960");
listShowParameter.getOpenStyle().setInlineStyleCss(inlineStyleCss);
//设置为不能多选,如果为true则表示可以多选
listShowParameter.setMultiSelect(true);
//LookUp必须为true,该界面才是可选界面
listShowParameter.setLookUp(true);
//是否只显示审核的数据
listShowParameter.setShowApproved(true);
//是否只显示只启用的数据
listShowParameter.setShowUsed(true);
//设置子页面关闭回调参数,回调标识为XXX setControlKey用来设置f7选择的数据返回给哪个字段
CloseCallBack closeCallBack =new CloseCallBack(this, "kded_addf7");
closeCallBack.setControlKey("kded_supplies");
listShowParameter.setCloseCallBack(closeCallBack);
//弹出F7选择界面
this.getView().showForm(listShowParameter);