From 3df6834ffaef2a89c0ab932ad4862edce0a0c5ad Mon Sep 17 00:00:00 2001 From: lip Date: Fri, 2 Sep 2022 21:05:16 +0800 Subject: [PATCH] =?UTF-8?q?=E6=A8=A1=E5=9E=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../bpm/web/design/form/ModelFormHelper.java | 1 + .../bpm/web/design/form/ModelFormSaveHandler.java | 1 + .../bpm/web/engine/model/listcard/ModelUtils.java | 25 +++ .../model/listcard/abshandler/AbsDelHandler.java | 84 +++++++++ .../model/listcard/abshandler/AbsLoadHandler.java | 84 +++++++++ .../model/listcard/abshandler/AbsSaveHandler.java | 205 ++++++++++++++++++++ .../engine/model/listcard/lclc1/LCLC1Define.java | 12 ++ .../model/listcard/lclc1/LCLC1DelHandler.java | 71 +------ .../engine/model/listcard/lclc1/LCLC1Handler.java | 12 -- .../model/listcard/lclc1/LCLC1LoadHandler.java | 84 ++------- .../model/listcard/lclc1/LCLC1SaveHandler.java | 208 +-------------------- .../engine/model/listcard/lclc1/LCLC1Service.java | 10 +- .../model/listcard/mastersub/LCMsDefine.java | 14 ++ .../model/listcard/mastersub/LCMsDelHandler.java | 44 ++++- .../model/listcard/mastersub/LCMsLoadHandler.java | 58 +++++- .../model/listcard/mastersub/LCMsSaveHandler.java | 58 ++---- .../model/listcard/mastersub/LCMsService.java | 43 +++-- .../model/listcard/normal/LCNormalDefine.java | 12 ++ .../model/listcard/normal/LCNormalDelHandler.java | 56 ++---- .../model/listcard/normal/LCNormalLoadHandler.java | 66 +------ .../model/listcard/normal/LCNormalSaveHandler.java | 22 +++ .../model/listcard/normal/LCNormalService.java | 28 ++- .../model/listcard/single/LCSingleSaveHandler.java | 2 - .../template/default/incModel/inc_list_table.ftl | 9 +- .../static/template/default/model_card_ms.ftl | 7 +- .../static/template/default/model_list_list_1.ftl | 8 +- .../static/template/default/model_list_list_2.ftl | 4 +- .../static/template/default/model_list_normal.ftl | 8 +- .../static/template/default/model_tree_list.ftl | 8 +- 29 files changed, 693 insertions(+), 551 deletions(-) create mode 100644 smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/listcard/ModelUtils.java create mode 100644 smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/listcard/abshandler/AbsDelHandler.java create mode 100644 smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/listcard/abshandler/AbsLoadHandler.java create mode 100644 smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/listcard/abshandler/AbsSaveHandler.java create mode 100644 smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/listcard/lclc1/LCLC1Define.java delete mode 100644 smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/listcard/lclc1/LCLC1Handler.java create mode 100644 smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/listcard/mastersub/LCMsDefine.java create mode 100644 smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/listcard/normal/LCNormalDefine.java create mode 100644 smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/listcard/normal/LCNormalSaveHandler.java 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 2dfed23..c7d0d1e 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 @@ -436,6 +436,7 @@ public class ModelFormHelper { PageDatasets datasets = form.getDatasets(); SwMap tmplModel = JsonUtil.parse(form.getTmpl(), SwMap.class); tmplModel.put("title", form.getTitle()); + tmplModel.put("name", form.getName()); tmplModel.put("datasets", JsonUtil.bean2MapList(form.getDatasets().list)); SwMap layout = tmplModel.readMap("layout"); //用到的自定义控件 diff --git a/smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/design/form/ModelFormSaveHandler.java b/smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/design/form/ModelFormSaveHandler.java index 6e7614d..cf9fae2 100644 --- a/smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/design/form/ModelFormSaveHandler.java +++ b/smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/design/form/ModelFormSaveHandler.java @@ -57,6 +57,7 @@ public class ModelFormSaveHandler extends DefaultSaveHandler { ModelFormCache.getInstance().put(bean); if (listFormChild != null) { for (ModelForm page : listFormChild) { + page.removeStatus(); ModelFormCache.getInstance().put(page); } } diff --git a/smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/listcard/ModelUtils.java b/smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/listcard/ModelUtils.java new file mode 100644 index 0000000..53337e6 --- /dev/null +++ b/smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/listcard/ModelUtils.java @@ -0,0 +1,25 @@ +package cc.smtweb.system.bpm.web.engine.model.listcard; + +import cc.smtweb.framework.core.common.SwMap; +import cc.smtweb.system.bpm.web.design.form.define.PageDataset; +import cc.smtweb.system.bpm.web.design.form.define.PageDatasets; +import cc.smtweb.system.bpm.web.engine.dynPage.DynRetBean; +import org.springframework.util.Assert; + +/** + * @Author:lip + * @Date : 2022/9/2 15:22 + */ +public class ModelUtils { + public static SwMap buildRetData(String dsName, SwMap data) { + SwMap mapRet = new SwMap(); + mapRet.put(dsName, DynRetBean.createBean(data)); + return mapRet; + } + + public static PageDataset findPageDatasetByName(PageDatasets dataSets, String dsName) { + PageDataset pageDataset = dataSets.findByName(dsName); + Assert.notNull(pageDataset, "未获取到数据集:" + dsName); + return pageDataset; + } +} diff --git a/smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/listcard/abshandler/AbsDelHandler.java b/smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/listcard/abshandler/AbsDelHandler.java new file mode 100644 index 0000000..2db3ca2 --- /dev/null +++ b/smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/listcard/abshandler/AbsDelHandler.java @@ -0,0 +1,84 @@ +package cc.smtweb.system.bpm.web.engine.model.listcard.abshandler; + +import cc.smtweb.framework.core.cache.AbstractCache; +import cc.smtweb.framework.core.cache.CacheManager; +import cc.smtweb.framework.core.db.DbEngine; +import cc.smtweb.framework.core.db.EntityDao; +import cc.smtweb.framework.core.db.EntityHelper; +import cc.smtweb.framework.core.db.cache.ModelTableCache; +import cc.smtweb.framework.core.db.jdbc.AbsDbWorker; +import cc.smtweb.framework.core.db.vo.ModelTable; +import cc.smtweb.framework.core.exception.BizException; +import cc.smtweb.system.bpm.web.design.form.define.PageDataset; +import cc.smtweb.system.bpm.web.engine.dynPage.AbstractDynPageHandler; +import cc.smtweb.system.bpm.web.engine.model.listcard.ModelUtils; + +/** + * @Author:lip + * @Date : 2022/9/2 15:03 + */ +public abstract class AbsDelHandler extends AbstractDynPageHandler { + /** + * 删除指定数据集,入参{pageId, dataset, id} + * + * @return + */ + protected void doDel(String dsName) { + long id = params.readLong("id"); + if (id <= 0L) throw new BizException("没有收到待删除记录Id(" + id + ")!"); + //数据集 + PageDataset pageDataset = ModelUtils.findPageDatasetByName(this.datasets,dsName); + // + checkBean(pageDataset, id); + // + DbEngine.getInstance().doTrans(new AbsDbWorker() { + @Override + public void work() { + ModelTable table = ModelTableCache.getInstance().get(pageDataset.masterTable); + if (table == null) throw new BizException("没有找到指定的的表定义:" + pageDataset.name + "!"); + EntityDao dao = DbEngine.getInstance().findDao(table.getName()); + dao.deleteEntity(id); + localDel(id, table); + } + + @Override + public void doAfterDbCommit() { + ModelTable table = ModelTableCache.getInstance().get(pageDataset.masterTable); + if (table.isNeedCache()) { + AbstractCache cache = CacheManager.getIntance().getCache(table.getName()); + cache.remove(id); + } + afterCommit(id, table); + } + + @Override + public void doAfterDbRollback() { + afterRollback(id); + } + }); + } + + //回调:::删除之后 + protected void localDel(long id, ModelTable table) { + } + + //回调:::提交成功后 + protected void afterCommit(long id, ModelTable table) { + } + + //回调:::提交失败,事务回滚后 + protected void afterRollback(long id) { + + } + + /** + * 删除校验 + * + * @param pageDataSet + * @param id + */ + protected void checkBean(PageDataset pageDataSet, long id) { + //校验外键引用关系 + EntityHelper.checkExists(pageDataSet.masterTable, id); + } +} diff --git a/smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/listcard/abshandler/AbsLoadHandler.java b/smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/listcard/abshandler/AbsLoadHandler.java new file mode 100644 index 0000000..24fbb06 --- /dev/null +++ b/smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/listcard/abshandler/AbsLoadHandler.java @@ -0,0 +1,84 @@ +package cc.smtweb.system.bpm.web.engine.model.listcard.abshandler; + +import cc.smtweb.framework.core.common.R; +import cc.smtweb.framework.core.common.SwMap; +import cc.smtweb.system.bpm.web.design.form.define.PageDataset; +import cc.smtweb.system.bpm.web.engine.dynPage.AbstractDynPageHandler; +import cc.smtweb.system.bpm.web.engine.dynPage.DynPageHelper; +import cc.smtweb.system.bpm.web.engine.dynPage.DynPageListHandler; +import cc.smtweb.system.bpm.web.engine.dynPage.DynRetBean; +import cc.smtweb.system.bpm.web.engine.model.listcard.ModelUtils; +import org.springframework.util.Assert; + +/** + * @Author:lip + * @Date : 2022/9/2 15:03 + */ +public abstract class AbsLoadHandler extends AbstractDynPageHandler { + + /** + * 新增初始化 + * @param dsName + * @return + */ + protected SwMap doAdd(String dsName) { + PageDataset addDataSet = this.datasets.findByName(dsName); + Assert.notNull(addDataSet, "未获取到数据集:" + dsName); + SwMap data; + //懒加载,给个空对象 + if (addDataSet.lazy) { + data = new SwMap(); + } else { + data = DynPageHelper.createBean(addDataSet); + } + return data; + } + + /** + * 加载卡片数据 + * @param dsName + * @return + */ + protected SwMap doLoadCard(String dsName){ + //过滤条件 + SwMap filter = params.readMap("filter"); + //对应的数据集定义 + PageDataset loadDataSet = ModelUtils.findPageDatasetByName(this.datasets,dsName); + return provider.loadData(filter, loadDataSet); + } + + /** + * 列表数据 + * @return + */ + protected DynRetBean doList(String dsName) { + //过滤条件 + SwMap filter = params.readMap("filter"); + + //对应的数据集定义 + PageDataset listDataSet = ModelUtils.findPageDatasetByName(this.datasets,dsName); + + return DynRetBean.createList(getListWorker(filter, listDataSet).buildListData()); + } + + /** + * 计算分页数据 + * + * @return + */ + protected R doTotal(String dsName) { + //过滤条件 + SwMap filter = params.readMap("filter"); + + //对应的数据集定义 + PageDataset listDataSet = ModelUtils.findPageDatasetByName(this.datasets,dsName); + + return getListWorker(filter, listDataSet).getTotal(); + } + + protected DynPageListHandler getListWorker(SwMap filter, PageDataset pageDataSet) { + DynPageListHandler listHandler = new DynPageListHandler(form.getId(), filter, pageDataSet); + listHandler.init(params, us); + return listHandler; + } +} diff --git a/smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/listcard/abshandler/AbsSaveHandler.java b/smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/listcard/abshandler/AbsSaveHandler.java new file mode 100644 index 0000000..943ab8c --- /dev/null +++ b/smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/listcard/abshandler/AbsSaveHandler.java @@ -0,0 +1,205 @@ +package cc.smtweb.system.bpm.web.engine.model.listcard.abshandler; + +import cc.smtweb.framework.core.cache.AbstractCache; +import cc.smtweb.framework.core.cache.CacheManager; +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.db.cache.ModelTableCache; +import cc.smtweb.framework.core.db.impl.DefaultEntity; +import cc.smtweb.framework.core.db.jdbc.AbsDbWorker; +import cc.smtweb.framework.core.db.vo.ModelField; +import cc.smtweb.framework.core.db.vo.ModelIndex; +import cc.smtweb.framework.core.db.vo.ModelTable; +import cc.smtweb.framework.core.exception.BizException; +import cc.smtweb.framework.core.mvc.service.TreeHelper; +import cc.smtweb.framework.core.util.StringUtil; +import cc.smtweb.system.bpm.web.design.form.define.PageDataset; +import cc.smtweb.system.bpm.web.design.form.define.PageDatasetFilter; +import cc.smtweb.system.bpm.web.engine.dynPage.AbstractDynPageHandler; +import cc.smtweb.system.bpm.web.engine.model.listcard.ModelUtils; +import org.apache.commons.lang3.StringUtils; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * @Author:lip + * @Date : 2022/9/2 15:02 + */ +public abstract class AbsSaveHandler extends AbstractDynPageHandler { + private Map> mapTreeBean = new HashMap<>(); + + protected void setNewId(T bean) { + bean.setEntityId(DbEngine.getInstance().nextId()); + } + + protected T doSave(String dsName) { + //数据集 + SwMap filter = params.readMap("filter"); + //待保存数据 + SwMap data = params.readMap("data"); + if (data == null) throw new BizException("没有收到待保存的的数据:" + dsName + "!"); + //对应的数据集定义 + PageDataset pageDataSet = ModelUtils.findPageDatasetByName(this.datasets,dsName); + //读取待保存的bean + T bean = readBeanFromPage(pageDataSet, data.readMap(dsName).readMap("form")); + if (filter != null && bean.isNew()) {//有过滤条件,将关联的值设上 + setLinkValue(pageDataSet, bean, f -> filter.get(f.name)); + } + checkBean(bean); + + DbEngine.getInstance().doTrans(new AbsDbWorker() { + @Override + public void work() { + saveBean(bean); + } + + @Override + public void doAfterDbCommit() { + afterCommit(bean); + } + + @Override + public void doAfterDbRollback() { + afterRollback(bean); + } + }); + return bean; + } + + /** + * 从页面获取待保存的bean + * + * @param pageDataSet + * @param data + * @return + */ + protected T readBeanFromPage(PageDataset pageDataSet, SwMap data) { + ModelTable table = ModelTableCache.getInstance().get(pageDataSet.masterTable); + if (table == null) throw new BizException("没有找到待保存的表定义:" + pageDataSet.name); + + long id = data.readLong(table.getIdField()); + + EntityDao dao = DbEngine.getInstance().findDao(table.getName()); + T bean; + if (id <= 0L) { + bean = dao.createBean(); + bean.setIsNew(true); + //暂时不考虑list保存的情况 + bean.getData().putAll(data); + bean.setEntityId(DbEngine.getInstance().nextId()); + } else { + bean = dao.queryEntity(id); + if (bean == null) { + throw new BizException("没有找到待保存的记录:" + table.getName() + "." + id); + } + //暂时不考虑list保存的情况 + bean.getData().putAll(data); + bean.setIsNew(false); + } + return bean; + } + + /** + * 保存校验 + * + * @param bean + */ + protected void checkBean(T bean) { + ModelTable table = ModelTableCache.getInstance().getByName(bean.getTableName()); + for (ModelField field : table.getFields()) { + String value = bean.getStr(field.getName()); + //非空校验 + if (field.isNotNull() && StringUtils.isEmpty(value)) { + throw new BizException("字段不允许为空:" + field.getTitle()); + } + + //长度校验 + if (StringUtils.isNotEmpty(value)) { + int len = SwEnum.DataType.instance.getByValue(field.getDataType()).dataLength; + if (len > 0 && StringUtil.getStrLenB(value) > len) { + throw new BizException("字段值超长:" + field.getTitle()); + } + } + } + //唯一键校验 + EntityDao dao = DbEngine.getInstance().findDao(bean.getTableName()); + for (ModelIndex mi : table.getIndexes()) { + if (mi.isUnique()) { + dao.checkUnique(bean, mi.getFields().split(",")); + } + } + } + + protected void saveBean(T bean) { + final String tableName = bean.getTableName(); + EntityDao dao = DbEngine.getInstance().findDao(tableName); + if (bean.isNew()) { + dao.insertEntity(bean); + } else { + ModelTable table = ModelTableCache.getInstance().getByName(tableName); + ModelField field = table.findFieldByType(SwEnum.FieldType.UPDATE_USER.value); + if (field != null) bean.put(field.getName(), us.getUserId()); + + dao.updateEntity(bean); + if (table.getType() == SwEnum.TableType.TYPE_TREE.value) { + List listTreeBean = TreeHelper.getTreeHelper(tableName).resetTreeLevel(bean); + mapTreeBean.put(tableName, listTreeBean); + } + } + } + + protected void afterCommit(T bean) { + final String tableName = bean.getTableName(); + ModelTable table = ModelTableCache.getInstance().getByName(tableName); + if (table.isNeedCache()) { + AbstractCache cache = CacheManager.getIntance().getCache(tableName); + List listTreeBean = mapTreeBean.get(tableName); + //树型表,父亲改变了,要多处理下缓存;还有个东东:级次码 + if (listTreeBean != null && !listTreeBean.isEmpty()) { + for (DefaultEntity b : listTreeBean) { + cache.put(b); + } + } else { + cache.put(bean); + } + } + } + + protected void afterRollback(T bean) { + final String tableName = bean.getTableName(); + ModelTable table = ModelTableCache.getInstance().getByName(tableName); + if (table.isNeedCache()) { + AbstractCache cache = CacheManager.getIntance().getCache(tableName); + cache.reset(bean); + } + } + + //将关联的值设上 + protected void setLinkValue(PageDataset pageDataSet, T bean, IGetValue iGetValue) { + ModelTable table = ModelTableCache.getInstance().getByName(bean.getTableName()); + for (PageDatasetFilter f : pageDataSet.filters) { + String v = bean.getStr(f.field); + //有值,就不管 + if (v != null && !v.equals(table.findField(f.field).getDefaultValue())) continue; + + if (SwEnum.FilterType.CONST.value.equals(f.type)) {//常量 + bean.put(f.field, f.value); + } else if (SwEnum.FilterType.PARAM.value.equals(f.type)) {//参数 + bean.put(f.field, f.value); + } else if (SwEnum.FilterType.LINK.value.equals(f.type)) {//参数 + Object value = iGetValue.getValue(f); + if (value != null) { + bean.put(f.field, value); + } + } + } + } + + public interface IGetValue { + Object getValue(PageDatasetFilter f); + } +} diff --git a/smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/listcard/lclc1/LCLC1Define.java b/smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/listcard/lclc1/LCLC1Define.java new file mode 100644 index 0000000..2bd1091 --- /dev/null +++ b/smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/listcard/lclc1/LCLC1Define.java @@ -0,0 +1,12 @@ +package cc.smtweb.system.bpm.web.engine.model.listcard.lclc1; + +/** + * @Author:lip + * @Date : 2022/9/2 12:00 + */ +public class LCLC1Define { + public static final String dsLList = "lList"; + public static final String dsLCard = "lCard"; + public static final String dsRList = "rList"; + public static final String dsRCard = "rCard"; +} diff --git a/smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/listcard/lclc1/LCLC1DelHandler.java b/smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/listcard/lclc1/LCLC1DelHandler.java index ad6b1db..e4e13ba 100644 --- a/smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/listcard/lclc1/LCLC1DelHandler.java +++ b/smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/listcard/lclc1/LCLC1DelHandler.java @@ -1,30 +1,20 @@ package cc.smtweb.system.bpm.web.engine.model.listcard.lclc1; -import cc.smtweb.framework.core.cache.AbstractCache; -import cc.smtweb.framework.core.cache.CacheManager; import cc.smtweb.framework.core.common.R; -import cc.smtweb.framework.core.db.DbEngine; -import cc.smtweb.framework.core.db.EntityDao; -import cc.smtweb.framework.core.db.EntityHelper; -import cc.smtweb.framework.core.db.cache.ModelTableCache; -import cc.smtweb.framework.core.db.jdbc.AbsDbWorker; -import cc.smtweb.framework.core.db.vo.ModelTable; -import cc.smtweb.framework.core.exception.BizException; -import cc.smtweb.system.bpm.web.design.form.define.PageDataset; -import cc.smtweb.system.bpm.web.engine.dynPage.AbstractDynPageHandler; +import cc.smtweb.system.bpm.web.engine.model.listcard.abshandler.AbsDelHandler; /** * @Author:lip * @Date : 2022/9/2 11:44 */ -public class LCLC1DelHandler extends AbstractDynPageHandler { +public class LCLC1DelHandler extends AbsDelHandler { /** * 左列表删除 * @return */ public R lLDel(){ - del(LCLC1Handler.dsLList); + doDel(LCLC1Define.dsLList); return R.success(); } @@ -33,7 +23,7 @@ public class LCLC1DelHandler extends AbstractDynPageHandler { * @return */ public R lCDel(){ - del(LCLC1Handler.dsLCard); + doDel(LCLC1Define.dsLCard); return R.success(); } @@ -42,7 +32,7 @@ public class LCLC1DelHandler extends AbstractDynPageHandler { * @return */ public R rLDel(){ - del(LCLC1Handler.dsRList); + doDel(LCLC1Define.dsRList); return R.success(); } @@ -51,56 +41,7 @@ public class LCLC1DelHandler extends AbstractDynPageHandler { * @return */ public R rCDel(){ - del(LCLC1Handler.dsRCard); + doDel(LCLC1Define.dsRCard); return R.success(); } - - private void del(String dsName) { - long id = params.readLong("id"); - if (id == 0L) throw new BizException("没有收到待删除记录Id(" + id + ")!"); - //数据集 - PageDataset pageDataset = this.datasets.findByName(dsName); - - checkBean(pageDataset, id); - - DbEngine.getInstance().doTrans(new AbsDbWorker() { - @Override - public void work() { - ModelTable table = ModelTableCache.getInstance().get(pageDataset.masterTable); - if (table == null) throw new BizException("没有找到指定的的表定义:" + pageDataset.name + "!"); - EntityDao dao = DbEngine.getInstance().findDao(table.getName()); - dao.deleteEntity(id); - localDel(id, table); - } - - @Override - public void doAfterDbCommit() { - ModelTable table = ModelTableCache.getInstance().get(pageDataset.masterTable); - if (table.isNeedCache()) { - AbstractCache cache = CacheManager.getIntance().getCache(table.getName()); - cache.remove(id); - } - localDelSuccess(id, table); - } - }); - } - - protected void localDel(long id, ModelTable table) { - - } - - protected void localDelSuccess(long id, ModelTable table) { - - } - - /** - * 删除校验 - * - * @param pageDataSet - * @param id - */ - protected void checkBean(PageDataset pageDataSet, long id) { - //校验外键引用关系 - EntityHelper.checkExists(pageDataSet.masterTable, id); - } } diff --git a/smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/listcard/lclc1/LCLC1Handler.java b/smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/listcard/lclc1/LCLC1Handler.java deleted file mode 100644 index 39da242..0000000 --- a/smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/listcard/lclc1/LCLC1Handler.java +++ /dev/null @@ -1,12 +0,0 @@ -package cc.smtweb.system.bpm.web.engine.model.listcard.lclc1; - -/** - * @Author:lip - * @Date : 2022/9/2 12:00 - */ -public class LCLC1Handler { - public static String dsLList = "lList"; - public static String dsLCard = "lCard"; - public static String dsRList = "rList"; - public static String dsRCard = "rCard"; -} diff --git a/smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/listcard/lclc1/LCLC1LoadHandler.java b/smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/listcard/lclc1/LCLC1LoadHandler.java index 45cf34e..c6f82d1 100644 --- a/smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/listcard/lclc1/LCLC1LoadHandler.java +++ b/smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/listcard/lclc1/LCLC1LoadHandler.java @@ -2,26 +2,22 @@ package cc.smtweb.system.bpm.web.engine.model.listcard.lclc1; import cc.smtweb.framework.core.common.R; import cc.smtweb.framework.core.common.SwMap; -import cc.smtweb.system.bpm.web.design.form.define.PageDataset; -import cc.smtweb.system.bpm.web.engine.dynPage.AbstractDynPageHandler; -import cc.smtweb.system.bpm.web.engine.dynPage.DynPageHelper; -import cc.smtweb.system.bpm.web.engine.dynPage.DynPageListHandler; import cc.smtweb.system.bpm.web.engine.dynPage.DynRetBean; +import cc.smtweb.system.bpm.web.engine.model.listcard.abshandler.AbsLoadHandler; import cc.smtweb.system.bpm.web.engine.model.listcard.single.LCSingleHelper; -import org.springframework.util.Assert; /** * @Author:lip * @Date : 2022/9/2 11:44 */ -public class LCLC1LoadHandler extends AbstractDynPageHandler { +public class LCLC1LoadHandler extends AbsLoadHandler { /** * 左表新增 * @return */ public R lAdd() { - SwMap data = add(LCLC1Handler.dsLCard); - return R.success(LCSingleHelper.buildRetData(LCLC1Handler.dsLCard, data)); + SwMap data = doAdd(LCLC1Define.dsLCard); + return R.success(LCSingleHelper.buildRetData(LCLC1Define.dsLCard, data)); } /** @@ -29,21 +25,8 @@ public class LCLC1LoadHandler extends AbstractDynPageHandler { * @return */ public R rAdd() { - SwMap data = add(LCLC1Handler.dsRCard); - return R.success(LCSingleHelper.buildRetData(LCLC1Handler.dsRCard, data)); - } - - private SwMap add(String dsName) { - PageDataset addDataSet = this.datasets.findByName(dsName); - Assert.notNull(addDataSet, "未获取到数据集:" + dsName); - SwMap data; - //懒加载,给个空对象 - if (addDataSet.lazy) { - data = new SwMap(); - } else { - data = DynPageHelper.createBean(addDataSet); - } - return data; + SwMap data = doAdd(LCLC1Define.dsRCard); + return R.success(LCSingleHelper.buildRetData(LCLC1Define.dsRCard, data)); } /** @@ -51,8 +34,8 @@ public class LCLC1LoadHandler extends AbstractDynPageHandler { * @return */ public R lLoad() { - SwMap bean = load(LCLC1Handler.dsLCard); - return R.success(LCSingleHelper.buildRetData(LCLC1Handler.dsLCard, bean)); + SwMap bean = doLoadCard(LCLC1Define.dsLCard); + return R.success(LCSingleHelper.buildRetData(LCLC1Define.dsLCard, bean)); } /** @@ -60,25 +43,8 @@ public class LCLC1LoadHandler extends AbstractDynPageHandler { * @return */ public R rLoad() { - SwMap bean = load(LCLC1Handler.dsRCard); - return R.success(LCSingleHelper.buildRetData(LCLC1Handler.dsRCard, bean)); - } - - private SwMap load(String dsName) { - //过滤条件 - SwMap filter = params.readMap("filter"); - - //对应的数据集定义 - PageDataset loadDataSet = this.datasets.findByName(dsName); - Assert.notNull(loadDataSet, "未获取到数据集:" + dsName); - - return provider.loadData(filter, loadDataSet); - } - - private DynPageListHandler getListWorker(SwMap filter, PageDataset pageDataSet) { - DynPageListHandler listHandler = new DynPageListHandler(form.getId(), filter, pageDataSet); - listHandler.init(params, us); - return listHandler; + SwMap bean = doLoadCard(LCLC1Define.dsRCard); + return R.success(LCSingleHelper.buildRetData(LCLC1Define.dsRCard, bean)); } /** @@ -86,7 +52,7 @@ public class LCLC1LoadHandler extends AbstractDynPageHandler { * @return */ public R lList(){ - DynRetBean list = list(LCLC1Handler.dsLList); + DynRetBean list = doList(LCLC1Define.dsLList); return R.success(list); } @@ -95,27 +61,16 @@ public class LCLC1LoadHandler extends AbstractDynPageHandler { * @return */ public R rList(){ - DynRetBean list = list(LCLC1Handler.dsRList); + DynRetBean list = doList(LCLC1Define.dsRList); return R.success(list); } - private DynRetBean list(String dsName) { - //过滤条件 - SwMap filter = params.readMap("filter"); - - //对应的数据集定义 - PageDataset listDataSet = this.datasets.findByName(dsName); - Assert.notNull(listDataSet, "未获取到数据集:" + dsName); - - return DynRetBean.createList(getListWorker(filter, listDataSet).buildListData()); - } - /** * 左列表分页数据 * @return */ public R getLTotal(){ - return getTotal(LCLC1Handler.dsLList); + return doTotal(LCLC1Define.dsLList); } /** @@ -123,17 +78,6 @@ public class LCLC1LoadHandler extends AbstractDynPageHandler { * @return */ public R getRTotal(){ - return getTotal(LCLC1Handler.dsRList); - } - - private R getTotal(String dsName) { - //过滤条件 - SwMap filter = params.readMap("filter"); - - //对应的数据集定义 - PageDataset listDataSet = this.datasets.findByName(dsName); - Assert.notNull(listDataSet, "未获取到数据集:" + dsName); - - return getListWorker(filter, listDataSet).getTotal(); + return doTotal(LCLC1Define.dsRList); } } diff --git a/smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/listcard/lclc1/LCLC1SaveHandler.java b/smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/listcard/lclc1/LCLC1SaveHandler.java index bdd670b..b1dfbc5 100644 --- a/smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/listcard/lclc1/LCLC1SaveHandler.java +++ b/smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/listcard/lclc1/LCLC1SaveHandler.java @@ -1,51 +1,22 @@ package cc.smtweb.system.bpm.web.engine.model.listcard.lclc1; - -import cc.smtweb.framework.core.cache.AbstractCache; -import cc.smtweb.framework.core.cache.CacheManager; import cc.smtweb.framework.core.common.R; -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.db.cache.ModelTableCache; import cc.smtweb.framework.core.db.impl.DefaultEntity; -import cc.smtweb.framework.core.db.jdbc.AbsDbWorker; -import cc.smtweb.framework.core.db.vo.ModelField; -import cc.smtweb.framework.core.db.vo.ModelIndex; -import cc.smtweb.framework.core.db.vo.ModelTable; -import cc.smtweb.framework.core.exception.BizException; -import cc.smtweb.framework.core.mvc.service.TreeHelper; -import cc.smtweb.framework.core.util.StringUtil; -import cc.smtweb.system.bpm.web.design.form.define.PageDataset; -import cc.smtweb.system.bpm.web.design.form.define.PageDatasetFilter; -import cc.smtweb.system.bpm.web.engine.dynPage.AbstractDynPageHandler; +import cc.smtweb.system.bpm.web.engine.model.listcard.abshandler.AbsSaveHandler; import cc.smtweb.system.bpm.web.engine.model.listcard.single.LCSingleHelper; -import cc.smtweb.system.bpm.web.engine.model.listcard.single.LCSingleSaveHandler; -import org.apache.commons.lang3.StringUtils; - -import java.util.HashMap; -import java.util.List; -import java.util.Map; /** * @Author:lip * @Date : 2022/9/2 11:44 */ -public class LCLC1SaveHandler extends AbstractDynPageHandler { - private Map> mapTreeBean = new HashMap<>(); - - protected void setNewId(T bean) { - bean.setEntityId(DbEngine.getInstance().nextId()); - } - +public class LCLC1SaveHandler extends AbsSaveHandler { /** * 左表保存 * @return */ public R lSave() { - T bean = save(LCLC1Handler.dsLCard); - return R.success(LCSingleHelper.buildRetData(LCLC1Handler.dsLCard, bean.getData())); + DefaultEntity bean = doSave(LCLC1Define.dsLCard); + return R.success(LCSingleHelper.buildRetData(LCLC1Define.dsLCard, bean.getData())); } /** @@ -53,174 +24,7 @@ public class LCLC1SaveHandler extends AbstractDynPageHa * @return */ public R rSave() { - T bean = save(LCLC1Handler.dsRCard); - return R.success(LCSingleHelper.buildRetData(LCLC1Handler.dsRCard, bean.getData())); - } - - private T save(String dsName) { - //数据集 - SwMap filter = params.readMap("filter"); - //待保存数据 - SwMap data = params.readMap("data"); - if (data == null) throw new BizException("没有收到待保存的的数据:" + dsName + "!"); - //对应的数据集定义 - PageDataset pageDataSet = this.datasets.findByName(dsName); - //读取待保存的bean - T bean = readBeanFromPage(pageDataSet, data.readMap(dsName).readMap("form")); - if (filter != null && bean.isNew()) {//有过滤条件,将关联的值设上 - setLinkValue(pageDataSet, bean, f -> filter.get(f.name)); - } - checkBean(bean); - - DbEngine.getInstance().doTrans(new AbsDbWorker() { - @Override - public void work() { - saveBean(bean); - } - - @Override - public void doAfterDbCommit() { - afterCommit(bean); - } - - @Override - public void doAfterDbRollback() { - afterRollback(bean); - } - }); - return bean; - } - - /** - * 从页面获取待保存的bean - * - * @param pageDataSet - * @param data - * @return - */ - protected T readBeanFromPage(PageDataset pageDataSet, SwMap data) { - ModelTable table = ModelTableCache.getInstance().get(pageDataSet.masterTable); - if (table == null) throw new BizException("没有找到待保存的表定义:" + pageDataSet.name); - - long id = data.readLong(table.getIdField()); - - EntityDao dao = DbEngine.getInstance().findDao(table.getName()); - T bean; - if (id <= 0L) { - bean = dao.createBean(); - bean.setIsNew(true); - //暂时不考虑list保存的情况 - bean.getData().putAll(data); - bean.setEntityId(DbEngine.getInstance().nextId()); - } else { - bean = dao.queryEntity(id); - if (bean == null) { - throw new BizException("没有找到待保存的记录:" + table.getName() + "." + id); - } - //暂时不考虑list保存的情况 - bean.getData().putAll(data); - bean.setIsNew(false); - } - return bean; - } - - /** - * 保存校验 - * - * @param bean - */ - protected void checkBean(T bean) { - ModelTable table = ModelTableCache.getInstance().getByName(bean.getTableName()); - for (ModelField field : table.getFields()) { - String value = bean.getStr(field.getName()); - //非空校验 - if (field.isNotNull() && StringUtils.isEmpty(value)) { - throw new BizException("字段不允许为空:" + field.getTitle()); - } - - //长度校验 - if (StringUtils.isNotEmpty(value)) { - int len = SwEnum.DataType.instance.getByValue(field.getDataType()).dataLength; - if (len > 0 && StringUtil.getStrLenB(value) > len) { - throw new BizException("字段值超长:" + field.getTitle()); - } - } - } - //唯一键校验 - EntityDao dao = DbEngine.getInstance().findDao(bean.getTableName()); - for (ModelIndex mi : table.getIndexes()) { - if (mi.isUnique()) { - dao.checkUnique(bean, mi.getFields().split(",")); - } - } - } - - protected void saveBean(T bean) { - final String tableName = bean.getTableName(); - EntityDao dao = DbEngine.getInstance().findDao(tableName); - if (bean.isNew()) { - dao.insertEntity(bean); - } else { - ModelTable table = ModelTableCache.getInstance().getByName(tableName); - ModelField field = table.findFieldByType(SwEnum.FieldType.UPDATE_USER.value); - if (field != null) bean.put(field.getName(), us.getUserId()); - - dao.updateEntity(bean); - if (table.getType() == SwEnum.TableType.TYPE_TREE.value) { - List listTreeBean = TreeHelper.getTreeHelper(tableName).resetTreeLevel(bean); - mapTreeBean.put(tableName, listTreeBean); - } - } - } - - protected void afterCommit(T bean) { - final String tableName = bean.getTableName(); - ModelTable table = ModelTableCache.getInstance().getByName(tableName); - if (table.isNeedCache()) { - AbstractCache cache = CacheManager.getIntance().getCache(tableName); - List listTreeBean = mapTreeBean.get(tableName); - //树型表,父亲改变了,要多处理下缓存;还有个东东:级次码 - if (listTreeBean != null && !listTreeBean.isEmpty()) { - for (DefaultEntity b : listTreeBean) { - cache.put(b); - } - } else { - cache.put(bean); - } - } - } - - protected void afterRollback(T bean) { - final String tableName = bean.getTableName(); - ModelTable table = ModelTableCache.getInstance().getByName(tableName); - if (table.isNeedCache()) { - AbstractCache cache = CacheManager.getIntance().getCache(tableName); - cache.reset(bean); - } - } - - //将关联的值设上 - protected void setLinkValue(PageDataset pageDataSet, T bean, LCSingleSaveHandler.IGetValue iGetValue) { - ModelTable table = ModelTableCache.getInstance().getByName(bean.getTableName()); - for (PageDatasetFilter f : pageDataSet.filters) { - String v = bean.getStr(f.field); - //有值,就不管 - if (v != null && !v.equals(table.findField(f.field).getDefaultValue())) continue; - - if (SwEnum.FilterType.CONST.value.equals(f.type)) {//常量 - bean.put(f.field, f.value); - } else if (SwEnum.FilterType.PARAM.value.equals(f.type)) {//参数 - bean.put(f.field, f.value); - } else if (SwEnum.FilterType.LINK.value.equals(f.type)) {//参数 - Object value = iGetValue.getValue(f); - if (value != null) { - bean.put(f.field, value); - } - } - } - } - - public interface IGetValue { - Object getValue(PageDatasetFilter f); + DefaultEntity bean = doSave(LCLC1Define.dsRCard); + return R.success(LCSingleHelper.buildRetData(LCLC1Define.dsRCard, bean.getData())); } } diff --git a/smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/listcard/lclc1/LCLC1Service.java b/smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/listcard/lclc1/LCLC1Service.java index c1386d7..f3e9c3f 100644 --- a/smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/listcard/lclc1/LCLC1Service.java +++ b/smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/listcard/lclc1/LCLC1Service.java @@ -14,11 +14,11 @@ import cc.smtweb.system.bpm.web.engine.dynPage.DynPageService; */ @SwService public class LCLC1Service extends DynPageService { - private final static String TYPE_MODEL_LIST = "modelList"; - private final static String TYPE_MODEL_ADD = "modelAdd"; - private final static String TYPE_MODEL_LOAD = "modelLoad"; - private final static String TYPE_MODEL_SAVE = "modelSave"; - private final static String TYPE_MODEL_DEL = "modelDel"; + protected final static String TYPE_MODEL_LIST = "modelList"; + protected final static String TYPE_MODEL_ADD = "modelAdd"; + protected final static String TYPE_MODEL_LOAD = "modelLoad"; + protected final static String TYPE_MODEL_SAVE = "modelSave"; + protected final static String TYPE_MODEL_DEL = "modelDel"; // @Override protected AbstractHandler createHandler(String type) { diff --git a/smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/listcard/mastersub/LCMsDefine.java b/smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/listcard/mastersub/LCMsDefine.java new file mode 100644 index 0000000..0112e1d --- /dev/null +++ b/smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/listcard/mastersub/LCMsDefine.java @@ -0,0 +1,14 @@ +package cc.smtweb.system.bpm.web.engine.model.listcard.mastersub; + +/** + * @Author:lip + * @Date : 2022/9/2 17:06 + */ +public class LCMsDefine { + //列表主表数据集 + public static final String dsMList = "list"; + //卡片主表数据集 + public static final String dsMCard = "cardMaster"; + //卡片子表模型数据集 + public static final String dsSList = "listSub"; +} diff --git a/smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/listcard/mastersub/LCMsDelHandler.java b/smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/listcard/mastersub/LCMsDelHandler.java index cf8d4b0..e971349 100644 --- a/smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/listcard/mastersub/LCMsDelHandler.java +++ b/smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/listcard/mastersub/LCMsDelHandler.java @@ -6,24 +6,45 @@ import cc.smtweb.framework.core.common.R; 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.db.EntityHelper; import cc.smtweb.framework.core.db.cache.ModelTableCache; +import cc.smtweb.framework.core.db.impl.DefaultEntity; import cc.smtweb.framework.core.db.jdbc.AbsDbWorker; import cc.smtweb.framework.core.db.vo.ModelTable; import cc.smtweb.framework.core.exception.BizException; -import cc.smtweb.system.bpm.web.engine.dynPage.AbstractDynPageHandler; +import cc.smtweb.system.bpm.web.engine.model.listcard.abshandler.AbsDelHandler; import org.springframework.util.Assert; +import java.util.List; + /** * @Author:lip * @Date : 2022/8/28 20:40 */ -public class LCMsDelHandler extends AbstractDynPageHandler { +public class LCMsDelHandler extends AbsDelHandler { + + /** + * 列表删除 + * @return + */ + public R lDel(){ + return del(); + } + + /** + * 卡片删除 + * @return + */ + public R cDel(){ + return del(); + } + /** * 删除指定数据集,入参{pageId, dataset, id} * * @return */ - public R del() { + private R del() { long id = params.readLong("id"); if (id <= 0L) throw new BizException("没有收到待删除记录Id(" + id + ")!"); SwMap props = form.getOpts().readMap("config").readMap("props"); @@ -37,14 +58,19 @@ public class LCMsDelHandler extends AbstractDynPageHandler { Assert.isTrue(subTable!= null && !subForeignKey.equals("-1"),"未获取到子表配置"); // + DbEngine engine = DbEngine.getInstance(); + EntityDao masterDao = engine.findDao(masterTable.getName()); + EntityDao subDao = engine.findDao(subTable.getName()); + // + List delDetails = subDao.queryWhere(subForeignKey + " = ?", id); + checkDetails(delDetails); DbEngine.getInstance().doTrans(new AbsDbWorker() { @Override public void work() { - DbEngine engine = DbEngine.getInstance(); - EntityDao masterDao = engine.findDao(masterTable.getName()); - EntityDao subDao = engine.findDao(subTable.getName()); + subDao.batchDelete(delDetails); + // + EntityHelper.checkExists(masterTable.getId(), id); masterDao.deleteEntity(id); - subDao.deleteEntity("where " + subForeignKey + " = ?", id); } @Override @@ -61,4 +87,8 @@ public class LCMsDelHandler extends AbstractDynPageHandler { }); return R.success(); } + + protected void checkDetails(List details){ + details.forEach(item-> EntityHelper.checkExists(item.getModelTable().getId(), item.getEntityId())); + } } diff --git a/smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/listcard/mastersub/LCMsLoadHandler.java b/smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/listcard/mastersub/LCMsLoadHandler.java index caae76e..c21d40f 100644 --- a/smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/listcard/mastersub/LCMsLoadHandler.java +++ b/smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/listcard/mastersub/LCMsLoadHandler.java @@ -1,11 +1,65 @@ package cc.smtweb.system.bpm.web.engine.model.listcard.mastersub; -import cc.smtweb.system.bpm.web.engine.model.listcard.normal.LCNormalLoadHandler; +import cc.smtweb.framework.core.common.R; +import cc.smtweb.framework.core.common.SwMap; +import cc.smtweb.system.bpm.web.engine.dynPage.DynRetBean; +import cc.smtweb.system.bpm.web.engine.model.listcard.abshandler.AbsLoadHandler; +import cc.smtweb.system.bpm.web.engine.model.listcard.single.LCSingleHelper; /** * @Author:lip * @Date : 2022/8/28 21:44 */ -public class LCMsLoadHandler extends LCNormalLoadHandler { +public class LCMsLoadHandler extends AbsLoadHandler { + /** + * 主表新增 + * @return + */ + public R mAdd() { + SwMap data = doAdd(LCMsDefine.dsMCard); + return R.success(LCSingleHelper.buildRetData(LCMsDefine.dsMCard, data)); + } + /** + * 主表编辑 + * @return + */ + public R mLoad() { + SwMap bean = doLoadCard(LCMsDefine.dsMCard); + return R.success(LCSingleHelper.buildRetData(LCMsDefine.dsMCard, bean)); + } + + /** + * 主表列表加载 + * @return + */ + public R mList(){ + DynRetBean list = doList(LCMsDefine.dsMList); + return R.success(list); + } + + /** + * 子列表加载 + * @return + */ + public R sList(){ + DynRetBean list = doList(LCMsDefine.dsSList); + return R.success(list); + } + + /** + * 主列表分页数据 + * @return + */ + public R getMTotal(){ + return doTotal(LCMsDefine.dsMList); + } + + /** + * 子列表分页数据 + * @return + */ + public R getSTotal(){ + return doTotal(LCMsDefine.dsSList); + } } diff --git a/smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/listcard/mastersub/LCMsSaveHandler.java b/smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/listcard/mastersub/LCMsSaveHandler.java index b30d7c7..d2e33fc 100644 --- a/smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/listcard/mastersub/LCMsSaveHandler.java +++ b/smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/listcard/mastersub/LCMsSaveHandler.java @@ -10,8 +10,9 @@ import cc.smtweb.framework.core.db.jdbc.AbsDbWorker; import cc.smtweb.framework.core.db.vo.ModelTable; import cc.smtweb.framework.core.exception.BizException; import cc.smtweb.system.bpm.web.design.form.define.PageDataset; +import cc.smtweb.system.bpm.web.engine.model.listcard.ModelUtils; +import cc.smtweb.system.bpm.web.engine.model.listcard.abshandler.AbsSaveHandler; import cc.smtweb.system.bpm.web.engine.model.listcard.single.LCSingleHelper; -import cc.smtweb.system.bpm.web.engine.model.listcard.single.LCSingleSaveHandler; import org.springframework.util.Assert; import java.util.ArrayList; @@ -21,32 +22,27 @@ import java.util.Set; * @Author:lip * @Date : 2022/8/28 21:03 */ -public class LCMsSaveHandler extends LCSingleSaveHandler { - private String cardMaster = "cardMaster"; - private String listSub = "listSub"; - +public class LCMsSaveHandler extends AbsSaveHandler { /** * 保存指定数据集操作,入参:{pageId,dataset:"", data:{form:{},list: {total:0,rows:[]}}, filter:{}} */ public R save() { - //数据集 - String dbName = params.readString("dataset"); + //对应的数据集定义 + PageDataset masterDataSet = ModelUtils.findPageDatasetByName(this.datasets, LCMsDefine.dsMCard); + PageDataset subDataSet = ModelUtils.findPageDatasetByName(this.datasets, LCMsDefine.dsSList); + // SwMap filter = params.readMap("filter"); //待保存数据 SwMap data = params.readMap("data"); - if (data == null) throw new BizException("没有收到待保存的的数据:" + dbName + "!"); + if (data == null) throw new BizException("没有收到待保存的的数据:" + LCMsDefine.dsMCard + "!"); + //获取子表关联字段 String subForeignKey = form.getOpts().readMap("config").readMap("props").readString("subForeignKey","-1"); Assert.isTrue(!subForeignKey.equals("-1"),"未获取到子表外键配置"); - //对应的数据集定义 - PageDataset masterDataSet = findDataset(cardMaster); - PageDataset subDataSet = findDataset(listSub); - Assert.isTrue(masterDataSet != null && subDataSet != null,"没有找到数据集"); - //读取待保存的bean - DefaultEntity masterBean = readBeanFromPage(masterDataSet, data.readMap(cardMaster).readMap("form")); + DefaultEntity masterBean = readBeanFromPage(masterDataSet, data.readMap(LCMsDefine.dsMCard).readMap("form")); if (filter != null && masterBean.isNew()) { //有过滤条件,将关联的值设上 setLinkValue(masterDataSet, masterBean, f -> filter.get(f.name)); @@ -54,6 +50,7 @@ public class LCMsSaveHandler extends LCSingleSaveHandler { // 读取子表数据 SwMap details = params.readMap("details"); Assert.notNull(details,"没有收到待保存的明细数据"); + // ArrayList inserted = new ArrayList<>(); ArrayList updated = new ArrayList<>(); details.readListMap("inserted").forEach(row -> { @@ -101,37 +98,4 @@ public class LCMsSaveHandler extends LCSingleSaveHandler { }); return R.success(LCSingleHelper.buildRetData(masterDataSet.name, masterBean.getData())); } - - /** - * 从页面获取待保存的bean - * - * @param pageDataSet - * @param data - * @return - */ - protected DefaultEntity readBeanFromPage(PageDataset pageDataSet, SwMap data) { - ModelTable table = ModelTableCache.getInstance().get(pageDataSet.masterTable); - if (table == null) throw new BizException("没有找到待保存的表定义:" + pageDataSet.name); - - long id = data.readLong(table.getIdField()); - - EntityDao dao = DbEngine.getInstance().findDao(table.getName()); - DefaultEntity bean; - if (id <= 0L) { - bean = dao.createBean(); - bean.setIsNew(true); - //暂时不考虑list保存的情况 - bean.getData().putAll(data); - } else { - bean = dao.queryEntity(id); - if (bean == null) { - throw new BizException("没有找到待保存的记录:" + table.getName() + "." + id); - } - //暂时不考虑list保存的情况 - bean.getData().putAll(data); - bean.setIsNew(false); - } - return bean; - } - } diff --git a/smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/listcard/mastersub/LCMsService.java b/smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/listcard/mastersub/LCMsService.java index c638e75..224c8d2 100644 --- a/smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/listcard/mastersub/LCMsService.java +++ b/smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/listcard/mastersub/LCMsService.java @@ -6,14 +6,14 @@ import cc.smtweb.framework.core.common.R; import cc.smtweb.framework.core.common.SwMap; import cc.smtweb.framework.core.mvc.service.AbstractHandler; import cc.smtweb.framework.core.session.UserSession; -import cc.smtweb.system.bpm.web.engine.model.listcard.single.LCSingleService; +import cc.smtweb.system.bpm.web.engine.dynPage.DynPageService; /** * @Author:lip * @Date : 2022/8/28 20:38 */ @SwService -public class LCMsService extends LCSingleService { +public class LCMsService extends DynPageService { private final static String TYPE_MODEL_LIST = "modelList"; private final static String TYPE_MODEL_ADD = "modelAdd"; private final static String TYPE_MODEL_LOAD = "modelLoad"; @@ -42,26 +42,41 @@ public class LCMsService extends LCSingleService { //读取 public R modelLoad(@SwBody SwMap params, UserSession us) { - return pageHandler(params, us, TYPE_MODEL_LOAD, handler -> ((LCMsLoadHandler)handler).load()); + return pageHandler(params, us, TYPE_MODEL_LOAD, handler -> ((LCMsLoadHandler)handler).mLoad()); } - //读取 + //新增 public R modelAdd(@SwBody SwMap params, UserSession us) { - return pageHandler(params, us, TYPE_MODEL_ADD, handler -> ((LCMsLoadHandler)handler).add()); + return pageHandler(params, us, TYPE_MODEL_ADD, handler -> ((LCMsLoadHandler)handler).mAdd()); + } + + //列表删除 + public R modelLDel(@SwBody SwMap params, UserSession us) { + return pageHandler(params, us, TYPE_MODEL_DEL, handler -> ((LCMsDelHandler)handler).lDel()); + } + + //卡片删除 + public R modelCDel(@SwBody SwMap params, UserSession us) { + return pageHandler(params, us, TYPE_MODEL_DEL, handler -> ((LCMsDelHandler)handler).cDel()); + } + + //主表列表数据 + public R modelMList(@SwBody SwMap params, UserSession us) { + return pageHandler(params, us, TYPE_MODEL_LIST, handler -> ((LCMsLoadHandler)handler).mList()); } - //删除 - public R modelDel(@SwBody SwMap params, UserSession us) { - return pageHandler(params, us, TYPE_MODEL_DEL, handler -> ((LCMsDelHandler)handler).del()); + //主表列表总记录数及合计栏 + public R modelMListTotal(@SwBody SwMap params, UserSession us) { + return pageHandler(params, us, TYPE_MODEL_LIST, handler -> ((LCMsLoadHandler)handler).getMTotal()); } - //列表数据 - public R modelList(@SwBody SwMap params, UserSession us) { - return pageHandler(params, us, TYPE_MODEL_LIST, handler -> ((LCMsLoadHandler)handler).list()); + //子表列表数据 + public R modelSList(@SwBody SwMap params, UserSession us) { + return pageHandler(params, us, TYPE_MODEL_LIST, handler -> ((LCMsLoadHandler)handler).sList()); } - //列表总记录数及合计栏 - public R modelListTotal(@SwBody SwMap params, UserSession us) { - return pageHandler(params, us, TYPE_MODEL_LIST, handler -> ((LCMsLoadHandler)handler).getTotal()); + //子表列表总记录数及合计栏 + public R modelSListTotal(@SwBody SwMap params, UserSession us) { + return pageHandler(params, us, TYPE_MODEL_LIST, handler -> ((LCMsLoadHandler)handler).getSTotal()); } } diff --git a/smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/listcard/normal/LCNormalDefine.java b/smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/listcard/normal/LCNormalDefine.java new file mode 100644 index 0000000..82581c9 --- /dev/null +++ b/smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/listcard/normal/LCNormalDefine.java @@ -0,0 +1,12 @@ +package cc.smtweb.system.bpm.web.engine.model.listcard.normal; + +/** + * @Author:lip + * @Date : 2022/9/2 15:23 + */ +public class LCNormalDefine { + //列表里数据集 + public static final String dsList = "list"; + //卡片数据集 + public static final String dsCard = "card"; +} diff --git a/smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/listcard/normal/LCNormalDelHandler.java b/smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/listcard/normal/LCNormalDelHandler.java index 8bf25ad..8c3afbc 100644 --- a/smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/listcard/normal/LCNormalDelHandler.java +++ b/smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/listcard/normal/LCNormalDelHandler.java @@ -1,58 +1,28 @@ package cc.smtweb.system.bpm.web.engine.model.listcard.normal; -import cc.smtweb.framework.core.cache.AbstractCache; -import cc.smtweb.framework.core.cache.CacheManager; import cc.smtweb.framework.core.common.R; -import cc.smtweb.framework.core.db.DbEngine; -import cc.smtweb.framework.core.db.EntityDao; -import cc.smtweb.framework.core.db.cache.ModelTableCache; -import cc.smtweb.framework.core.db.jdbc.AbsDbWorker; -import cc.smtweb.framework.core.db.vo.ModelTable; -import cc.smtweb.framework.core.exception.BizException; -import cc.smtweb.system.bpm.web.design.form.define.PageDataset; -import cc.smtweb.system.bpm.web.engine.model.listcard.single.LCSingleDelHandler; -import org.springframework.util.Assert; +import cc.smtweb.system.bpm.web.engine.model.listcard.abshandler.AbsDelHandler; /** * Created by Akmm at 2022/4/21 17:53 * 删除操作 */ -public class LCNormalDelHandler extends LCSingleDelHandler { +public class LCNormalDelHandler extends AbsDelHandler { /** - * 删除指定数据集,入参{pageId, dataset, id} - * + * 通过列表删除 * @return */ - public R del() { - long id = params.readLong("id"); - if (id == 0L) throw new BizException("没有收到待删除记录Id(" + id + ")!"); - //数据集 - String dataSet = params.readString("dataset"); - PageDataset delDataSet = this.datasets.findByName(dataSet); - Assert.notNull(delDataSet, "未获取到数据集:" + dataSet); - // - checkBean(delDataSet, id); - // - DbEngine.getInstance().doTrans(new AbsDbWorker() { - @Override - public void work() { - ModelTable table = ModelTableCache.getInstance().get(delDataSet.masterTable); - if (table == null) throw new BizException("没有找到指定的的表定义:" + delDataSet.name + "!"); - EntityDao dao = DbEngine.getInstance().findDao(table.getName()); - dao.deleteEntity(id); - localDel(id, table); - } + public R listDel(){ + doDel(LCNormalDefine.dsList); + return R.success(); + } - @Override - public void doAfterDbCommit() { - ModelTable table = ModelTableCache.getInstance().get(delDataSet.masterTable); - if (table.isNeedCache()) { - AbstractCache cache = CacheManager.getIntance().getCache(table.getName()); - cache.remove(id); - } - afterCommit(id, table); - } - }); + /** + * 通过卡片删除 + * @return + */ + public R cardDel(){ + doDel(LCNormalDefine.dsCard); return R.success(); } } diff --git a/smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/listcard/normal/LCNormalLoadHandler.java b/smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/listcard/normal/LCNormalLoadHandler.java index c685b27..a70d868 100644 --- a/smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/listcard/normal/LCNormalLoadHandler.java +++ b/smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/listcard/normal/LCNormalLoadHandler.java @@ -2,54 +2,25 @@ package cc.smtweb.system.bpm.web.engine.model.listcard.normal; import cc.smtweb.framework.core.common.R; import cc.smtweb.framework.core.common.SwMap; -import cc.smtweb.system.bpm.web.design.form.define.PageDataset; -import cc.smtweb.system.bpm.web.engine.dynPage.AbstractDynPageHandler; -import cc.smtweb.system.bpm.web.engine.dynPage.DynPageHelper; -import cc.smtweb.system.bpm.web.engine.dynPage.DynPageListHandler; import cc.smtweb.system.bpm.web.engine.dynPage.DynRetBean; -import cc.smtweb.system.bpm.web.engine.model.listcard.single.LCSingleHelper; -import org.springframework.util.Assert; +import cc.smtweb.system.bpm.web.engine.model.listcard.ModelUtils; +import cc.smtweb.system.bpm.web.engine.model.listcard.abshandler.AbsLoadHandler; /** * @Author:lip * @Date : 2022/8/29 14:37 */ -public class LCNormalLoadHandler extends AbstractDynPageHandler { +public class LCNormalLoadHandler extends AbsLoadHandler { //新增卡片操作,初始化定义的数据集 public R add() { - String dataSet = params.readString("dataset"); - PageDataset addDataSet = this.datasets.findByName(dataSet); - Assert.notNull(addDataSet, "未获取到数据集:" + dataSet); - SwMap data; - //懒加载,给个空对象 - if (addDataSet.lazy) { - data = new SwMap(); - } else { - data = DynPageHelper.createBean(addDataSet); - } - - return R.success(LCSingleHelper.buildRetData(addDataSet.name, data)); + SwMap data = doAdd(LCNormalDefine.dsCard); + return R.success(ModelUtils.buildRetData(LCNormalDefine.dsCard, data)); } public R load() { - //过滤条件 - SwMap filter = params.readMap("filter"); - - //对应的数据集定义 - String dataSet = params.readString("dataset"); - PageDataset loadDataSet = this.datasets.findByName(dataSet); - Assert.notNull(loadDataSet, "未获取到数据集:" + dataSet); - - SwMap data = provider.loadData(filter, loadDataSet); - - return R.success(LCSingleHelper.buildRetData(loadDataSet.name, data)); - } - - private DynPageListHandler getListWorker(SwMap filter, PageDataset pageDataSet) { - DynPageListHandler listHandler = new DynPageListHandler(form.getId(), filter, pageDataSet); - listHandler.init(params, us); - return listHandler; + SwMap data = doLoadCard(LCNormalDefine.dsCard); + return R.success(ModelUtils.buildRetData(LCNormalDefine.dsCard, data)); } /** @@ -57,17 +28,8 @@ public class LCNormalLoadHandler extends AbstractDynPageHandler { * @return */ public R list() { - //过滤条件 - SwMap filter = params.readMap("filter"); - - //对应的数据集定义 - String dataSet = params.readString("dataset"); - PageDataset listDataSet = this.datasets.findByName(dataSet); - Assert.notNull(listDataSet, "未获取到数据集:" + dataSet); - - DynRetBean bean = DynRetBean.createList(getListWorker(filter, listDataSet).buildListData()); - - return R.success(bean); + DynRetBean dynRetBean = doList(LCNormalDefine.dsList); + return R.success(dynRetBean); } /** @@ -76,14 +38,6 @@ public class LCNormalLoadHandler extends AbstractDynPageHandler { * @return */ public R getTotal() { - //过滤条件 - SwMap filter = params.readMap("filter"); - - //对应的数据集定义 - String dataSet = params.readString("dataset"); - PageDataset listDataSet = this.datasets.findByName(dataSet); - Assert.notNull(listDataSet, "未获取到数据集:" + dataSet); - - return getListWorker(filter, listDataSet).getTotal(); + return doTotal(LCNormalDefine.dsList); } } diff --git a/smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/listcard/normal/LCNormalSaveHandler.java b/smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/listcard/normal/LCNormalSaveHandler.java new file mode 100644 index 0000000..68c6687 --- /dev/null +++ b/smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/listcard/normal/LCNormalSaveHandler.java @@ -0,0 +1,22 @@ +package cc.smtweb.system.bpm.web.engine.model.listcard.normal; + +import cc.smtweb.framework.core.common.R; +import cc.smtweb.framework.core.db.impl.DefaultEntity; +import cc.smtweb.system.bpm.web.engine.model.listcard.ModelUtils; +import cc.smtweb.system.bpm.web.engine.model.listcard.abshandler.AbsSaveHandler; + +/** + * @Author:lip + * @Date : 2022/9/2 14:56 + */ +public class LCNormalSaveHandler extends AbsSaveHandler { + /** + * + * @return + */ + public R save(){ + DefaultEntity bean = doSave(LCNormalDefine.dsCard); + return R.success(ModelUtils.buildRetData(LCNormalDefine.dsCard,bean.getData())); + } + +} diff --git a/smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/listcard/normal/LCNormalService.java b/smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/listcard/normal/LCNormalService.java index 4fd6403..66e9cd0 100644 --- a/smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/listcard/normal/LCNormalService.java +++ b/smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/listcard/normal/LCNormalService.java @@ -6,14 +6,21 @@ import cc.smtweb.framework.core.common.R; import cc.smtweb.framework.core.common.SwMap; import cc.smtweb.framework.core.mvc.service.AbstractHandler; import cc.smtweb.framework.core.session.UserSession; -import cc.smtweb.system.bpm.web.engine.model.listcard.single.LCSingleService; +import cc.smtweb.system.bpm.web.engine.dynPage.DynPageService; +import cc.smtweb.system.bpm.web.engine.model.listcard.single.LCSingleSaveHandler; /** * @Author:lip * @Date : 2022/8/27 13:54 */ @SwService -public class LCNormalService extends LCSingleService { +public class LCNormalService extends DynPageService { + protected final static String TYPE_MODEL_LIST = "modelList"; + protected final static String TYPE_MODEL_ADD = "modelAdd"; + protected final static String TYPE_MODEL_LOAD = "modelLoad"; + protected final static String TYPE_MODEL_SAVE = "modelSave"; + protected final static String TYPE_MODEL_DEL = "modelDel"; + @Override protected AbstractHandler createHandler(String type) { switch (type) { @@ -21,15 +28,26 @@ public class LCNormalService extends LCSingleService { case TYPE_MODEL_LOAD: case TYPE_MODEL_ADD: return new LCNormalLoadHandler(); + case TYPE_MODEL_SAVE: + return new LCNormalSaveHandler(); case TYPE_MODEL_DEL: return new LCNormalDelHandler(); } return super.createHandler(type); } + //保存 + public R modelSave(@SwBody SwMap params, UserSession us) { + return pageHandler(params, us, TYPE_MODEL_SAVE, handler -> ((LCNormalSaveHandler)handler).save()); + } + + //列表删除 + public R modelLDel(@SwBody SwMap params, UserSession us) { + return pageHandler(params, us, TYPE_MODEL_DEL, handler -> ((LCNormalDelHandler)handler).listDel()); + } - //删除 - public R modelDel(@SwBody SwMap params, UserSession us) { - return pageHandler(params, us, TYPE_MODEL_DEL, handler -> ((LCNormalDelHandler)handler).del()); + //卡片删除 + public R modelCDel(@SwBody SwMap params, UserSession us) { + return pageHandler(params, us, TYPE_MODEL_DEL, handler -> ((LCNormalDelHandler)handler).cardDel()); } //读取 diff --git a/smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/listcard/single/LCSingleSaveHandler.java b/smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/listcard/single/LCSingleSaveHandler.java index 66032c2..3fd70ad 100644 --- a/smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/listcard/single/LCSingleSaveHandler.java +++ b/smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/listcard/single/LCSingleSaveHandler.java @@ -19,11 +19,9 @@ import cc.smtweb.framework.core.util.StringUtil; import cc.smtweb.system.bpm.web.design.form.define.PageDataset; import cc.smtweb.system.bpm.web.design.form.define.PageDatasetFilter; import cc.smtweb.system.bpm.web.engine.dynPage.AbstractDynPageHandler; -import cc.smtweb.system.bpm.web.engine.dynPage.DynRetBean; import org.apache.commons.lang3.StringUtils; import java.util.HashMap; -import java.util.LinkedHashMap; import java.util.List; import java.util.Map; 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 22e2f6f..a4c85a1 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 @@ -70,9 +70,12 @@ "text": true, "link": false, "linkType": "curr", - "nextAction": "", - "fxLink": "", - "fxLink_text": "" + <#if name?has_content && name?ends_with("List")> + "fxLink": "bpm.${name?replace("List","Card")}", + <#else> + "fxLink": "", + + "fxLink_text": "编辑卡片" } }, <#else > diff --git a/smtweb-framework/bpm/src/main/resources/static/template/default/model_card_ms.ftl b/smtweb-framework/bpm/src/main/resources/static/template/default/model_card_ms.ftl index 51bc051..a7e4a8c 100644 --- a/smtweb-framework/bpm/src/main/resources/static/template/default/model_card_ms.ftl +++ b/smtweb-framework/bpm/src/main/resources/static/template/default/model_card_ms.ftl @@ -252,7 +252,6 @@ "leftIcon": "plus", "fxLink": "dialog:cardSubDialog", "fxLink_text": "子表编辑卡片", - "nextAction": "", "preAction": "", "dataset": "${layout.listSub[0].dataset}" }, @@ -314,7 +313,6 @@ "dataset": "${layout.listSub[0].dataset}", "link": true, "linkType": "", - "nextAction": "", "fxLink": "" } }, @@ -525,8 +523,7 @@ "label": "关闭", "leftIcon": "close", "type": "", - "action": "button:closeDialog", - "nextAction": "button:search" + "action": "button:closeDialog" }, "id": "id${newId()}" } @@ -550,4 +547,4 @@ "widgetRef": [${widgetRef}], "vars": [] } -} \ No newline at end of file +} diff --git a/smtweb-framework/bpm/src/main/resources/static/template/default/model_list_list_1.ftl b/smtweb-framework/bpm/src/main/resources/static/template/default/model_list_list_1.ftl index 512c276..7b12425 100644 --- a/smtweb-framework/bpm/src/main/resources/static/template/default/model_list_list_1.ftl +++ b/smtweb-framework/bpm/src/main/resources/static/template/default/model_list_list_1.ftl @@ -213,7 +213,6 @@ "type": "primary", "leftIcon": "delete", "action": "button:delCard", - "nextAction":"button:loadList", "link": true, "text": false, "dataset": "${assist.dataset}", @@ -445,7 +444,6 @@ "type": "danger", "leftIcon": "delete", "action": "button:delCard", - "nextAction":"button:loadList", "link": false, "text": true, "preAction": "" @@ -583,8 +581,7 @@ "label": "关闭", "leftIcon": "close", "type": "", - "action": "button:closeDialog", - "nextAction": "button:loadList" + "action": "button:closeDialog" }, "id": "id${newId()}" } @@ -692,8 +689,7 @@ "label": "关闭", "leftIcon": "close", "type": "", - "action": "button:closeDialog", - "nextAction": "button:loadList" + "action": "button:closeDialog" }, "id": "id${newId()}" } diff --git a/smtweb-framework/bpm/src/main/resources/static/template/default/model_list_list_2.ftl b/smtweb-framework/bpm/src/main/resources/static/template/default/model_list_list_2.ftl index bf4e104..bff22ce 100644 --- a/smtweb-framework/bpm/src/main/resources/static/template/default/model_list_list_2.ftl +++ b/smtweb-framework/bpm/src/main/resources/static/template/default/model_list_list_2.ftl @@ -387,7 +387,6 @@ "type": "danger", "leftIcon": "delete", "action": "button:delCard", - "nextAction":"button:loadList", "link": false, "text": true, "preAction": "" @@ -525,8 +524,7 @@ "label": "关闭", "leftIcon": "close", "type": "", - "action": "button:closeDialog", - "nextAction": "button:loadList" + "action": "button:closeDialog" }, "id": "id${newId()}" } diff --git a/smtweb-framework/bpm/src/main/resources/static/template/default/model_list_normal.ftl b/smtweb-framework/bpm/src/main/resources/static/template/default/model_list_normal.ftl index 2e101f4..4d6f288 100644 --- a/smtweb-framework/bpm/src/main/resources/static/template/default/model_list_normal.ftl +++ b/smtweb-framework/bpm/src/main/resources/static/template/default/model_list_normal.ftl @@ -68,8 +68,12 @@ "action": "button:addCard", "link": false, "linkType": "curr", - "fxLink": "", - "fxLink_text": "" + <#if name?has_content && name?ends_with("List")> + "fxLink": "bpm.${name?replace("List","Card")}", + <#else> + "fxLink": "", + + "fxLink_text": "编辑卡片" }, "id": "id${newId()}", "events": {} diff --git a/smtweb-framework/bpm/src/main/resources/static/template/default/model_tree_list.ftl b/smtweb-framework/bpm/src/main/resources/static/template/default/model_tree_list.ftl index 782bb21..c216970 100644 --- a/smtweb-framework/bpm/src/main/resources/static/template/default/model_tree_list.ftl +++ b/smtweb-framework/bpm/src/main/resources/static/template/default/model_tree_list.ftl @@ -150,8 +150,12 @@ "action": "button:addCard", "link": false, "linkType": "curr", - "fxLink": "", - "fxLink_text": "" + <#if name?has_content && name?ends_with("List")> + "fxLink": "bpm.${name?replace("List","Card")}", + <#else> + "fxLink": "", + + "fxLink_text": "编辑卡片" }, "id": "id${newId()}", "events": {}