Commit cd8fd7d1 authored by 刘凡's avatar 刘凡

*)子表单逻辑

parent 833d6cd5
...@@ -103,7 +103,7 @@ public class DPSubServiceImpl { ...@@ -103,7 +103,7 @@ public class DPSubServiceImpl {
this.buildSubContentData(map, i, yObj, mergedArray, apiResult); this.buildSubContentData(map, i, yObj, mergedArray, apiResult);
} }
} else if("subForm".equals(yObj.get("componentKey"))) { // 子表单 } else if("subForm".equals(yObj.get("componentKey"))) { // 子表单
this.buildSubFormData(map, i, yObj, apiResult);
} else if("formTable".equals(yObj.get("componentKey"))){ } else if("formTable".equals(yObj.get("componentKey"))){
map = new JSONObject(); map = new JSONObject();
map.put("columns", JsonValueUtils.getValueByKey(yObj, "visualParams", "visualParams.modelTableColumns")); map.put("columns", JsonValueUtils.getValueByKey(yObj, "visualParams", "visualParams.modelTableColumns"));
...@@ -306,7 +306,7 @@ public class DPSubServiceImpl { ...@@ -306,7 +306,7 @@ public class DPSubServiceImpl {
} }
public JSONObject buildSubContentData(JSONObject map, int i, JSONObject yObj, List<Object> mergedArray, JSONObject apiResult){ public JSONObject buildSubContentData(JSONObject map, int i, JSONObject yObj, List<Object> mergedArray, JSONObject apiResult){
JSONArray jsonArray = map.getJSONArray("subs"); JSONArray subs = map.getJSONArray("subs");
JSONArray children = yObj.getJSONArray("children"); JSONArray children = yObj.getJSONArray("children");
List<Object> columnsArray = children.stream().filter(x -> { List<Object> columnsArray = children.stream().filter(x -> {
JSONObject xObj = (JSONObject) x; JSONObject xObj = (JSONObject) x;
...@@ -352,7 +352,38 @@ public class DPSubServiceImpl { ...@@ -352,7 +352,38 @@ public class DPSubServiceImpl {
subObj.put("datas", datas); subObj.put("datas", datas);
} }
}); });
jsonArray.add(subObj); subs.add(subObj);
return map;
}
public JSONObject buildSubFormData(JSONObject map, int i, JSONObject yObj, JSONObject apiResult){
JSONArray subs = map.getJSONArray("subs");
JSONArray children = yObj.getJSONArray("children");
JSONObject subObj = new JSONObject();
subObj.put("key", "key" + i);
subObj.put("displayName", JsonValueUtils.getValueByKey(yObj, "visualParams", "visualParams.label"));
subObj.put("renderType", "table");
List<Object> noHiddenChildren = children.stream().filter(x -> {
JSONObject xObj = (JSONObject) x;
return !"hidden".equals(JsonValueUtils.getValueByKey(xObj, "visualParams", "visualParams.behavior"));
}).collect(Collectors.toList());
List<JSONObject> columns = noHiddenChildren.stream().map(x -> {
JSONObject xObj = (JSONObject) x;
JSONObject visualParams = xObj.getJSONObject("visualParams");
JSONObject jsonObject = new JSONObject();
jsonObject.put("key", xObj.get("eid"));
jsonObject.put("dataIndex", visualParams.get("fieldKey"));
jsonObject.put("title", visualParams.get("label"));
return jsonObject;
}).collect(Collectors.toList());
subObj.put("columns", columns);
subObj.put("dataList", apiResult.get(JsonValueUtils.getValueByKey(yObj, "visualParams", "visualParams.fieldKey")));
subs.add(subObj);
return map; return map;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment