Bladeren bron

页面设计

master
郑根木 2 jaren geleden
bovenliggende
commit
3bd471a256
17 gewijzigde bestanden met toevoegingen van 216 en 107 verwijderingen
  1. +66
    -0
      smtweb-system/sw-system-bpm/src/main/java/cc/smtweb/system/bpm/web/design/form/ModelForm.java
  2. +13
    -0
      smtweb-system/sw-system-bpm/src/main/java/cc/smtweb/system/bpm/web/design/form/ModelFormCache.java
  3. +43
    -26
      smtweb-system/sw-system-bpm/src/main/java/cc/smtweb/system/bpm/web/design/form/ModelFormHelper.java
  4. +2
    -2
      smtweb-system/sw-system-bpm/src/main/java/cc/smtweb/system/bpm/web/design/form/ModelFormLoadHandler.java
  5. +3
    -4
      smtweb-system/sw-system-bpm/src/main/java/cc/smtweb/system/bpm/web/design/form/ModelFormSaveHandler.java
  6. +31
    -14
      smtweb-system/sw-system-bpm/src/main/java/cc/smtweb/system/bpm/web/design/form/define/PageDataset.java
  7. +0
    -1
      smtweb-system/sw-system-bpm/src/main/java/cc/smtweb/system/bpm/web/design/form/define/PageDatasetField.java
  8. +11
    -0
      smtweb-system/sw-system-bpm/src/main/java/cc/smtweb/system/bpm/web/design/form/define/PageDatasets.java
  9. +5
    -3
      smtweb-system/sw-system-bpm/src/main/java/cc/smtweb/system/bpm/web/engine/dynPage/AbstractDynPageHandler.java
  10. +1
    -1
      smtweb-system/sw-system-bpm/src/main/java/cc/smtweb/system/bpm/web/engine/dynPage/DynPageHelper.java
  11. +0
    -22
      smtweb-system/sw-system-bpm/src/main/resources/static/template/incModel/inc_dataset.ftl
  12. +4
    -2
      smtweb-system/sw-system-bpm/src/main/resources/static/template/incModel/inc_filter.ftl
  13. +4
    -2
      smtweb-system/sw-system-bpm/src/main/resources/static/template/incModel/inc_form.ftl
  14. +1
    -1
      smtweb-system/sw-system-bpm/src/main/resources/static/template/incModel/inc_grid_opt.ftl
  15. +28
    -0
      smtweb-system/sw-system-bpm/src/main/resources/static/template/incModel/inc_model.ftl
  16. +2
    -1
      smtweb-system/sw-system-bpm/src/main/resources/static/template/model_simple.ftl
  17. +2
    -28
      smtweb-system/sw-system-bpm/src/test/java/cc/smtweb/system/bpm/test/ModelFormTest.java

+ 66
- 0
smtweb-system/sw-system-bpm/src/main/java/cc/smtweb/system/bpm/web/design/form/ModelForm.java Bestand weergeven

@@ -1,7 +1,10 @@
package cc.smtweb.system.bpm.web.design.form;

import cc.smtweb.framework.core.annotation.SwTable;
import cc.smtweb.framework.core.common.SwMap;
import cc.smtweb.framework.core.db.impl.DefaultEntity;
import cc.smtweb.system.bpm.web.design.form.define.PageDatasets;
import cc.smtweb.system.bpm.web.design.form.define.PageModel;

