本文描述了通过xml方式创建自定义基础资料字段,以满足在设计器中配置超级F7对应的虚拟基础资料或报表数据源的需求。详细说明了xml文件的创建过程,包括SOI_ExtendModelProperty.xml和SOI_ExtendModelTemplate.xml等文件的内容及作用,并介绍了相关类的设计和实现。
需求
想要更简单的在设计器配置超级 F7 对应的虚拟基础资料或者报表数据源
思路
扩展元模型,创建自定义的基础资料字段。
实现过程
因为不满足实际需求,没有采用新版开发平台的模型扩展。使用 xml 方式创建字段元素。
resources 文件夹如下图创建文件,xml 文件前缀 SOI 对应变量 bos.extend.domains
字段属性 SOI_ExtendModelProperty.xml
可以参考源码 bos-metadata-xx.jar/EntityItemProperty.xml BaseEntityIdProper
Style 解释
Id 元素属性 Id
PropertyName 元素属性,对应设计器右上角 xml 打开看到的元数据 xml 中的节点 key
Name 元素属性名称,对应设计器右侧属性的标题
Description 元素属性描述,对应设计器右侧属性鼠标悬停时显示的文本
Editor
type btnedit 带三个点按钮的样式
form 配置点击弹出列表选择,modeltype 指定实体类型过滤条件 BaseFormModel 基础资料、ReportFormModel 报表
<Styles> <Style Id="SoiVmBaseEntityIdProperty"> <PropertyName>SoiVmBaseEntityId</PropertyName> <Seq>4</Seq> <Name>关联虚拟基础资料</Name> <Description>超级F7关联虚拟基础资料</Description> <Editor> {"type":"btnedit","form":{"formId":"bos_entityobject","showType":"ListType","modeltype":"BaseFormModel"},"extenddata":{"modeltype":"BaseFormModel"},"alias":true} </Editor> <Action></Action> <GroupId>2</GroupId> <GroupSubSeq>26</GroupSubSeq> </Style> <Style Id="SoiReportIdProperty"> <PropertyName>SoiReportId</PropertyName> <Seq>4</Seq> <Name>关联报表数据源</Name> <Description>超级F7关联报表数据源</Description> <Editor> {"type":"btnedit","form":{"formId":"bos_entityobject","showType":"ListType","modeltype":"ReportFormModel"},"extenddata":{"modeltype":"ReportFormModel"},"alias":true} </Editor> <Action></Action> <GroupId>2</GroupId> <GroupSubSeq>27</GroupSubSeq> </Style> </Styles>
字段 SOI_ExtendModelTemplate.xml
<?xml version="1.0" encoding="UTF-8"?> <Styles> <Style Id="CategoryBusinessField"> <ElementTypes> <ElementType style="SoiSuperF7Field"></ElementType> </ElementTypes> </Style> <Style Id="SoiField"> <PackageName>soi.ext.meta.field</PackageName> </Style> <Style Id="SoiSuperF7Field" style="BasedataField,SoiField"> <Id>SoiSuperF7Field</Id> <Name>超级F7基础资料</Name> <Properties> <Property style="SoiVmBaseEntityIdProperty"/> <Property style="SoiReportIdProperty"/> </Properties> </Style> </Styles>
元模型 SOI_ExtendBillForm.model
version 有更新需要修改
<?xml version="1.0" encoding="UTF-8"?> <DomainModelTypeDefiner> <TypeName>BillFormModel</TypeName> <Version>2024113005</Version> <ElementResources> <Resource> <FileName>SOI_ExtendModelTemplate.xml</FileName> </Resource> </ElementResources> <PropertyResources> <Resource> <FileName>SOI_ExtendModelProperty.xml</FileName> </Resource> </PropertyResources> </DomainModelTypeDefiner>
xml 创建完成后,需要对应三个类
设计时 SoiSuperF7Field
createServerEditor 创建元数据运行时类
createDynamicProperty 创建元数据实体类型
public class SoiSuperF7Field extends BasedataField { private String superF7VmBaseEntityId; private String superF7ReportId; @SimplePropertyAttribute public String getSoiVmBaseEntityId() { return superF7VmBaseEntityId; } public void setSoiVmBaseEntityId(String superF7VmBaseEntityId) { this.superF7VmBaseEntityId = superF7VmBaseEntityId; } @SimplePropertyAttribute public String getSoiReportId() { return superF7ReportId; } public void setSoiReportId(String superF7ReportId) { this.superF7ReportId = superF7ReportId; } @Override protected FieldEdit createServerEditor() { SoiSuperF7FieldEdit editor = new SoiSuperF7FieldEdit(); editor.setSoiVmBaseEntityId(getSoiVmBaseEntityId()); editor.setSoiReportId(getSoiReportId()); return editor; } @Override protected BasedataProp createDynamicProperty() { SoiSuperF7FieldProp prop = new SoiSuperF7FieldProp(); return prop; } }
运行时 SoiSuperF7FieldEdit
上一篇讲了表单页面 F7 在 BeforeF7SelectListener 修改弹出的 F7 列表 ListShowParameter 属性 formId、billFormId
实际 ListShowParameter 就是 createShowListForm 方法创建,重写 createShowListForm 替换 formId、billFormId
@DataEntityTypeAttribute(name = "soi.ext.meta.field.SoiSuperF7FieldEdit") public class SoiSuperF7FieldEdit extends BasedataEdit { private String superF7VmBaseEntityId; private String superF7ReportId; @SimplePropertyAttribute public String getSoiVmBaseEntityId() { return superF7VmBaseEntityId; } public void setSoiVmBaseEntityId(String superF7VmBaseEntityId) { DynamicObject dynamicObject = BusinessDataServiceHelper.loadSingleFromCache("bos_entityobject", new QFilter("dentityid", QCP.equals,superF7VmBaseEntityId).toArray()); this.superF7VmBaseEntityId = dynamicObject==null?null:dynamicObject.getString("number"); } @SimplePropertyAttribute public String getSoiReportId() { return superF7ReportId; } public void setSoiReportId(String superF7ReportId) { DynamicObject dynamicObject = BusinessDataServiceHelper.loadSingleFromCache("bos_entityobject", new QFilter("dentityid", QCP.equals,superF7ReportId).toArray()); this.superF7ReportId =dynamicObject==null?null:dynamicObject.getString("number"); } @Override protected ListShowParameter createShowListForm(BasedataProp prop) { ListShowParameter listShowParameter= super.createShowListForm(prop); if (StringUtils.isNotBlank(this.superF7VmBaseEntityId)) { listShowParameter.setBillFormId(this.superF7VmBaseEntityId); } listShowParameter.setFormId("soi_super_listf7_rpt"); listShowParameter.getCustomParams().put("report", this.superF7ReportId); return listShowParameter; } }
字段实体 SoiSuperF7FieldProp
@DataEntityTypeAttribute(name = "soi.ext.meta.field.SoiSuperF7FieldProp") public class SoiSuperF7FieldProp extends BasedataProp { private String superF7VmBaseEntityId; private String superF7ReportId; @SimplePropertyAttribute public String getSoiVmBaseEntityId() { return superF7VmBaseEntityId; } public void setSoiVmBaseEntityId(String superF7VmBaseEntityId) { this.superF7VmBaseEntityId = superF7VmBaseEntityId; } @SimplePropertyAttribute public String getSoiReportId() { return superF7ReportId; } public void setSoiReportId(String superF7ReportId) { this.superF7ReportId = superF7ReportId; } }
效果图
页面设计器可以看到已经加载【超级 F7 基础资料】
【超级 F7 基础资料】字段属性加载 【关联虚拟基础资料】、【关联报表数据源】
测试基础资料 F7 列表,显示报表数据的自定义列表
开发环境版本
v6.0
注意事项
参考资料
苍穹5.0模型扩展开发工具-控件开发案例:https://vip.kingdee.com/link/s/lPqjV
推荐阅读