diff --git a/smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/design/form/ModelFormHelper.java b/smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/design/form/ModelFormHelper.java index c72a48a..f55b40e 100644 --- a/smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/design/form/ModelFormHelper.java +++ b/smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/design/form/ModelFormHelper.java @@ -490,7 +490,8 @@ public class ModelFormHelper { field.put("id", pdf.id); field.put("field", pdf.field); field.put("name", pdf.name); - field.put("label", pdf.label); + String label = (String) field.get("field_text"); + field.put("label", StringUtils.isEmpty(label)? pdf.label: label); field.put("required", pdf.isFieldNotNull()); final SwEnum.DataTypeBean dtb = SwEnum.DataType.instance.getByValue(pdf.dataType); if (dtb != null) { 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 34af617..e4a4423 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 @@ -2,10 +2,10 @@ package cc.smtweb.system.bpm.web.design.form.model; import cc.smtweb.framework.core.common.SwConsts; import cc.smtweb.framework.core.common.SwEnum; -import cc.smtweb.framework.core.exception.BizException; import cc.smtweb.framework.core.exception.SwException; 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.model.flow.LcFlowWorker; import org.apache.commons.lang3.StringUtils; import java.util.*; @@ -22,6 +22,7 @@ public class ModelFactory { mapWorker = new HashMap<>(); mapWorker.put(SwConsts.DEF_ROOT_ID, new BaseModelWorker()); mapWorker.put(SwEnum.ModelType.LC_SINGLE.value, new LcSinlgeWorker()); + mapWorker.put(SwEnum.ModelType.LC_FLOW.value, new LcFlowWorker()); } public static ModelFactory getInstance() { diff --git a/smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/design/form/model/flow/LcFlowWorker.java b/smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/design/form/model/flow/LcFlowWorker.java new file mode 100644 index 0000000..911a2de --- /dev/null +++ b/smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/design/form/model/flow/LcFlowWorker.java @@ -0,0 +1,75 @@ +package cc.smtweb.system.bpm.web.design.form.model.flow; + +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.exception.SwException; +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.ModelFormCache; +import cc.smtweb.system.bpm.web.design.form.ModelFormHelper; +import cc.smtweb.system.bpm.web.design.form.model.BaseModelWorker; +import org.apache.commons.lang3.StringUtils; + +import java.util.ArrayList; +import java.util.List; + +/** + * @Author: tanghp + * @Date: 2022-08-26 9:48 + * @Desc: 列表卡片(含工作流) + */ +public class LcFlowWorker extends BaseModelWorker { + private final static String listTmpl = "model_list_flow"; + private final static String cardTmpl = "model_card_flow"; + @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); + SwMap cfgPage = new SwMap(); + cfg.put(ModelFormHelper.OPT_PAGE, cfgPage); + // 添加列表页面名称 + String listFormName = ModelFormHelper.getPageName(bean) + StringUtil.upFirst(SwEnum.PageType.LIST.value); + cfgPage.put(SwEnum.PageType.LIST.value, listFormName); + // 添加卡片页面名称 + String cardFormName = ModelFormHelper.getPageName(bean) + StringUtil.upFirst(SwEnum.PageType.CARD.value); + cfgPage.put(SwEnum.PageType.CARD.value, cardFormName); + bean.setOption(JsonUtil.encodeString(opts)); + + if (bean.isNew()) {//新增 + List insertList = new ArrayList<>(); + + ModelForm listPage = createPage(bean, SwEnum.PageType.LIST.value); + listFormChild.add(listPage); + insertList.add(listPage); + + ModelForm cardPage = createPage(bean, SwEnum.PageType.CARD.value); + listFormChild.add(cardPage); + insertList.add(cardPage); + + dao.batchInsertEntity(insertList); + } else {//修改,先不考虑修改模型的情况 todo + + } + } + + @Override + public void buildSaveModel(ModelForm bean) { + ModelForm parent = ModelFormCache.getInstance().get(bean.getParent()); + if(parent==null){ + return; + } + String listFormName = parent.getName()+ StringUtil.upFirst(SwEnum.PageType.LIST.value); + String cardFormName = parent.getName()+ StringUtil.upFirst(SwEnum.PageType.CARD.value); + if(listFormName.equals(bean.getName())){ + ModelFormHelper.buildSaveModelByTmpl(bean, listTmpl); + }else if(cardFormName.equals(bean.getName())){ + ModelFormHelper.buildSaveModelByTmpl(bean, cardTmpl); + } + } + +} diff --git a/smtweb-framework/bpm/src/main/resources/static/template/default/incModel/inc_list_table.ftl b/smtweb-framework/bpm/src/main/resources/static/template/default/incModel/inc_list_table.ftl index 90fe426..05f73ff 100644 --- a/smtweb-framework/bpm/src/main/resources/static/template/default/incModel/inc_list_table.ftl +++ b/smtweb-framework/bpm/src/main/resources/static/template/default/incModel/inc_list_table.ftl @@ -41,24 +41,6 @@ ], "button": [ - <#if (tmpl_Type == "model_list")> - { - "id": "id${newId()}", - "type": "fx-button", - "props": { - "label": "编辑", - "type": "primary", - "leftIcon": "edit", - "action": "button:edit", - "dataset": "${group.dataset}", - "text": true, - "link": false, - "linkType": "", - "nextAction": "", - "fxLink": "" - } - }, - <#elseif (tmpl_Type == "model_list_card")> { "id": "id${newId()}", "type": "fx-button", @@ -68,14 +50,9 @@ "leftIcon": "edit", "action": "button:editCard", "link": false, - "text": true, - "linkType": "dialog", - "fxLink": "dialog:cardDialog", - "fxLink_text": "${param.cardTitle}" + "text": true } - }, - - { + },{ "id": "id${newId()}", "type": "fx-button", "props": { diff --git a/smtweb-framework/bpm/src/main/resources/static/template/default/model_card_flow.ftl b/smtweb-framework/bpm/src/main/resources/static/template/default/model_card_flow.ftl new file mode 100644 index 0000000..98f4268 --- /dev/null +++ b/smtweb-framework/bpm/src/main/resources/static/template/default/model_card_flow.ftl @@ -0,0 +1,358 @@ +{ + "version": 6, + "form": [ + { + "page": { + "id": "id${newId()}", + "type": "fx-page", + "props": { + "title": "编辑", + "key": "${newId()}", + "tipsExpand": false + } + }, + "graph": { + "shape": "panel", + "id": "root_panel", + "type": "fx-split-panel", + "props": { + "horizontal": false, + "shadow": "", + "scroll": false, + "size": "", + "name": "s0" + }, + "children": [ + { + "id": "${newId()}", + "type": "fx-split-panel", + "shape": "panel", + "props": { + "size": "50", + "horizontal": true, + "scroll": false, + "name": "s11" + }, + "children": [ + { + "id": "${newId()}", + "type": "fx-form-panel", + "shape": "panel", + "props": { + "alignY": "center", + "size": "200", + "paddingLeft": 20 + }, + "children": [ + { + "id": "${newId()}", + "type": "fx-title", + "props": { + "label": "${title}", + "showPrefix": true + } + } + ] + }, + { + "id": "${newId()}", + "type": "fx-form-panel", + "shape": "panel", + "props": { + "alignY": "center", + "paddingRight": 20 + }, + "children": [ + { + "id": "${newId()}", + "type": "fx-button-group", + "props": { + "menus": [], + "textAlign": "right" + }, + "slots": { + "default": [ + { + "type": "fx-button", + "props": { + "label": "删除", + "leftIcon": "delete", + "type": "", + "action": "button:remove" + }, + "id": "${newId()}" + }, + { + "id": "${newId()}", + "type": "fx-button", + "props": { + "label": "新增", + "type": "primary", + "linkType": "curr", + "leftIcon": "plus" + } + }, + { + "id": "id182e345bb7b", + "type": "fx-button", + "props": { + "label": "返回", + "type": "success", + "size": "default", + "preAction": "", + "action": "button:return", + "leftIcon": "list-top" + }, + "events": {} + } + ] + } + } + ] + } + ] + }, + { + "id": "${newId()}", + "type": "fx-form-panel", + "shape": "panel", + "props": { + "size": "0" + }, + "children": [ + { + "id": "${newId()}", + "type": "fx-divider", + "props": { + "label": "", + "contentPosition": "center", + "direction": "horizontal" + } + } + ] + }, + { + "id": "${newId()}", + "type": "fx-split-panel", + "shape": "panel", + "props": { + "size": "", + "horizontal": false, + "scroll": true, + "name": "s12" + }, + "children": [ + { + <#list layout.card as group> + "id": "${newId()}", + "type": "fx-form-panel", + "shape": "panel", + "props": { + "size": "0", + <#if param.col lte 1> + "gridTemplateColumns": "1fr 2fr", + <#elseif param.col gte 2> + "gridTemplateColumns": "1fr 1fr 1fr", + + "paddingTop": 32 + }, + <#assign fields = group.fields> + "children": [ + <#list fields as field> + { + "id": "id${newId()}", + <#if (field.readonly = true)> + "type": "fx-text", + <#else> + "type": "${field.editor}", + + "props": { + "label": "${field.label}", + "type": "text", + "dataset": "${field.dataset}", + "required": "${field.required}", + "field": "${field.id}", + <#if field.maxlength gt 0> + "maxlength": ${field.maxlength}, + + "placeholder": "请输入内容", + <#if (param.col = 2)> + "tips": "${field.desc}", + + "labelWidth": 100, + <#if (field.readonly = true)> + "readonly": true, + <#else> + "readonly": false, + + "affixError": true + }, + "events": {} + } + <#if field_has_next> + <#if (param.col lte 1 )> + <#if (field.desc != "")> + ,{ + "id": "id181d83cdb41", + "type": "fx-label", + "props": { + "label": "${field.desc}", + "labelWidth": 0, + "affixError": true, + "labelAlign": "left" + } + } + <#else> + ,{ + "id": "id${newId()}", + "type": "fx-placeholder", + "props": { + "label": "占位" + }, + "layout": { + "row": 1 + } + } + + + <#if (param.col = 2 && ((field_index+1) % 2 = 0 ) )> + ,{ + "id": "id${newId()}", + "type": "fx-placeholder", + "props": { + "label": "占位" + }, + "layout": { + "row": 1 + } + } + + , + + + ] + + }, + { + "id": "${newId()}", + "type": "fx-form-panel", + "shape": "panel", + "props": { + "name": "d2" + }, + "children": [] + } + ] + }, + { + "id": "182e345bb14", + "type": "fx-form-panel", + "shape": "panel", + "props": { + "size": "10", + "backgroundColor": "--color-transparent" + }, + "children": [] + }, + { + "id": "${newId()}", + "type": "fx-form-panel", + "shape": "panel", + "props": { + "size": "50", + "alignY": "center", + "alignX": "center" + }, + "children": [ + { + "id": "${newId()}", + "type": "fx-button-group", + "props": { + "menus": [] + }, + "slots": { + "default": [ + { + "type": "fx-button", + "props": { + "label": "保存并新增", + "type": "primary", + "action": "button:saveAndAdd", + "linkType": "curr" + }, + "id": "${newId()}" + }, + { + "type": "fx-button", + "props": { + "label": "保存", + "leftIcon": "save", + "type": "success", + "action": "button:save" + }, + "id": "${newId()}" + },{ + "type": "fx-button", + "props": { + "label": "提交", + "leftIcon": "save", + "type": "success", + "action": "button:submit" + }, + "id": "${newId()}" + },{ + "type": "fx-button", + "props": { + "label": "取回", + "leftIcon": "save", + "type": "success", + "action": "button:retake" + }, + "id": "${newId()}" + },{ + "type": "fx-button", + "props": { + "label": "驳回", + "leftIcon": "save", + "type": "success", + "action": "button:reject" + }, + "id": "${newId()}" + },{ + "type": "fx-button", + "props": { + "label": "作废", + "leftIcon": "save", + "type": "success", + "action": "button:cancel" + }, + "id": "${newId()}" + },{ + "type": "fx-button", + "props": { + "label": "终止", + "leftIcon": "save", + "type": "success", + "action": "button:interrupt" + }, + "id": "${newId()}" + } + ] + } + } + ] + } + ] + } + } + ], + "model": [ + <#list datasets as dataset> + <#include "incModel/inc_model.ftl"/><#if dataset_has_next>, + + ], + "option": { + "widgetRef": [${widgetRef}], + "vars": [] + } +} diff --git a/smtweb-framework/bpm/src/main/resources/static/template/default/model_list_flow.ftl b/smtweb-framework/bpm/src/main/resources/static/template/default/model_list_flow.ftl new file mode 100644 index 0000000..ba8105b --- /dev/null +++ b/smtweb-framework/bpm/src/main/resources/static/template/default/model_list_flow.ftl @@ -0,0 +1,109 @@ +{ +<#list layout.list as group> + "form": + [ + { + "page": { + "id": "p${newId()}", + "type": "fx-page", + "props": { + "title": "${title}", + "key": "${newId()}" + } + }, + "graph": { + "shape": "panel", + "id": "root_panel", + "type": "fx-split-panel", + "props": { + "horizontal": false, + "shadow": "" + }, + "children": [ + <#if (group.cfilters?size>0)> + <#include "incModel/inc_list_query.ftl"/> + + { + "id": "${newId()}", + "type": "fx-form-panel", + "shape": "panel", + "props": { + "size": "50", + "label": "查询条件", + "colNum": 2, + "alignY": "center", + "paddingLeft": 20, + "paddingRight": 20, + "shadow": "" + }, + "children": [ + { + "id": "id${newId()}", + "type": "fx-title", + "props": { + "label": "${title}", + "fontSize": 15, + "color": "#313131", + "fontWeight": "bold", + "showPrefix": true, + "prefixWidth": 5, + "prefixHeight": 15, + "prefixColor": "#1E90FF" + } + }, + { + "id": "id${newId()}", + "type": "fx-button-group", + "props": { + "menus": [], + "textAlign": "right" + }, + "slots": { + "default": [ + { + "id": "id${newId()}", + "type": "fx-button", + "props": { + "label": "新增", + "leftIcon": "plus", + "type": "primary", + "action": "button:addCard", + "link": false, + "linkType": "", + "fxLink": "" + } + } + ] + } + } + ] + }, + <#include "incModel/inc_list_table.ftl"/> + { + "id": "${newId()}", + "type": "fx-form-panel", + "shape": "panel", + "props": { + "size": "15", + "backgroundColor": "transparent" + }, + "children": [] + } + ] + } + } + <#if (group.sfilters?size>0)> + <#include "incModel/inc_query_sfilters.ftl"/> + + ], + +"model": [ +<#list datasets as dataset> + <#include "incModel/inc_model.ftl"/><#if dataset_has_next>, + +], +"option": { +"widgetRef": [${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 6b0dd24..41a9d9f 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 @@ -339,6 +339,7 @@ public interface SwEnum { class ModelType extends StrEnum { public static ModelType instance = new ModelType(); public static StrEnumBean LC_SINGLE = instance.addEnum("LC_SINGLE", "简单列表(含卡片)"); + public static StrEnumBean LC_FLOW = instance.addEnum("LC_FLOW", "列表卡片(含工作流)"); } // 权限类型