/**
* Created by Akmm at 2022/4/15 17:26
@@ -9,6 +12,66 @@ import cc.smtweb.framework.core.db.impl.DefaultEntity;
@SwTable("ASP_MODEL_FORM")
public class ModelForm extends DefaultEntity {
public static final String ENTITY_NAME = "ASP_MODEL_FORM";
//将相关信息缓存起来
private transient long masterTableId = -1;
private transient PageDatasets datasets;
private transient SwMap opts;

public void clearEx() {
masterTableId = -1L;
datasets = null;
opts = null;
}

public long getMasterTableId() {
if (masterTableId < 0) {
synchronized (ModelForm.class) {
if (masterTableId < 0) {
datasets = ModelFormHelper.parsePageDataset(getDataset());
if (datasets == null) {
masterTableId = 0;
} else {
masterTableId = datasets.findMasterTableId();
}
}
}
}
return masterTableId;
}

public void setMasterTableId(long masterTableId) {
this.masterTableId = masterTableId;
}

public PageDatasets getDatasets() {
if (datasets == null) {
synchronized (ModelForm.class) {
if (datasets == null) {
datasets = ModelFormHelper.parsePageDataset(getDataset());
}
}
}
return datasets;
}

public void setDatasets(PageDatasets datasets) {
this.datasets = datasets;
}

public SwMap getOpts() {
if (opts == null) {
synchronized (ModelForm.class) {
if (opts == null) {
opts = ModelFormHelper.parseFormOption(getOption());
}
}
}
return opts;
}

public void setOpts(SwMap opts) {
this.opts = opts;
}

public ModelForm() {
super(ENTITY_NAME);
@@ -84,6 +147,7 @@ public class ModelForm extends DefaultEntity {

public void setOption(String mf_option) {
put("mf_option", mf_option);
opts = null;
}

public String getTmpl() {
@@ -100,6 +164,8 @@ public class ModelForm extends DefaultEntity {

public void setDataset(String mf_dataset) {
put("mf_dataset", mf_dataset);
datasets = null;
masterTableId = 0L;
}

public long getCreateUid() {


+ 13
- 0
smtweb-system/sw-system-bpm/src/main/java/cc/smtweb/system/bpm/web/design/form/ModelFormCache.java Bestand weergeven

@@ -3,6 +3,7 @@ package cc.smtweb.system.bpm.web.design.form;
import cc.smtweb.framework.core.annotation.SwCache;
import cc.smtweb.framework.core.cache.AbstractCache;
import cc.smtweb.framework.core.cache.CacheManager;
import cc.smtweb.framework.core.common.SwConsts;
import cc.smtweb.framework.core.db.DbEngine;
import cc.smtweb.framework.core.db.EntityDao;

@@ -19,6 +20,7 @@ public class ModelFormCache extends AbstractCache<ModelForm> {
private final static String mk = "k";
private final static String mp = "prj";
private final static String mc = "c";
private final static String mt = "t";

public static ModelFormCache getInstance() {
return CacheManager.getIntance().getCache(ModelFormCache.class);
@@ -28,6 +30,7 @@ public class ModelFormCache extends AbstractCache<ModelForm> {
regMap(mk, k-> k.getName().toUpperCase());
regList(mp, k-> String.valueOf(k.getPrjId()));
regList(mc, k-> String.valueOf(k.getMcId()));
regList(mt, k-> k.getMasterTableId() + SwConsts.SPLIT_CHAR + k.getType());
// regList(mf, k-> k.get);
}

@@ -69,4 +72,14 @@ public class ModelFormCache extends AbstractCache<ModelForm> {
list.sort(comparator);
return list;
}

//根据表id,找对应的页面设计
public Set<ModelForm> getListByTable(long tableId, int type) {
return getListByKey(mt, tableId + SwConsts.SPLIT_CHAR + type);
}

public String getText(long id) {
ModelForm form = get(id);
return form != null ? form.getTitle() : String.valueOf(id);
}
}

+ 43
- 26
smtweb-system/sw-system-bpm/src/main/java/cc/smtweb/system/bpm/web/design/form/ModelFormHelper.java Bestand weergeven

@@ -46,11 +46,11 @@ public class ModelFormHelper {
return cache.get(formId);
}

public static PageDatasets parsePageDataset(long formId) {
/*public static PageDatasets parsePageDataset(long formId) {
ModelForm form = getFromCache(formId);
if (form == null) return null;
return parsePageDataset(form.getDataset());
}
}*/

