diff --git a/smtweb-framework/sw-framework-core/src/main/java/cc/smtweb/framework/core/common/SwEnum.java b/smtweb-framework/sw-framework-core/src/main/java/cc/smtweb/framework/core/common/SwEnum.java index dec095f..420f454 100644 --- a/smtweb-framework/sw-framework-core/src/main/java/cc/smtweb/framework/core/common/SwEnum.java +++ b/smtweb-framework/sw-framework-core/src/main/java/cc/smtweb/framework/core/common/SwEnum.java @@ -71,6 +71,7 @@ public interface SwEnum { public static StrEnumBean INPUT = instance.addEnum("text", "文本"); public static StrEnumBean TEXT = instance.addEnum("textarea", "长文本"); public static StrEnumBean NUMBER = instance.addEnum("number", "数字"); + public static StrEnumBean SWITCH = instance.addEnum("switch", "布尔型"); public static StrEnumBean DATE = instance.addEnum("date", "日期"); public static StrEnumBean TIME = instance.addEnum("time", "时间"); public static StrEnumBean DATETIME = instance.addEnum("datetime", "日期时间"); @@ -122,7 +123,7 @@ public interface SwEnum { public static DataTypeBean TEXT = instance.addEnum("text", "大文本", "text", 0, "string", Types.CLOB, "", EditorType.TEXT.value); public static DataTypeBean INT = instance.addEnum("int", "整型", "int", 0, "int", Types.INTEGER, "0", EditorType.NUMBER.value); public static DataTypeBean SHORT = instance.addEnum("short", "短整型", "smallint", 0, "short", Types.SMALLINT, "0", EditorType.NUMBER.value); - public static DataTypeBean BOOL = instance.addEnum("bool", "布尔型", "tinyint", 0, "boolean", Types.TINYINT, "0", EditorType.COMBO.value); + public static DataTypeBean BOOL = instance.addEnum("bool", "布尔型", "tinyint", 0, "boolean", Types.TINYINT, "0", EditorType.SWITCH.value); public static DataTypeBean CURRENCY = instance.addEnum("currency", "金额型", "bigint", 0, "long", Types.BIGINT, "0", EditorType.NUMBER.value); public static DataTypeBean DATE = instance.addEnum("date", "日期型", "bigint", 0, "long", Types.BIGINT, "0", EditorType.DATE.value); public static DataTypeBean TIME = instance.addEnum("time", "时间型", "bigint", 0, "long", Types.BIGINT, "0", EditorType.TIME.value); diff --git a/smtweb-system/sw-system-bpm/src/main/java/cc/smtweb/system/bpm/util/CodeGenerator.java b/smtweb-system/sw-system-bpm/src/main/java/cc/smtweb/system/bpm/util/CodeGenerator.java index 0df1a0d..968ef18 100644 --- a/smtweb-system/sw-system-bpm/src/main/java/cc/smtweb/system/bpm/util/CodeGenerator.java +++ b/smtweb-system/sw-system-bpm/src/main/java/cc/smtweb/system/bpm/util/CodeGenerator.java @@ -164,7 +164,7 @@ public class CodeGenerator { map.put("title", "thisIsATest!"); map.put("newId", new PKGenerator()); - CodeGenerator.getInstance().generate(map, "model_simple.ftl", out); + CodeGenerator.getInstance().generate(map, "model_card.ftl", out); System.out.println(out.getBuffer().toString()); } } diff --git a/smtweb-system/sw-system-bpm/src/main/java/cc/smtweb/system/bpm/web/design/form/define/PageDatasetField.java b/smtweb-system/sw-system-bpm/src/main/java/cc/smtweb/system/bpm/web/design/form/define/PageDatasetField.java index 6faa2f3..0101386 100644 --- a/smtweb-system/sw-system-bpm/src/main/java/cc/smtweb/system/bpm/web/design/form/define/PageDatasetField.java +++ b/smtweb-system/sw-system-bpm/src/main/java/cc/smtweb/system/bpm/web/design/form/define/PageDatasetField.java @@ -11,7 +11,7 @@ public class PageDatasetField { public long table; public String table_text; //字段 - public String field; + public String field = ""; //有别名取别名,无别名同字段名 public String name; public String label; diff --git a/smtweb-system/sw-system-bpm/src/main/java/cc/smtweb/system/bpm/web/design/form/define/PageDatasetFilter.java b/smtweb-system/sw-system-bpm/src/main/java/cc/smtweb/system/bpm/web/design/form/define/PageDatasetFilter.java index d2b3ec6..8bc0e63 100644 --- a/smtweb-system/sw-system-bpm/src/main/java/cc/smtweb/system/bpm/web/design/form/define/PageDatasetFilter.java +++ b/smtweb-system/sw-system-bpm/src/main/java/cc/smtweb/system/bpm/web/design/form/define/PageDatasetFilter.java @@ -13,5 +13,5 @@ public class PageDatasetFilter extends PageDatasetField { public String linkField; //type为const时,常量值 public String value; - public boolean required; + public boolean required = false; } diff --git a/smtweb-system/sw-system-bpm/src/main/resources/static/template/incModel/inc_model.ftl b/smtweb-system/sw-system-bpm/src/main/resources/static/template/incModel/inc_model.ftl index 7c63272..bdda13c 100644 --- a/smtweb-system/sw-system-bpm/src/main/resources/static/template/incModel/inc_model.ftl +++ b/smtweb-system/sw-system-bpm/src/main/resources/static/template/incModel/inc_model.ftl @@ -18,9 +18,9 @@ "filters": [ <#list dataset.filters as field> { - "id": "${field.field}", - "field": "${field.field}", - "required": ${field.required}, + "id": "${field.id}", + "field": "${field.field!0}", + "required": ${field.required?string ("true","false")}, "type": "input" }<#if field_has_next>, diff --git a/smtweb-system/sw-system-bpm/src/main/resources/static/template/index.yaml b/smtweb-system/sw-system-bpm/src/main/resources/static/template/index.yaml index f0842e6..55ec5fa 100644 --- a/smtweb-system/sw-system-bpm/src/main/resources/static/template/index.yaml +++ b/smtweb-system/sw-system-bpm/src/main/resources/static/template/index.yaml @@ -1,7 +1,9 @@ model: - - name: 'model_simple' - label: '简单页面' + name: 'model_list' + label: '简单列表' + # list/card/view + type: 'list' # 布局 layout: - @@ -10,7 +12,24 @@ model: type: 'list' hasGroup: false # 变量 - param: +# param: +# - +# name: 'p1' +# type: 'ds' + - + name: 'model_card' + label: '简单卡片' + # list/card/view + type: 'card' + # 布局 + layout: - - name: 'p1' - type: 'ds' + name: 'c1' + label: '客户区' + type: 'card' + hasGroup: false + # 变量 +# param: +# - +# name: 'p1' +# type: 'ds' \ No newline at end of file diff --git a/smtweb-system/sw-system-bpm/src/main/resources/static/template/model_card.ftl b/smtweb-system/sw-system-bpm/src/main/resources/static/template/model_card.ftl new file mode 100644 index 0000000..713b23f --- /dev/null +++ b/smtweb-system/sw-system-bpm/src/main/resources/static/template/model_card.ftl @@ -0,0 +1,116 @@ +{ + "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": "never" + }, + "children": [ +<#list layout.c1 as group> + <#if (group.type == "list")> + <#if (group.cfilters?size>0)> + <#include "incModel/inc_filter.ftl"/> + + <#include "incModel/inc_grid_opt.ftl"/> + <#elseif (group.type == "card")> + <#include "incModel/inc_form.ftl"/> + , + +{ + "id": "${newId()}", + "type": "fx-form-panel", + "shape": "panel", + "props": { + "paddingY": 3, + "paddingX": 10, + "size": 20 + }, + "children": [ + { + "id": "id${newId()}", + "type": "fx-button-group", + "props": { + "menus": [], + "textAlign": "center" + }, + "slots": { + "default": [ + { + "type": "fx-button", + "props": { + "label": "新增", + "leftIcon": "plus", + "type": "primary", + "action": "button:add" + }, + "id": "id${newId()}" + }, + { + "type": "fx-button", + "props": { + "label": "保存并新增", + "type": "primary", + "action": "button:saveAndAdd" + }, + "id": "id${newId()}" + }, + { + "type": "fx-button", + "props": { + "label": "保存", + "leftIcon": "save", + "type": "success", + "action": "button:save" + }, + "id": "id${newId()}" + }, + { + "type": "fx-button", + "props": { + "label": "删除", + "leftIcon": "delete", + "type": "danger", + "action": "button:remove" + }, + "id": "id${newId()}" + }, + { + "type": "fx-button", + "props": { + "label": "返回", + "leftIcon": "return", + "action": "button:return" + }, + "id": "id${newId()}" + } + ] + } + } + ] + } + ] + } + } + ], + "model": [ +<#list datasets as dataset> + <#include "incModel/inc_model.ftl"/><#if dataset_has_next>, + + ], + "option": { + "widgetRef": [${widgetRef}], + "vars": [] + } +} \ No newline at end of file diff --git a/smtweb-system/sw-system-bpm/src/main/resources/static/template/model_list.ftl b/smtweb-system/sw-system-bpm/src/main/resources/static/template/model_list.ftl new file mode 100644 index 0000000..e88fb9e --- /dev/null +++ b/smtweb-system/sw-system-bpm/src/main/resources/static/template/model_list.ftl @@ -0,0 +1,41 @@ +{ + "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": "never" + }, + "children": [ +<#list layout.c1 as group> + <#if (group.cfilters?size>0)> + <#include "incModel/inc_filter.ftl"/> + + <#include "incModel/inc_grid_opt.ftl"/> + <#if group_has_next>, + + ] + } + } + ], + "model": [ +<#list datasets as dataset> + <#include "incModel/inc_model.ftl"/><#if dataset_has_next>, + + ], + "option": { + "widgetRef": [${widgetRef}], + "vars": [] + } +} \ No newline at end of file