@@ -1,88 +1,11 @@ | |||||
package cc.smtweb.system.bpm.web.engine.model.listcard.mastersub; | package cc.smtweb.system.bpm.web.engine.model.listcard.mastersub; | ||||
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.normal.LCNormalLoadHandler; | |||||
/** | /** | ||||
* @Author:lip | * @Author:lip | ||||
* @Date : 2022/8/28 21:44 | * @Date : 2022/8/28 21:44 | ||||
*/ | */ | ||||
public class LCMsLoadHandler extends AbstractDynPageHandler { | |||||
//新增卡片操作,初始化定义的数据集 | |||||
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); | |||||
} | |||||
public class LCMsLoadHandler extends LCNormalLoadHandler { | |||||
return R.success(LCSingleHelper.buildRetData(addDataSet.name, 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; | |||||
} | |||||
/** | |||||
* 列表数据 | |||||
* @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); | |||||
} | |||||
/** | |||||
* 计算分页数据 | |||||
* | |||||
* @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(); | |||||
} | |||||
} | } |
@@ -0,0 +1,89 @@ | |||||
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; | |||||
/** | |||||
* @Author:lip | |||||
* @Date : 2022/8/29 14:37 | |||||
*/ | |||||
public class LCNormalLoadHandler extends AbstractDynPageHandler { | |||||
//新增卡片操作,初始化定义的数据集 | |||||
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)); | |||||
} | |||||
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; | |||||
} | |||||
/** | |||||
* 列表数据 | |||||
* @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); | |||||
} | |||||
/** | |||||
* 计算分页数据 | |||||
* | |||||
* @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(); | |||||
} | |||||
} |
@@ -14,11 +14,15 @@ import cc.smtweb.system.bpm.web.engine.model.listcard.single.LCSingleService; | |||||
*/ | */ | ||||
@SwService | @SwService | ||||
public class LCNormalService extends LCSingleService { | public class LCNormalService extends LCSingleService { | ||||
@Override | @Override | ||||
protected AbstractHandler createHandler(String type) { | protected AbstractHandler createHandler(String type) { | ||||
if (type.equals(TYPE_MODEL_DEL)){ | |||||
return new LCNormalDelHandler(); | |||||
switch (type) { | |||||
case TYPE_MODEL_LIST: | |||||
case TYPE_MODEL_LOAD: | |||||
case TYPE_MODEL_ADD: | |||||
return new LCNormalLoadHandler(); | |||||
case TYPE_MODEL_DEL: | |||||
return new LCNormalDelHandler(); | |||||
} | } | ||||
return super.createHandler(type); | return super.createHandler(type); | ||||
} | } | ||||
@@ -27,4 +31,24 @@ public class LCNormalService extends LCSingleService { | |||||
public R modelDel(@SwBody SwMap params, UserSession us) { | public R modelDel(@SwBody SwMap params, UserSession us) { | ||||
return pageHandler(params, us, TYPE_MODEL_DEL, handler -> ((LCNormalDelHandler)handler).del()); | return pageHandler(params, us, TYPE_MODEL_DEL, handler -> ((LCNormalDelHandler)handler).del()); | ||||
} | } | ||||
//读取 | |||||
public R modelLoad(@SwBody SwMap params, UserSession us) { | |||||
return pageHandler(params, us, TYPE_MODEL_LOAD, handler -> ((LCNormalLoadHandler)handler).load()); | |||||
} | |||||
//读取 | |||||
public R modelAdd(@SwBody SwMap params, UserSession us) { | |||||
return pageHandler(params, us, TYPE_MODEL_ADD, handler -> ((LCNormalLoadHandler)handler).add()); | |||||
} | |||||
//列表数据 | |||||
public R modelList(@SwBody SwMap params, UserSession us) { | |||||
return pageHandler(params, us, TYPE_MODEL_LIST, handler -> ((LCNormalLoadHandler)handler).list()); | |||||
} | |||||
//列表总记录数及合计栏 | |||||
public R modelListTotal(@SwBody SwMap params, UserSession us) { | |||||
return pageHandler(params, us, TYPE_MODEL_LIST, handler -> ((LCNormalLoadHandler)handler).getTotal()); | |||||
} | |||||
} | } |
@@ -73,7 +73,7 @@ | |||||
"props": { | "props": { | ||||
"label": "返回", | "label": "返回", | ||||
"leftIcon": "return", | "leftIcon": "return", | ||||
"action": "button:return" | |||||
"action": "button:backList" | |||||
}, | }, | ||||
"id": "${newId()}", | "id": "${newId()}", | ||||
"events": {} | "events": {} | ||||
@@ -64,7 +64,7 @@ | |||||
"props": { | "props": { | ||||
"label": "返回", | "label": "返回", | ||||
"leftIcon": "return", | "leftIcon": "return", | ||||
"action": "button:return" | |||||
"action": "button:backList" | |||||
}, | }, | ||||
"id": "${newId()}", | "id": "${newId()}", | ||||
"events": {} | "events": {} | ||||