Skip to content

Commit

Permalink
feat: view-add n2nref
Browse files Browse the repository at this point in the history
  • Loading branch information
getrebuild committed Nov 8, 2023
1 parent dadbcd2 commit 86684ce
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -653,14 +653,10 @@ else if (dt == DisplayType.REFERENCE || dt == DisplayType.N2NREFERENCE) {
* @param initialVal 此值优先级大于字段默认值
*/
public void setFormInitialValue(Entity entity, JSON formModel, JSONObject initialVal) {
if (initialVal == null || initialVal.isEmpty()) {
return;
}
if (initialVal == null || initialVal.isEmpty()) return;

JSONArray elements = ((JSONObject) formModel).getJSONArray("elements");
if (elements == null || elements.isEmpty()) {
return;
}
if (elements == null || elements.isEmpty()) return;

// 已布局字段。字段是否布局会影响返回值
Set<String> inFormFields = new HashSet<>();
Expand Down Expand Up @@ -705,7 +701,7 @@ else if (field.equals(DV_MAINID)) {
// 其他
else if (entity.containsField(field)) {
EasyField easyField = EasyMetaFactory.valueOf(entity.getField(field));
if (easyField.getDisplayType() == DisplayType.REFERENCE) {
if (easyField.getDisplayType() == DisplayType.REFERENCE || easyField.getDisplayType() == DisplayType.N2NREFERENCE) {

// v3.4 如果字段设置了附加过滤条件,从相关项新建时要检查是否符合
String dataFilter = easyField.getExtraAttr(EasyFieldConfigProps.REFERENCE_DATAFILTER);
Expand All @@ -723,9 +719,16 @@ else if (entity.containsField(field)) {

Object mixValue = inFormFields.contains(field) ? getReferenceMixValue(value) : value;
if (mixValue != null) {
initialValReady.put(field, mixValue);
if (easyField.getDisplayType() == DisplayType.REFERENCE) {
initialValReady.put(field, mixValue);
} else {
// N2N 是数组
initialValReady.put(field,
inFormFields.contains(field) ? new Object[] { mixValue } : value);
}
}
}

} else {
log.warn("Unknown value pair : " + field + " = " + value);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,9 +163,9 @@ private JSONObject getViewAddons(String entity, ID user, String applyType) {
if (!MetadataHelper.isBusinessEntity(e)) continue;
if (ArrayUtils.contains(entityMeta.getDetialEntities(), e)) continue;

// 新建项无明细、多引用
// 新建项排除明细
if (TYPE_ADD.equals(applyType)) {
if (e.getMainEntity() != null || field.getType() != FieldType.REFERENCE) continue;
if (e.getMainEntity() != null) continue;
}

Entity eCheck = ObjectUtils.defaultIfNull(e.getMainEntity(), e);
Expand Down

0 comments on commit 86684ce

Please sign in to comment.