From d95c6ca6ce141ee637df14d8eb9162488f622f2f Mon Sep 17 00:00:00 2001 From: yaoq Date: Thu, 4 Aug 2022 15:08:41 +0800 Subject: [PATCH] =?UTF-8?q?=E6=A8=A1=E6=9D=BF=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../system/bpm/web/sys/user/menu/MenuHandler.java | 80 ++++++++++++++++++++-- .../static/template/incModel/inc_list_dialog.ftl | 4 +- .../resources/static/template/model_tree_list.ftl | 70 +++++-------------- 3 files changed, 95 insertions(+), 59 deletions(-) diff --git a/smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/sys/user/menu/MenuHandler.java b/smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/sys/user/menu/MenuHandler.java index 1fafbb9..cedc1fb 100644 --- a/smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/sys/user/menu/MenuHandler.java +++ b/smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/sys/user/menu/MenuHandler.java @@ -4,20 +4,19 @@ import cc.smtweb.framework.core.common.SwEnum; import cc.smtweb.framework.core.common.SwMap; import cc.smtweb.framework.core.db.impl.DefaultEntity; import cc.smtweb.framework.core.db.vo.ModelCatalog; +import cc.smtweb.framework.core.db.vo.ModelProject; import cc.smtweb.framework.core.util.CommUtil; import cc.smtweb.framework.core.util.JsonUtil; import cc.smtweb.framework.core.util.PubUtil; import cc.smtweb.system.bpm.web.design.db.ModelCatalogTreeHelper; +import cc.smtweb.system.bpm.web.design.db.ModelProjectCache; import cc.smtweb.system.bpm.web.design.form.define.PageDataset; import cc.smtweb.system.bpm.web.engine.dynPage.DynPageListHandler; import cc.smtweb.system.bpm.web.engine.dynPage.DynPageLoadHandler; import cc.smtweb.system.bpm.web.engine.dynPage.DynPageSaveHandler; import cc.smtweb.system.bpm.web.engine.dynPage.DynPageTreeHandler; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; -import java.util.Set; +import java.util.*; /** * @Author: tanghp @@ -29,6 +28,9 @@ public class MenuHandler { @Override public DynPageTreeHandler getTreeWorker(SwMap filter, PageDataset pageDataSet) { DynPageTreeHandler treeHandler = new MenuTreeHandler(pageId, filter, pageDataSet); + if (pageDataSet.name.equals("mcTree")) { + treeHandler = new MenuCatalogTreeHandler(pageId, filter, pageDataSet); + } treeHandler.init(params, us); return treeHandler; } @@ -81,6 +83,76 @@ public class MenuHandler { } } + static class MenuCatalogTreeHandler extends DynPageTreeHandler { + private ModelCatalogTreeHelper mcTreeHelper = new ModelCatalogTreeHelper(); + + public MenuCatalogTreeHandler(long pageId, SwMap filter, PageDataset pageDataSet) { + super(pageId, filter, pageDataSet); + } + + @Override + protected List getChildren(long id) { + List list = new ArrayList<>(); + buildTreeData(list, id); + return list; + } + + private void buildTreeData(List list, long id) { + if (id <= 0) { + Collection mpList = ModelProjectCache.getInstance().getAll(); + for (ModelProject mp : mpList) { + SwMap row = new SwMap(); + row.put("mc_id", mp.getId()); + row.put("mc_name", mp.getName()); + list.add(row); + /*List children = new ArrayList<>(); + buildTreeData(children, mp.getId()); + if (PubUtil.isEmpty(children)) continue; + row.put("children", children);*/ + } + return; + } + ModelProject mp = ModelProjectCache.getInstance().get(id); + if (mp != null) { + List mcList = mcTreeHelper.getChildren(0, mp.getId(), true, (o1, o2) -> CommUtil.chineseCompare(o1.getName(), o2.getName())); + if (PubUtil.isEmpty(mcList)) return; + for (ModelCatalog mc : mcList) { + SwMap row = new SwMap(); + row.put("mc_id", mc.getId()); + row.put("mc_name", mc.getName()); + list.add(row); + /*List children = new ArrayList<>(); + buildTreeData(children, mc.getId()); + if (PubUtil.isEmpty(children)) continue; + row.put("children", children);*/ + } + return; + } + List mcList = mcTreeHelper.getChildren(id, (o1, o2) -> CommUtil.chineseCompare(o1.getName(), o2.getName())); + if (PubUtil.isEmpty(mcList)) return; + for (ModelCatalog mc : mcList) { + SwMap row = new SwMap(); + row.put("mc_id", mc.getId()); + row.put("mc_name", mc.getName()); + list.add(row); + /*List children = new ArrayList<>(); + buildTreeData(children, mc.getId()); + if (PubUtil.isEmpty(children)) continue; + row.put("children", children);*/ + } + } + + @Override + protected long getId(SwMap bean) { + return bean.readLong("mc_id"); + } + + @Override + protected String getText(SwMap bean) { + return bean.readString("mc_name"); + } + } + static class MenuTreeHandler extends DynPageTreeHandler { private ModelCatalogTreeHelper mcTreeHelper = new ModelCatalogTreeHelper(); diff --git a/smtweb-framework/bpm/src/main/resources/static/template/incModel/inc_list_dialog.ftl b/smtweb-framework/bpm/src/main/resources/static/template/incModel/inc_list_dialog.ftl index ab5de15..5c06db7 100644 --- a/smtweb-framework/bpm/src/main/resources/static/template/incModel/inc_list_dialog.ftl +++ b/smtweb-framework/bpm/src/main/resources/static/template/incModel/inc_list_dialog.ftl @@ -5,7 +5,7 @@ "shape": "panel", "props": { "size": "0", - "paddingTop": 32, + "paddingTop": 15, "colNum": 2 }, "children": [ @@ -30,7 +30,7 @@ <#if (col1 gte 2)> "tips": "${dfield.desc}", - "labelWidth": 150, + "labelWidth": 100, <#if (dfield.readonly = true)> "readonly": true, <#else> diff --git a/smtweb-framework/bpm/src/main/resources/static/template/model_tree_list.ftl b/smtweb-framework/bpm/src/main/resources/static/template/model_tree_list.ftl index 52c0b9c..6364a41 100644 --- a/smtweb-framework/bpm/src/main/resources/static/template/model_tree_list.ftl +++ b/smtweb-framework/bpm/src/main/resources/static/template/model_tree_list.ftl @@ -42,48 +42,6 @@ "type": "fx-form-panel", "shape": "panel", "props": { - "size": "56", - "alignY": "center", - "backgroundImage": "bgImg-region-title", - "paddingLeft": 32, - "colNum": 2, - "gridTemplateColumns": "", - "paddingRight": 32 - }, - "children": [ - { - "id": "id${newId()}", - "type": "fx-title", - "props": { - "label": "树列表" - } - } - ] - }, - { - "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-form-panel", - "shape": "panel", - "props": { "size": "", "colNum": 0, "align": "full", @@ -116,7 +74,7 @@ "type": "fx-form-panel", "shape": "panel", "props": { - "size": "10", + "size": "15", "backgroundColor": "--color-transparent" }, "children": [] @@ -138,7 +96,10 @@ "colNum": 3, "label": "查询条件", "size": "50", - "alignY": "center" + "alignY": "center", + "paddingRight": 20, + "gridTemplateColumns": "400px 400px 1fr", + "paddingLeft": 20 }, "children": [ <#list group.cfilters as cfilters> @@ -149,6 +110,7 @@ "label": "${cfilters.label}", "type": "text", "maxlength": 50, + "hideLabel": true, "placeholder": "请输入${cfilters.label}", "labelWidth": 100, "affixError": false @@ -198,7 +160,7 @@ "shape": "panel", "props": { "label": "间隔", - "size": "10", + "size": "15", "backgroundColor": "--color-transparent" }, "children": [] @@ -211,11 +173,10 @@ "props": { "label": "表格标题区", "size": "50", - "backgroundImage": "bgImg-region-title", "colNum": 2, "alignY": "center", - "paddingLeft": 32, - "paddingRight": 32 + "paddingLeft": 20, + "paddingRight": 20 }, "children": [ { @@ -262,7 +223,9 @@ "shape": "panel", "props": { "label": "表格区", - "colNum": 0 + "colNum": 0, + "paddingLeft": 20, + "paddingRight": 20 }, "children": [ { @@ -339,7 +302,7 @@ "type": "fx-split-panel", "props": { "shadow": "", - "size": 24 + "size": 15 }, "children": [] } @@ -358,7 +321,8 @@ "title": "${param.editTitle}", "key": "editMainDialog", - "closeOnClickModal": false + "closeOnClickModal": false, + "showPrefix": true }, "events": {} }, @@ -411,7 +375,7 @@ "shape": "panel", "props": { "size": "50", - "paddingRight": 10, + "paddingRight": 20, "alignY": "center" }, "children": [ @@ -466,4 +430,4 @@ "widgetRef": [${widgetRef}], "vars": [] } -} \ No newline at end of file +}