diff --git a/smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/design/form/model/EmptyWorker.java b/smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/design/form/model/EmptyWorker.java new file mode 100644 index 0000000..b3852e8 --- /dev/null +++ b/smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/design/form/model/EmptyWorker.java @@ -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 listFormChild) { + EntityDao 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; + } +} diff --git a/smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/design/form/model/ModelFactory.java b/smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/design/form/model/ModelFactory.java index cea7e3e..8ccfc5f 100644 --- a/smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/design/form/model/ModelFactory.java +++ b/smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/design/form/model/ModelFactory.java @@ -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() { diff --git a/smtweb-framework/bpm/src/main/resources/static/template/default/model_empty.ftl b/smtweb-framework/bpm/src/main/resources/static/template/default/model_empty.ftl new file mode 100644 index 0000000..6f4f352 --- /dev/null +++ b/smtweb-framework/bpm/src/main/resources/static/template/default/model_empty.ftl @@ -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": [] + } +} diff --git a/smtweb-framework/core/src/main/java/cc/smtweb/framework/core/common/SwEnum.java b/smtweb-framework/core/src/main/java/cc/smtweb/framework/core/common/SwEnum.java index 81491c1..79ab92a 100644 --- a/smtweb-framework/core/src/main/java/cc/smtweb/framework/core/common/SwEnum.java +++ b/smtweb-framework/core/src/main/java/cc/smtweb/framework/core/common/SwEnum.java @@ -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", "普通工作流列表(含编辑卡片)"); }