public static PageDatasets parsePageDataset(String jsonStr) {
if (StringUtils.isEmpty(jsonStr)) return null;
@@ -83,9 +83,9 @@ public class ModelFormHelper {
* @param form
* @return
*/
public static String buildSaveModel(ModelForm form) {
PageDatasets datasets = parsePageDataset(form.getDataset());
PageModel pageInfo = parsePageInfo(form.getContent());
public static String buildSaveModel(ModelForm form, String jsonStr) {
PageDatasets datasets = form.getDatasets();
PageModel pageInfo = parsePageInfo(jsonStr);
if (pageInfo == null) return "";
for (Map<String, Object> model : pageInfo.model) {
buildSaveModelFields(datasets, pageInfo, model, true);
@@ -106,7 +106,7 @@ public class ModelFormHelper {
for (Map<String, Object> field : fields) {
String fn = (String) field.get("field");
if (StringUtils.isEmpty(fn)) throw new SwException("model[" + db + "]." + key + "未配置字段名field,无法解析!");
PageDatasetField pdf = isField ? pds.getField(fn) : pds.getFilter(fn);
PageDatasetField pdf = isField ? pds.findFieldByName(fn) : pds.findFilterByName(fn);
if (pdf == null) throw new SwException("model[" + db + "]." + key + "未找到定义的数据集字段(" + fn + "),无法解析!");

if (CommUtil.isStrEquals(MapUtil.readString(field, "label"), pdf.label)) {
@@ -171,8 +171,7 @@ public class ModelFormHelper {
* @return
* @throws JsonProcessingException
*/
public static String buildReqDataset(String jsonStr) {
PageDatasets datasets = parsePageDataset(jsonStr);
public static String buildReqDataset(PageDatasets datasets) {
if (datasets == null || datasets.list == null) return "";
return JsonUtil.encodeString(datasets.list);
}
@@ -185,7 +184,7 @@ public class ModelFormHelper {
* @return
*/
public static String buildReqModel(ModelForm form) {
PageDatasets datasets = parsePageDataset(form.getDataset());
PageDatasets datasets = form.getDatasets();
PageModel pageInfo = parsePageInfo(form.getContent());
if (pageInfo == null) return "";
for (Map<String, Object> model : pageInfo.model) {
@@ -208,7 +207,7 @@ public class ModelFormHelper {
for (Map<String, Object> field : fields) {
String fn = (String) field.get("field");
if (StringUtils.isEmpty(fn)) continue;
PageDatasetField pdf = isField ? dataSet.getField(fn) : dataSet.getFilter(fn);
PageDatasetField pdf = isField ? dataSet.findFieldByName(fn) : dataSet.findFilterByName(fn);
if (pdf == null) continue;
if (!field.containsKey("label")) {
field.put("label", pdf.label);
@@ -245,7 +244,7 @@ public class ModelFormHelper {
}

public static String buildEngineModel(ModelForm form, SwMap params, UserSession us, boolean incExtra) {
PageDatasets datasets = parsePageDataset(form.getDataset());
PageDatasets datasets = form.getDatasets();
if (datasets == null || datasets.list == null) return "";

SwMap ret = new SwMap();
@@ -317,7 +316,7 @@ public class ModelFormHelper {
if (widgetForm == null) throw new SwException("没有找到指定的控件定义!id=" + id);
SwMap w = new SwMap();
widget.put("w" + id, w);
SwMap widgetOpts = parseFormOption(widgetForm.getOption());
SwMap widgetOpts = widgetForm.getOpts();
w.put("service", widgetForm.getService());
if (widgetOpts != null) w.putAll(widgetOpts);
w.put("define", buildEngineModel(widgetForm, params, us, false));
@@ -335,7 +334,7 @@ public class ModelFormHelper {
//获取控件的filter信息
public static List<SwMap> buildWidgetFilter(ModelForm bean) {
List<SwMap> listRet = new ArrayList<>();
PageDatasets datasets = ModelFormHelper.parsePageDataset(bean.getDataset());
PageDatasets datasets = bean.getDatasets();
if (datasets == null || datasets.list == null) return listRet;
for (PageDataset ds : datasets.list) {
for (PageDatasetFilter filter : ds.filters) {
@@ -372,13 +371,13 @@ public class ModelFormHelper {
* @param tmplId
*/
public static void buildSaveModelByTmpl(ModelForm form, String tmplId) {
PageDatasets datasets = parsePageDataset(form.getDataset());
PageDatasets datasets = form.getDatasets();
SwMap tmplModel = JsonUtil.parse(form.getTmpl(), SwMap.class);
tmplModel.put("title", form.getTitle());
tmplModel.put("datasets", parsePageDataset(form.getDataset()));
tmplModel.put("datasets", form.getDatasets());
SwMap layout = tmplModel.readMap("layout");
//用到的自定义控件
Set<String> setWidget = new HashSet<>();
Set<Long> setWidget = new HashSet<>();
for (String key : layout.keySet()) {
List<Map<String, Object>> groups = layout.readListMap(key);
for (Map<String, Object> group : groups) {
@@ -397,17 +396,18 @@ public class ModelFormHelper {
}
String widgetRef = "";
if (!setWidget.isEmpty()) {
for (String s: setWidget) {
for (long s: setWidget) {
widgetRef += ",\"" + s + "\"";
}
widgetRef = widgetRef.substring(1);
}
tmplModel.put("widgetRef", widgetRef);
form.setContent(CodeGenerator.getInstance().generate(tmplModel, tmplId));
final String model = CodeGenerator.getInstance().generate(tmplModel, tmplId);
form.setContent(model);
// form.setContent(buildSaveModel(form));
}

private static void buildTmplFields(List<Map<String, Object>> fields, PageDatasets datasets, Set<String> setWidget, boolean isField) {
private static void buildTmplFields(List<Map<String, Object>> fields, PageDatasets datasets, Set<Long> setWidget, boolean isField) {
if (fields == null) return;
PageDataset dataset = null;
for (Map<String, Object> field : fields) {
@@ -419,18 +419,33 @@ public class ModelFormHelper {
String fn = MapUtil.readString(field, "field");
PageDatasetField pdf;
if (!isField) {
pdf = dataset.getFilter(fn);
pdf = dataset.findFilterById(fn);
} else {
pdf = dataset.getField(fn);
if (pdf == null) pdf = dataset.getFilter(fn);
pdf = dataset.findFieldById(fn);
if (pdf == null) pdf = dataset.findFilterByName(fn);
}
if (pdf == null) throw new SwException("model[" + dsId + "]未找到定义的数据集字段(" + fn + "),无法解析!");
field.put("id", pdf.id);
field.put("field", pdf.field);
field.put("name", pdf.name);
field.put("label", pdf.label);
field.put("required", pdf.isFieldNotNull());
field.put("widget", 0);
final SwEnum.DataTypeBean dtb = SwEnum.DataType.instance.getByValue(pdf.dataType);
if (dtb != null) {
if (dtb.dataLength > 0) field.put("maxlength", dtb.dataLength);
field.put("maxlength", dtb.dataLength);
field.put("editor", dtb.editor);
if (pdf.link > 0) {
long widget = getFieldCtrl(pdf.link);
if (widget > 0) {
setWidget.add(widget);
field.put("widget", widget);
field.put("widgetText", ModelFormCache.getInstance().getText(widget));
}
}
} else {
field.put("maxlength", 0);
field.put("editor", SwEnum.EditorType.INPUT.value);
}
}
}
@@ -439,10 +454,12 @@ public class ModelFormHelper {
* 计算字段适用控件
*
* @param tableId
* @param fieldName
* @return
*/
public String getFieldCtrl(long tableId, String fieldName) {
return null;
public static long getFieldCtrl(long tableId) {
Set<ModelForm> set = ModelFormCache.getInstance().getListByTable(tableId, SwEnum.FormType.WIDGET.value);
if (set == null || set.isEmpty()) return 0L;
ModelForm form = set.iterator().next();
return (form != null) ? form.getEntityId() : 0L;
}
}

+ 2
- 2
smtweb-system/sw-system-bpm/src/main/java/cc/smtweb/system/bpm/web/design/form/ModelFormLoadHandler.java Bestand weergeven

@@ -17,7 +17,7 @@ public class ModelFormLoadHandler extends DefaultLoadHandler<ModelForm> {
@Override
protected ModelForm loadComp(long id) {
ModelForm bean = super.loadComp(id);
SwMap opts = ModelFormHelper.parseFormOption(bean.getOption());
SwMap opts = bean.getOpts();
if (opts != null) {
ModelFormHelper.buildOptsEx(bean, opts);
bean.setOption(JsonUtil.encodeString(opts));
@@ -33,7 +33,7 @@ public class ModelFormLoadHandler extends DefaultLoadHandler<ModelForm> {
long id = params.readLong("id");
ModelForm bean = super.loadComp(id);
if (bean == null) throw new SwException("没有找到指定定义信息!id=" + id);
return R.success(ModelFormHelper.buildReqDataset(bean.getDataset()));
return R.success(ModelFormHelper.buildReqDataset(bean.getDatasets()));
}

//页面设计 - 加载页面model定义


+ 3
- 4
smtweb-system/sw-system-bpm/src/main/java/cc/smtweb/system/bpm/web/design/form/ModelFormSaveHandler.java Bestand weergeven

@@ -25,7 +25,7 @@ public class ModelFormSaveHandler extends DefaultSaveHandler<ModelForm> {

@Override
protected void updateBean(EntityDao<ModelForm> dao) {
SwMap opts = ModelFormHelper.parseFormOption(bean.getOption());
SwMap opts = bean.getOpts();
if (opts != null) {
opts.remove(ModelFormHelper.KEY_EVENT_PATH);
bean.setOption(JsonUtil.encodeString(opts));
@@ -73,8 +73,7 @@ public class ModelFormSaveHandler extends DefaultSaveHandler<ModelForm> {
if (StringUtils.isEmpty(data)) {
throw new SwException("没有待保存的数据!");
}
bean.setContent(data);
bean.setContent(ModelFormHelper.buildSaveModel(bean));
bean.setContent(ModelFormHelper.buildSaveModel(bean, data));
DbEngine.getInstance().doTrans(new AbsDbWorker() {
@Override
public void work() {
@@ -117,7 +116,7 @@ public class ModelFormSaveHandler extends DefaultSaveHandler<ModelForm> {
ModelTable table = ModelTableCache.getInstance().getByName(tableName);
ModelField field = table.findFieldByType(SwEnum.FieldType.UPDATE_USER.value);
if (field != null) bean.put(field.getName(), us.getUserId());
dao.updateEntity(bean, "mf_content", "mf_tmpl");
dao.updateEntity(bean, "mf_content,mf_tmpl");
}

@Override


+ 31
- 14
smtweb-system/sw-system-bpm/src/main/java/cc/smtweb/system/bpm/web/design/form/define/PageDataset.java Bestand weergeven

@@ -44,27 +44,43 @@ public class PageDataset {
public PageDatasetDynCond dynCond;
public List<PageDatasetSortField> sortFields;

private Map<String, PageDatasetField> mapField;
private Map<String, PageDatasetFilter> mapFilter;
//按字段名的缓存
private Map<String, PageDatasetField> mapFieldName;
private Map<String, PageDatasetFilter> mapFilterName;
//按字段Id的缓存
private Map<String, PageDatasetField> mapFieldId;
private Map<String, PageDatasetFilter> mapFilterId;

public PageDatasetField getField(String name) {
if (mapField == null) resetFields();
return mapField.get(name);
public PageDatasetField findFieldByName(String name) {
if (mapFieldName == null) resetFields();
return mapFieldName.get(name);
}

public PageDatasetFilter getFilter(String name) {
if (mapFilter == null) resetFields();
return mapFilter.get(name);
public PageDatasetFilter findFilterByName(String name) {
if (mapFilterName == null) resetFields();
return mapFilterName.get(name);
}

public PageDatasetField findFieldById(String id) {
if (mapFieldId == null) resetFields();
return mapFieldId.get(id);
}

public PageDatasetFilter findFilterById(String id) {
if (mapFilterId == null) resetFields();
return mapFilterId.get(id);
}

/**
* 重置丰富字段信息
*/
public void resetFields() {
mapField = new HashMap<>();
resetFields(mapField, fields);
mapFilter = new HashMap<>();
resetFields(mapFilter, filters);
mapFieldName = new HashMap<>();
mapFieldId = new HashMap<>();
resetFields(mapFieldName, mapFieldId, fields);
mapFilterName = new HashMap<>();
mapFilterId = new HashMap<>();
resetFields(mapFilterName, mapFilterId, filters);
for (PageDatasetFilter filter: filters) {
if (StringUtils.isEmpty(filter.sqlName)) {
filter.sqlName = filter.field;
@@ -72,11 +88,12 @@ public class PageDataset {
}
}

private <T extends PageDatasetField> void resetFields(Map<String, T> map, List<T> list) {
private <T extends PageDatasetField> void resetFields(Map<String, T> mapName, Map<String, T> mapId, List<T> list) {
ModelTableCache cache = ModelTableCache.getInstance();
ModelTable table = null;
for (T field: list) {
map.put(field.name, field);
mapName.put(field.name, field);
mapId.put(field.id, field);
if (field.table <= 0 || StringUtils.isEmpty(field.field)) continue;
if (table == null || table.getId() != field.table) {
table = cache.get(field.table);


+ 0
- 1
smtweb-system/sw-system-bpm/src/main/java/cc/smtweb/system/bpm/web/design/form/define/PageDatasetField.java Bestand weergeven

@@ -33,7 +33,6 @@ public class PageDatasetField {
public long link;
//控件类型:TEXT/TextArea/NUMBER/COMBO
public String editor;
public String editModel;

@JsonIgnore
public boolean isFieldNotNull() {


+ 11
- 0
smtweb-system/sw-system-bpm/src/main/java/cc/smtweb/system/bpm/web/design/form/define/PageDatasets.java Bestand weergeven

@@ -34,6 +34,17 @@ public class PageDatasets {
}
}

public PageDataset findMasterDataset() {
if (list == null || list.isEmpty()) return null;
return this.list.get(0);
}

public long findMasterTableId() {
PageDataset ds = findMasterDataset();
if (ds == null) return 0L;
return ds.masterTable;
}

public PageDataset findById(String id) {
return mapId.get(id);
}


+ 5
- 3
smtweb-system/sw-system-bpm/src/main/java/cc/smtweb/system/bpm/web/engine/dynPage/AbstractDynPageHandler.java Bestand weergeven

@@ -4,6 +4,7 @@ import cc.smtweb.framework.core.common.SwException;
import cc.smtweb.framework.core.common.SwMap;
import cc.smtweb.framework.core.mvc.service.AbstractHandler;
import cc.smtweb.framework.core.session.UserSession;
import cc.smtweb.system.bpm.web.design.form.ModelForm;
import cc.smtweb.system.bpm.web.design.form.ModelFormHelper;
import cc.smtweb.system.bpm.web.design.form.define.PageDataset;
import cc.smtweb.system.bpm.web.design.form.define.PageDatasets;
@@ -22,8 +23,9 @@ public abstract class AbstractDynPageHandler extends AbstractHandler {
public void init(SwMap params, UserSession us) {
super.init(params, us);
pageId = params.readLong("pageId");

datasets = ModelFormHelper.parsePageDataset(pageId);
ModelForm form = ModelFormHelper.getFromCache(pageId);
if (form == null) throw new SwException("没有找到页面定义数据!");
datasets = form.getDatasets();
if (datasets == null || datasets.list == null) throw new SwException("没有找到页面定义数据!");

provider.pageId = pageId;
@@ -36,7 +38,7 @@ public abstract class AbstractDynPageHandler extends AbstractHandler {

//获取第一个,主数据集
protected PageDataset findMasterDataset() {
return datasets.list.get(0);
return datasets.findMasterDataset();
}

//从参数读取数据集定义


+ 1
- 1
smtweb-system/sw-system-bpm/src/main/java/cc/smtweb/system/bpm/web/engine/dynPage/DynPageHelper.java Bestand weergeven

@@ -180,7 +180,7 @@ public class DynPageHelper {
boolean isNameSelf = setFixedFilter.contains(dynCond.param);
setFixedFilter.remove(dynCond.param);

PageDatasetFilter filter = dataSet.getFilter(dynCond.param);
PageDatasetFilter filter = dataSet.findFilterByName(dynCond.param);
if (filter == null) throw new SwException("没有找到filter(" + dynCond.param + ")!");

Object value = null;


+ 0
- 22
smtweb-system/sw-system-bpm/src/main/resources/static/template/incModel/inc_dataset.ftl Bestand weergeven

@@ -1,22 +0,0 @@
{
"dataset": "${dataset.id}",
"label": "${dataset.label}",
"fields": [
<#list fields as field>
{
"id": "${field.id}",
"field": "${field.field}"
},
</#list>
],
"filters": [
<#list filters as field>
{
"id": "${field.id}",
"field": "${field.field}"
"required": ${field.required},
"type": "input"
},
</#list>
]
},

+ 4
- 2
smtweb-system/sw-system-bpm/src/main/resources/static/template/incModel/inc_filter.ftl Bestand weergeven

@@ -17,15 +17,17 @@
"props": {
"label": "${filter.label}",
"type": "text",
<#if filter.maxlength gt 0>
"maxlength": ${filter.maxlength},
</#if>
"placeholder": "请输入查询内容",
"labelWidth": 100,
"dataset": "${filter.dataset}",
"field": "${filter.field}",
"field": "${filter.id}",
"name": "${filter.name}"
},
"events": {}
},
}<#if filter_has_next>,</#if>
</#list>
{
"id": "id${newId()}",


+ 4
- 2
smtweb-system/sw-system-bpm/src/main/resources/static/template/incModel/inc_form.ftl Bestand weergeven

@@ -17,15 +17,17 @@
"props": {
"label": "${field.label}",
"type": "text",
<#if field.maxlength gt 0>
"maxlength": ${field.maxlength},
</#if>
"placeholder": "请输入内容",
"labelWidth": 100,
"dataset": "${field.dataset}",
"field": "${field.field}",
"field": "${field.id}",
"name": "${field.name}"
},
"events": {}
},
}<#if field_has_next>,</#if>
</#list>
]
}

+ 1
- 1
smtweb-system/sw-system-bpm/src/main/resources/static/template/incModel/inc_grid_opt.ftl Bestand weergeven

@@ -32,7 +32,7 @@
"field": "${col.field}",
"label": "${col.label}"
}
},
}<#if col_has_next>,</#if>
</#list>
],
"button": [


+ 28
- 0
smtweb-system/sw-system-bpm/src/main/resources/static/template/incModel/inc_model.ftl Bestand weergeven

@@ -0,0 +1,28 @@
{
"dataset": "${dataset.id}",
"label": "${dataset.label}",
"fields": [
<#list fields as field>
{
"id": "${field.id}",
"field": "${field.field}"<#if field.widget gt 0>,
"lookup": {
"widgetId": "${field.widget}",
"widgetId_text": "${field.widgetText}",
"filters": []
}
</#if>
}<#if field_has_next>,</#if>
</#list>
],
"filters": [
<#list filters as field>
{
"id": "${field.field}",
"field": "${field.field}",
"required": ${field.required},
"type": "input"
}<#if field_has_next>,</#if>
</#list>
]
}

+ 2
- 1
smtweb-system/sw-system-bpm/src/main/resources/static/template/model_simple.ftl Bestand weergeven

@@ -27,6 +27,7 @@
<#elseif (group.type == "card")>
<#include "incModel/inc_form.ftl"/>
</#if>
<#if group_has_next>,</#if>
</#list>
]
}
@@ -34,7 +35,7 @@
],
"model": [
<#list datasets as dataset>
<#include "incModel/inc_dataset.ftl"/>
<#include "incModel/inc_model.ftl"/><#if dataset_has_next>,</#if>
</#list>
],
"option": {


+ 2
- 28
smtweb-system/sw-system-bpm/src/test/java/cc/smtweb/system/bpm/test/ModelFormTest.java Bestand weergeven

@@ -67,34 +67,8 @@ public class ModelFormTest {
public void testBuildModelByTmpl() {
ModelForm form = new ModelForm();
form.setTitle("测试呀");
form.setDataset("[{\"id\":\"ds_1813718bf0c\",\"name\":\"master\",\"label\":\"机构列表\",\"type\":\"list\",\"masterTable\":\"718391823709507584\",\"masterTable_text\":\"机构表\",\"idField\":\"pt_id\",\"lazy\":false,\"canEdit\":false,\"fields\":[{\"id\":\"id_1813718bf0e\",\"table\":\"718391823709507584\",\"field\":\"pt_id\",\"name\":\"pt_id\",\"fieldType\":1,\"notNull\":1,\"link\":\"0\"},{\"id\":\"id_1813718bf0f\",\"table\":\"718391823709507584\",\"field\":\"pt_parent_id\",\"name\":\"pt_parent_id\",\"fieldType\":4,\"notNull\":0,\"link\":\"0\"},{\"id\":\"id_1813718bf10\",\"table\":\"718391823709507584\",\"field\":\"pt_level_code\",\"name\":\"pt_level_code\",\"fieldType\":5,\"notNull\":0,\"link\":\"0\"},{\"id\":\"id_1813718bf11\",\"table\":\"718391823709507584\",\"field\":\"pt_area_id\",\"name\":\"pt_area_id\",\"fieldType\":0,\"notNull\":0,\"link\":\"718410950209703936\"},{\"id\":\"id_1813718bf12\",\"table\":\"718391823709507584\",\"field\":\"pt_code\",\"name\":\"pt_code\",\"fieldType\":2,\"notNull\":1,\"link\":\"0\"},{\"id\":\"id_1813718bf13\",\"table\":\"718391823709507584\",\"field\":\"pt_name\",\"name\":\"pt_name\",\"fieldType\":3,\"notNull\":1,\"link\":\"0\"},{\"id\":\"id_1813718bf14\",\"table\":\"718391823709507584\",\"field\":\"pt_type\",\"name\":\"pt_type\",\"fieldType\":0,\"notNull\":0,\"link\":\"0\"},{\"id\":\"id_1813718bf15\",\"table\":\"718391823709507584\",\"field\":\"pt_statu\",\"name\":\"pt_statu\",\"fieldType\":0,\"notNull\":0,\"link\":\"0\"},{\"id\":\"id_1813718bf16\",\"table\":\"718391823709507584\",\"field\":\"pt_linker\",\"name\":\"pt_linker\",\"fieldType\":0,\"notNull\":0,\"link\":\"0\"},{\"id\":\"id_1813718bf17\",\"table\":\"718391823709507584\",\"field\":\"pt_tel\",\"name\":\"pt_tel\",\"fieldType\":0,\"notNull\":0,\"link\":\"0\"},{\"id\":\"id_1813718bf18\",\"table\":\"718391823709507584\",\"field\":\"pt_addr\",\"name\":\"pt_addr\",\"fieldType\":0,\"notNull\":0,\"link\":\"0\"},{\"id\":\"id_1813718bf19\",\"table\":\"718391823709507584\",\"field\":\"pt_lon\",\"name\":\"pt_lon\",\"fieldType\":0,\"notNull\":0,\"link\":\"0\"},{\"id\":\"id_1813718bf1a\",\"table\":\"718391823709507584\",\"field\":\"pt_lat\",\"name\":\"pt_lat\",\"fieldType\":0,\"notNull\":0,\"link\":\"0\"},{\"id\":\"id_1813718bf1b\",\"table\":\"718391823709507584\",\"field\":\"pt_remark\",\"name\":\"pt_remark\",\"fieldType\":0,\"notNull\":0,\"link\":\"0\"}],\"filters\":[{\"id\":\"id_1813718bf21\",\"table\":\"718391823709507584\",\"field\":\"pt_name\",\"name\":\"pt_code\",\"fieldType\":3,\"notNull\":1,\"link\":\"0\",\"type\":\"input\",\"sqlName\":\"pt_name\",\"required\":false}],\"data\":[],\"dynCond\":{\"opt\":\"or\",\"children\":[{\"param\":\"pt_code\",\"opt\":\"like\"},{\"param\":\"pt_code\",\"opt\":\"like\"}]},\"sortFields\":[{\"field\":\"pt_code\",\"type\":\"asc\"}]}]");
form.setTmpl("{\n" +
" \"param\": {\n" +
" \"p1\": \"pp1\"\n" +
" },\n" +
" \"layout\": {\n" +
" \"c1\": [\n" +
" {\n" +
" \"name\": \"group2\",\n" +
" \"label\": \"分组2\",\n" +
" \"type\": \"list\",\n" +
" \"dataset\": \"ds_1813718bf0c\",\n" +
" \"fields\": [\n" +
" {\n" +
" \"field\": \"pt_parent_id\",\n" +
" \"dataset\": \"ds_1813718bf0c\"\n" +
" }\n" +
" ],\n" +
" \"cfilters\": [\n" +
" {\n" +
" \"field\": \"pt_code\",\n" +
" \"dataset\": \"ds_1813718bf0c\"\n" +
" }\n" +
" ]\n" +
" }\n" +
" ]\n" +
" }\n" +
" }");
form.setDataset("[{\"id\":\"ds_18147381016\",\"name\":\"master\",\"label\":\"主数据集\",\"type\":\"form\",\"masterTable\":\"2\",\"masterTable_text\":\"目录\",\"idField\":\"mc_id\",\"lazy\":false,\"canEdit\":true,\"fields\":[{\"id\":\"id_1814738101b\",\"table\":\"2\",\"field\":\"mc_id\",\"name\":\"mc_id\",\"fieldType\":1,\"notNull\":1,\"link\":\"0\"},{\"id\":\"id_1814738101c\",\"table\":\"2\",\"field\":\"mc_parent_id\",\"name\":\"mc_parent_id\",\"fieldType\":4,\"notNull\":0,\"link\":\"2\"},{\"id\":\"id_1814738101d\",\"table\":\"2\",\"field\":\"mc_level_code\",\"name\":\"mc_level_code\",\"fieldType\":5,\"notNull\":0,\"link\":\"0\"},{\"id\":\"id_1814738101e\",\"table\":\"2\",\"field\":\"mc_prj_id\",\"name\":\"mc_prj_id\",\"fieldType\":0,\"notNull\":1,\"link\":\"1\"},{\"id\":\"id_1814738101f\",\"table\":\"2\",\"field\":\"mc_code\",\"name\":\"mc_code\",\"fieldType\":2,\"notNull\":0,\"link\":\"0\"},{\"id\":\"id_18147381020\",\"table\":\"2\",\"field\":\"mc_name\",\"name\":\"mc_name\",\"fieldType\":3,\"notNull\":0,\"link\":\"0\"}],\"filters\":[],\"data\":[],\"dynCond\":{\"opt\":\"and\"},\"sortFields\":[]}]");
form.setTmpl("{\"param\":{},\"layout\":{\"c1\":[{\"id\":\"id18147381019\",\"name\":\"group1\",\"label\":\"分组1\",\"type\":\"card\",\"fields\":[{\"field\":\"id_1814738101c\",\"field_text\":\"mc_parent_id\",\"field_label\":\"父ID\",\"dataset\":\"ds_18147381016\",\"dataset_text\":\"master\"},{\"field\":\"id_1814738101d\",\"field_text\":\"mc_level_code\",\"field_label\":\"级次码\",\"dataset\":\"ds_18147381016\",\"dataset_text\":\"master\"},{\"field\":\"id_1814738101e\",\"field_text\":\"mc_prj_id\",\"field_label\":\"所属项目\",\"dataset\":\"ds_18147381016\",\"dataset_text\":\"master\"},{\"field\":\"id_1814738101f\",\"field_text\":\"mc_code\",\"field_label\":\"编码\",\"dataset\":\"ds_18147381016\",\"dataset_text\":\"master\"},{\"field\":\"id_18147381020\",\"field_text\":\"mc_name\",\"field_label\":\"编码\",\"dataset\":\"ds_18147381016\",\"dataset_text\":\"master\"}],\"sfilters\":[],\"cfilters\":[]}]}}");
ModelFormHelper.buildSaveModelByTmpl(form, "model_simple");
System.out.println(form.getContent());
}


Laden…
Annuleren
Opslaan