Ver código fonte

自定义模型

4.0
lip 2 anos atrás
pai
commit
62395c0acc
4 arquivos alterados com 114 adições e 0 exclusões
  1. +68
    -0
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/design/form/model/EmptyWorker.java
  2. +1
    -0
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/design/form/model/ModelFactory.java
  3. +44
    -0
      smtweb-framework/bpm/src/main/resources/static/template/default/model_empty.ftl
  4. +1
    -0
      smtweb-framework/core/src/main/java/cc/smtweb/framework/core/common/SwEnum.java

+ 68
- 0
smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/design/form/model/EmptyWorker.java Ver arquivo

@@ -0,0 +1,68 @@
package cc.smtweb.system.bpm.web.design.form.model;

import cc.smtweb.framework.core.common.AbstractEnum;
import cc.smtweb.framework.core.common.SwEnum;
import cc.smtweb.framework.core.common.SwMap;
import cc.smtweb.framework.core.db.DbEngine;
import cc.smtweb.framework.core.db.EntityDao;
import cc.smtweb.framework.core.util.JsonUtil;
import cc.smtweb.framework.core.util.StringUtil;
import cc.smtweb.system.bpm.web.design.form.ModelForm;
import cc.smtweb.system.bpm.web.design.form.ModelFormHelper;
import org.springframework.util.Assert;

import java.util.List;

/**
* @Author:lip
* @Date : 2022/9/14 11:27
*/
public class EmptyWorker extends BaseModelWorker{
private final static String template = "model_empty";

@Override
protected void saveModule(ModelForm bean, List<ModelForm> listFormChild) {
EntityDao<ModelForm> dao = DbEngine.getInstance().findDao(ModelForm.class);

SwMap opts = bean.getOpts();
SwMap cfg = opts.readMap(ModelFormHelper.OPT_CONFIG);
//
String pageType = cfg.readMap("props").readString("pageType");
AbstractEnum.StrEnumBean type = SwEnum.PageType.instance.getByValue(pageType);
Assert.notNull(type, "无效页面类型: " + pageType);
String pageName = ModelFormHelper.getPageName(bean) + StringUtil.upFirst(pageType);
//
SwMap cfgPage = new SwMap();
cfg.put(ModelFormHelper.OPT_PAGE, cfgPage);
//
cfgPage.put(pageType, pageName);
bean.setOption(JsonUtil.encodeString(opts));
//
ModelForm page;
if (bean.isNew()) {
//新增
page = createPage(bean, pageType);
listFormChild.add(page);
dao.insertEntity(page);
} else {
//修改,先不考虑修改模型的情况 todo
page = ModelFormHelper.getFromCache(pageName);
Assert.isTrue(page != null, "获取页面失败");
listFormChild.add(page);
boolean modified = false;
//服务名发生变化
if (!StringUtil.isStrEquals(page.getService(), bean.getService())) {
page.setService(bean.getService());
modified = true;
}
if (modified) {
dao.updateEntity(page, "mf_content,mf_dataset,mf_tmpl");
}
}
}

@Override
protected String getTmplId(ModelForm bean) {
return template;
}
}

+ 1
- 0
smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/design/form/model/ModelFactory.java Ver arquivo

@@ -33,6 +33,7 @@ public class ModelFactory {
mapWorker.put(SwEnum.ModelType.LC_LC_1.value, new LcLc1Worker());
mapWorker.put(SwEnum.ModelType.LC_LC_2.value, new LcLc2Worker());
mapWorker.put(SwEnum.ModelType.FLOW_SINGLE.value, new FlowSingleWorker());
mapWorker.put(SwEnum.ModelType.EMPTY.value, new EmptyWorker());
}

public static ModelFactory getInstance() {


+ 44
- 0
smtweb-framework/bpm/src/main/resources/static/template/default/model_empty.ftl Ver arquivo

@@ -0,0 +1,44 @@
{
"version": 6,
"form": [
{
"page": {
"id": "${newId()}",
"type": "fx-page",
"props": {
"title": "${title}",
"key": "${newId()}"
}
},
"graph": {
"shape": "panel",
"id": "root_panel",
"type": "fx-split-panel",
"props": {
"horizontal": false,
"shadow": "never"
},
"children": [
{
"shape": "panel",
"id": "form_panel",
"type": "fx-form-panel",
"props": {
"colNum": 3,
"paddingX": 5,
"paddingY": 5,
"name": "content",
"label": "content"
},
"children": []
}
]
}
}
],
"model": [],
"option": {
"widgetRef": [],
"vars": []
}
}

+ 1
- 0
smtweb-framework/core/src/main/java/cc/smtweb/framework/core/common/SwEnum.java Ver arquivo

@@ -346,6 +346,7 @@ public interface SwEnum {
public static StrEnumBean LC_LT_MS = instance.addEnum("LC_LT_MS", "左树-主子列表(含编辑卡片)");
public static StrEnumBean LC_LC_1 = instance.addEnum("LC_LC_1", "左列表-右列表(含编辑弹窗、左列表可编辑)");
public static StrEnumBean LC_LC_2 = instance.addEnum("LC_LC_2", "左列表-右列表(含编辑弹窗、左列表不可编辑)");
public static StrEnumBean EMPTY = instance.addEnum("EMPTY", "自定义模型");
public static StrEnumBean FLOW_SINGLE = instance.addEnum("FLOW_SINGLE", "普通工作流列表(含编辑卡片)");
}



Carregando…
Cancelar
Salvar