Browse Source

模块树展示

master
郑根木 2 years ago
parent
commit
4c97751eaf
5 changed files with 527 additions and 336 deletions
  1. +18
    -24
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/design/db/ModelCatalogTreeHandler.java
  2. +1
    -0
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/design/form/ModelFormSaveHandler.java
  3. +1
    -1
      smtweb-framework/bpm/src/main/resources/config/application.yaml
  4. +1
    -1
      smtweb-framework/core/src/main/java/cc/smtweb/framework/core/mvc/service/AbstractTreeHandler.java
  5. +506
    -310
      smtweb-framework/core/src/main/resources/demo.json

+ 18
- 24
smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/design/db/ModelCatalogTreeHandler.java View File

@@ -73,35 +73,20 @@ public class ModelCatalogTreeHandler extends AbstractTreeHandler<DefaultEntity>
EntityDao<ModelForm> formdao = DbEngine.getInstance().findDao(ModelForm.class); EntityDao<ModelForm> formdao = DbEngine.getInstance().findDao(ModelForm.class);
List<ModelForm> lf; List<ModelForm> lf;
switch (type) { switch (type) {
case TYPE_FORM:
lf = formdao.queryWhere(" mf_prj_id=? and (mf_name like ? or mf_title like ?) order by tb_name", prj_id, text, text);
addForm(listRet, lf);
break;
case TYPE_PAGE: case TYPE_PAGE:
lf = formdao.queryWhere(" mf_prj_id=? and mf_type<>? and (mf_name like ? or mf_title like ?) order by tb_name", prj_id, SwEnum.FormType.WIDGET.value, text, text); lf = formdao.queryWhere(" mf_prj_id=? and mf_type<>? and (mf_name like ? or mf_title like ?) order by tb_name", prj_id, SwEnum.FormType.WIDGET.value, text, text);
addForm(listRet, lf);
break; break;
case TYPE_WIDGET: case TYPE_WIDGET:
lf = formdao.queryWhere(" mf_prj_id=? and mf_type=? and (mf_name like ? or mf_title like ?) order by tb_name", prj_id, SwEnum.FormType.WIDGET.value, text, text); lf = formdao.queryWhere(" mf_prj_id=? and mf_type=? and (mf_name like ? or mf_title like ?) order by tb_name", prj_id, SwEnum.FormType.WIDGET.value, text, text);
listRet.addAll(lf);
break; break;
default:
lf = formdao.queryWhere(" mf_prj_id=? and (mf_name like ? or mf_title like ?) order by tb_name", prj_id, text, text);
} }
listRet.addAll(lf);
} }
return listRet; return listRet;
} }


//添加页面,将模块子页面单独扔map,特殊处理
private void addForm(List<DefaultEntity> listRet, List<ModelForm> lf){
for (ModelForm mf: lf) {
if (mf.getParent() > 0) {
List<DefaultEntity> ch = mapFormChild.computeIfAbsent(mf.getParent(), k -> new ArrayList<>());
ch.add(mf);
} else {
listRet.add(mf);
}
}
}

@Override @Override
protected List<DefaultEntity> getChildren(long id) { protected List<DefaultEntity> getChildren(long id) {
List<ModelCatalog> list = mcTreeHelper.getChildren(id, prj_id, (o1, o2) -> CommUtil.chineseCompare(o1.getName(), o2.getName())); List<ModelCatalog> list = mcTreeHelper.getChildren(id, prj_id, (o1, o2) -> CommUtil.chineseCompare(o1.getName(), o2.getName()));
@@ -168,6 +153,19 @@ public class ModelCatalogTreeHandler extends AbstractTreeHandler<DefaultEntity>
listRet.addAll(set); listRet.addAll(set);
} }


//添加页面,将子页面单独清出来
private void addForm(List<DefaultEntity> listRet, List<ModelForm> lf, boolean exc_widget) {
for (ModelForm mf : lf) {
if (exc_widget && mf.getType() == SwEnum.FormType.WIDGET.value) continue;
if (mf.getParent() > 0) {
List<DefaultEntity> ch = mapFormChild.computeIfAbsent(mf.getParent(), k -> new ArrayList<>());
ch.add(mf);
} else {
listRet.add(mf);
}
}
}

//增加页面定义 //增加页面定义
private void addPageChildren(List<DefaultEntity> listRet, long mcid, int type) { private void addPageChildren(List<DefaultEntity> listRet, long mcid, int type) {
List<ModelForm> set = ModelFormCache.getInstance().getFormsByMc(mcid, (o1, o2) -> { List<ModelForm> set = ModelFormCache.getInstance().getFormsByMc(mcid, (o1, o2) -> {
@@ -177,11 +175,7 @@ public class ModelCatalogTreeHandler extends AbstractTreeHandler<DefaultEntity>
if (set == null || set.isEmpty()) return; if (set == null || set.isEmpty()) return;
switch (type) { switch (type) {
case TYPE_PAGE: case TYPE_PAGE:
for (ModelForm form : set) {
if (form.getType() != SwEnum.FormType.WIDGET.value) {
listRet.add(form);
}
}
addForm(listRet, set, true);
break; break;
case TYPE_WIDGET: case TYPE_WIDGET:
for (ModelForm form : set) { for (ModelForm form : set) {
@@ -191,7 +185,7 @@ public class ModelCatalogTreeHandler extends AbstractTreeHandler<DefaultEntity>
} }
break; break;
default: default:
listRet.addAll(set);
addForm(listRet, set, false);
} }
} }




+ 1
- 0
smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/design/form/ModelFormSaveHandler.java View File

@@ -81,6 +81,7 @@ public class ModelFormSaveHandler extends DefaultSaveHandler<ModelForm> {
page.setId(DbEngine.getInstance().nextId()); page.setId(DbEngine.getInstance().nextId());
page.setOption("{}"); page.setOption("{}");
page.setDataset(null); page.setDataset(null);
page.setContent(null);
page.setTmpl(null); page.setTmpl(null);
page.setType(SwEnum.FormType.PAGE.value); page.setType(SwEnum.FormType.PAGE.value);
page.setName(name); page.setName(name);


+ 1
- 1
smtweb-framework/bpm/src/main/resources/config/application.yaml View File

@@ -27,7 +27,7 @@ spring:
password: password:
datasource: datasource:
driver-class-name: com.mysql.cj.jdbc.Driver driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://127.0.0.1:3306/gdmz?useUnicode=true&characterEncoding=utf-8&allowMultiQueries=true&useSSL=false
url: jdbc:mysql://127.0.0.1:3306/smt_asp?useUnicode=true&characterEncoding=utf-8&allowMultiQueries=true&useSSL=false
username: root username: root
password: root password: root
servlet: servlet:


+ 1
- 1
smtweb-framework/core/src/main/java/cc/smtweb/framework/core/mvc/service/AbstractTreeHandler.java View File

@@ -58,7 +58,7 @@ public abstract class AbstractTreeHandler<T> extends AbstractHandler {
node.put("bean", row); node.put("bean", row);
buildNode(node, row); buildNode(node, row);
listRet.add(node); listRet.add(node);
if (!lazy) {
if (!lazy && !node.containsKey("children")) {
List<SwMap> list = buildNodes(children, lazy); List<SwMap> list = buildNodes(children, lazy);
node.put("children", list); node.put("children", list);
} }


+ 506
- 310
smtweb-framework/core/src/main/resources/demo.json
File diff suppressed because it is too large
View File


Loading…
Cancel
Save