场景:树表结构查不到二级模型内容,联动配置如下
问题:界面只显示部门,不显示岗位。
已知:
-
自定义部门代理模型继承了PamirsDepartment
@Model.model(DepartmentDoc.MODEL_MODEL) @Model.Advanced(type = ModelTypeEnum.PROXY) @Model(displayName = "部门资料代理模型", summary = "部门资料代理模型") public class DepartmentDoc extends PamirsDepartment { public static final String MODEL_MODEL = "top.DepartmentDoc"; @Field.many2one @Field(displayName = "上级部门") private DepartmentDoc parent; @Field.one2many @Field(displayName = "岗位列表") private List
positionLists; } -
自定义岗位代理模型继承了PamirsPosition
@Model.model(PositionDoc.MODEL_MODEL) @Model(displayName = "岗位代理模型", summary = "岗位代理模型") @Model.Advanced(type = ModelTypeEnum.PROXY) public class PositionDoc extends PamirsPosition { public static final String MODEL_MODEL = "top.PositionDoc"; @Field.many2one @Field(displayName = "上级岗位") private PositionDoc parent; }
-
首先查看控制台相应请求
-
找到请求接口进后端debug,pro.shushi.pamirs.boot.web.action.UiTreeAction#fetchChildren
-
检查这两个数据是否正常
-
继续debug可知,在queryWrapper中使用departmentCode没有查询出数据,这时候回看模型定义,发现岗位列表中没有定义关联字段,导致没有查出数据。pro.shushi.pamirs.boot.web.manager.tree.UiTreeRelationQueryManager#_fetchIsLeaf
-
解决:在模型配置中添加关系字段
@Field.Relation(relationFields = {"code"}, referenceFields = {"departmentCode"})
,并和父类中的关系字段保持一致
部门代理模型:
@Model.model(DepartmentDoc.MODEL_MODEL)
@Model.Advanced(type = ModelTypeEnum.PROXY)
@Model(displayName = "部门资料代理模型", summary = "部门资料代理模型")
public class DepartmentDoc extends PamirsDepartment {
public static final String MODEL_MODEL = "top.DepartmentDoc";
@Field.many2one
@Field.Relation(relationFields = {"parentCode"}, referenceFields = {"code"})
@Field(displayName = "上级部门")
private DepartmentDoc parent;
@Field.one2many
@Field.Relation(relationFields = {"code"}, referenceFields = {"departmentCode"})
@Field(displayName = "岗位列表")
private List<PositionDoc> positionLists;
}
岗位代理模型
@Model.model(PositionDoc.MODEL_MODEL)
@Model(displayName = "岗位代理模型", summary = "岗位代理模型")
@Model.Advanced(type = ModelTypeEnum.PROXY)
public class PositionDoc extends PamirsPosition {
public static final String MODEL_MODEL = "top.PositionDoc";
@Field.many2one
@Field.Relation(relationFields = {"departmentCode"}, referenceFields = {"code"})
@Field(displayName = "上级岗位")
private PositionDoc parent;
}
Oinone社区 作者:yexiu原创文章,如若转载,请注明出处:https://doc.oinone.top/wen-ti-zhen-duan/14856.html
访问Oinone官网:https://www.oinone.top获取数式Oinone低代码应用平台体验