Browse Source

master
郑根木 2 years ago
parent
commit
e58ae00787
3 changed files with 16 additions and 8 deletions
  1. +12
    -4
      smtweb-framework/sw-framework-core/src/main/java/cc/smtweb/framework/core/util/JsonUtil.java
  2. +1
    -1
      smtweb-system/sw-system-bpm/src/main/java/cc/smtweb/system/bpm/web/design/form/ModelFormHelper.java
  3. +3
    -3
      smtweb-system/sw-system-bpm/src/main/resources/static/template/incModel/inc_model.ftl

+ 12
- 4
smtweb-framework/sw-framework-core/src/main/java/cc/smtweb/framework/core/util/JsonUtil.java View File

@@ -24,10 +24,7 @@ import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import java.sql.Timestamp; import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.*;


import static org.springframework.beans.BeanUtils.getPropertyDescriptors; import static org.springframework.beans.BeanUtils.getPropertyDescriptors;


@@ -285,4 +282,15 @@ public class JsonUtil {
throw new JsonParseException("can't convert type " + obj.getClass() + " to json string", e); throw new JsonParseException("can't convert type " + obj.getClass() + " to json string", e);
} }
} }

public static SwMap bean2Map(Object obj) {
return parse(encodeString(obj), SwMap.class);
}

public static List<SwMap> bean2MapList(Object obj) {
List<SwMap> list = new ArrayList<>();
SwMap[] arr = parse(encodeString(obj), SwMap[].class);
Collections.addAll(list, arr);
return list;
}
} }

+ 1
- 1
smtweb-system/sw-system-bpm/src/main/java/cc/smtweb/system/bpm/web/design/form/ModelFormHelper.java View File

@@ -374,7 +374,7 @@ public class ModelFormHelper {
PageDatasets datasets = form.getDatasets(); PageDatasets datasets = form.getDatasets();
SwMap tmplModel = JsonUtil.parse(form.getTmpl(), SwMap.class); SwMap tmplModel = JsonUtil.parse(form.getTmpl(), SwMap.class);
tmplModel.put("title", form.getTitle()); tmplModel.put("title", form.getTitle());
tmplModel.put("datasets", form.getDatasets());
tmplModel.put("datasets", JsonUtil.bean2MapList(form.getDatasets().list));
SwMap layout = tmplModel.readMap("layout"); SwMap layout = tmplModel.readMap("layout");
//用到的自定义控件 //用到的自定义控件
Set<Long> setWidget = new HashSet<>(); Set<Long> setWidget = new HashSet<>();


+ 3
- 3
smtweb-system/sw-system-bpm/src/main/resources/static/template/incModel/inc_model.ftl View File

@@ -2,12 +2,12 @@
"dataset": "${dataset.id}", "dataset": "${dataset.id}",
"label": "${dataset.label}", "label": "${dataset.label}",
"fields": [ "fields": [
<#list fields as field>
<#list dataset.fields as field>
{ {
"id": "${field.id}", "id": "${field.id}",
"field": "${field.field}"<#if field.widget gt 0>, "field": "${field.field}"<#if field.widget gt 0>,
"lookup": { "lookup": {
"widgetId": "${field.widget}",
"widgetId": "${field.widget?c}",
"widgetId_text": "${field.widgetText}", "widgetId_text": "${field.widgetText}",
"filters": [] "filters": []
} }
@@ -16,7 +16,7 @@
</#list> </#list>
], ],
"filters": [ "filters": [
<#list filters as field>
<#list dataset.filters as field>
{ {
"id": "${field.field}", "id": "${field.field}",
"field": "${field.field}", "field": "${field.field}",


Loading…
Cancel
Save