插件开发
This commit is contained in:
parent
550844c1d2
commit
57e246fcbf
|
@ -0,0 +1,61 @@
|
||||||
|
package zcgj.zcdev.zcdev.pr.plugin.form;
|
||||||
|
|
||||||
|
import kd.bos.dataentity.entity.DynamicObject;
|
||||||
|
import kd.bos.form.FormShowParameter;
|
||||||
|
import kd.bos.form.plugin.AbstractFormPlugin;
|
||||||
|
import kd.bos.logging.Log;
|
||||||
|
import kd.bos.logging.LogFactory;
|
||||||
|
import kd.bos.orm.query.QFilter;
|
||||||
|
import kd.bos.servicehelper.BusinessDataServiceHelper;
|
||||||
|
|
||||||
|
import java.util.EventObject;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 表单插件公共方法<br>
|
||||||
|
* 1.获取菜单参数配置的单据类型编码,菜单参数:<br>
|
||||||
|
* key=billType,value=单据类型编码 <br>
|
||||||
|
* key=filedMark,value=单据类型字段标识 <br>
|
||||||
|
* 2.将单据类型编码转换为编辑界面单据类型字段的值
|
||||||
|
*/
|
||||||
|
public class CommonFormPlugin extends AbstractFormPlugin {
|
||||||
|
private final static Log logger = LogFactory.getLog(CommonFormPlugin.class);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 初始化时,从获取参数类型,设置单据类型值
|
||||||
|
* @param e
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void afterCreateNewData(EventObject e) {
|
||||||
|
FormShowParameter formShowParameter = this.getView().getFormShowParameter();
|
||||||
|
if(null!=formShowParameter){
|
||||||
|
Map<String, Object> customParams = formShowParameter.getCustomParams();
|
||||||
|
if(null!=customParams){
|
||||||
|
//获取列表界面配置的参数:billType=单据类型编码
|
||||||
|
Object billType = customParams.get("billType");
|
||||||
|
//获取列表界面配置的参数:filedMark=单据类型字段标识
|
||||||
|
Object filedMark = customParams.get("filedMark");
|
||||||
|
if(null!=billType&&null!=filedMark){
|
||||||
|
DynamicObject billTypeObj = (DynamicObject)this.getModel().getValue(filedMark.toString());
|
||||||
|
if(null==billTypeObj){
|
||||||
|
//单据类型为空,赋值
|
||||||
|
QFilter q1 = new QFilter("number", "=", billType.toString());
|
||||||
|
DynamicObject billTypeObject = BusinessDataServiceHelper.loadSingle("bos_billtype", new QFilter[]{q1});
|
||||||
|
this.getModel().setValue(filedMark.toString(), billTypeObject);
|
||||||
|
}else if(!billTypeObj.getString("number").equals(billType.toString())){
|
||||||
|
//单据类型和列表菜单参数一致,不再赋值
|
||||||
|
QFilter q1 = new QFilter("number", "=", billType.toString());
|
||||||
|
DynamicObject billTypeObject = BusinessDataServiceHelper.loadSingle("bos_billtype", new QFilter[]{q1});
|
||||||
|
this.getModel().setValue(filedMark.toString(), billTypeObject);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
super.afterCreateNewData(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,32 @@
|
||||||
|
package zcgj.zcdev.zcdev.pr.plugin.form;
|
||||||
|
|
||||||
|
import kd.bos.form.FormShowParameter;
|
||||||
|
import kd.bos.list.events.BeforeShowBillFormEvent;
|
||||||
|
import kd.bos.list.plugin.AbstractListPlugin;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
public class CommonListPlugin extends AbstractListPlugin {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void beforeShowBill(BeforeShowBillFormEvent e) {
|
||||||
|
FormShowParameter formShowParameter = this.getView().getFormShowParameter();
|
||||||
|
if(null!=formShowParameter){
|
||||||
|
Map<String, Object> customParams =formShowParameter.getCustomParams();
|
||||||
|
if(null!=customParams){
|
||||||
|
Object billtype = customParams.get("billType");
|
||||||
|
Object filedMark = customParams.get("filedMark");
|
||||||
|
if(null!=billtype&&null!=filedMark){
|
||||||
|
customParams.putAll(e.getParameter().getCustomParams());
|
||||||
|
customParams.put("billtype",billtype.toString());
|
||||||
|
customParams.put("filedMark",filedMark.toString());
|
||||||
|
customParams.put("formId","zcgj_zckstopublicbill");
|
||||||
|
e.getParameter().setCustomParams(customParams);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
super.beforeShowBill(e);
|
||||||
|
}
|
||||||
|
}
|
|
@ -2,6 +2,7 @@ package zcgj.zcdev.zcdev.pr.plugin.form;
|
||||||
|
|
||||||
import kd.bos.bill.AbstractBillPlugIn;
|
import kd.bos.bill.AbstractBillPlugIn;
|
||||||
import kd.bos.dataentity.entity.DynamicObject;
|
import kd.bos.dataentity.entity.DynamicObject;
|
||||||
|
import kd.bos.dataentity.entity.DynamicObjectCollection;
|
||||||
import kd.bos.form.field.BasedataEdit;
|
import kd.bos.form.field.BasedataEdit;
|
||||||
import kd.bos.form.field.events.BeforeF7SelectEvent;
|
import kd.bos.form.field.events.BeforeF7SelectEvent;
|
||||||
import kd.bos.form.field.events.BeforeF7SelectListener;
|
import kd.bos.form.field.events.BeforeF7SelectListener;
|
||||||
|
@ -36,8 +37,32 @@ public class RecAndPayInitPlugin extends AbstractBillPlugIn implements Plugin, B
|
||||||
if(name.equals("zcgj_in_contract") || name.equals("zcgj_out_contract")){
|
if(name.equals("zcgj_in_contract") || name.equals("zcgj_out_contract")){
|
||||||
DynamicObject project = (DynamicObject)this.getModel().getValue("zcgj_project");
|
DynamicObject project = (DynamicObject)this.getModel().getValue("zcgj_project");
|
||||||
List<QFilter> qFilterList = new ArrayList<QFilter>();
|
List<QFilter> qFilterList = new ArrayList<QFilter>();
|
||||||
qFilterList.add(new QFilter("project", QCP.equals,project.getLong("id")));
|
if(project == null){
|
||||||
arg0.setCustomQFilters(qFilterList);
|
this.getView().showErrorNotification("请选择项目!");
|
||||||
|
arg0.setCancel(true);
|
||||||
|
}else{
|
||||||
|
qFilterList.add(new QFilter("project", QCP.equals,project.getLong("id")));
|
||||||
|
String entryKey = "zcgj_payable";
|
||||||
|
String contractKey = "zcgj_out_contract";
|
||||||
|
if(name.equals("zcgj_in_contract")){
|
||||||
|
entryKey="zcgj_receivable";
|
||||||
|
contractKey="zcgj_in_contract";
|
||||||
|
}
|
||||||
|
DynamicObjectCollection dynamicObjectCollection = this.getModel().getDataEntity(true).getDynamicObjectCollection(entryKey);
|
||||||
|
if(dynamicObjectCollection != null){
|
||||||
|
List<Long> ids = new ArrayList<>();
|
||||||
|
for (DynamicObject dynamicObject : dynamicObjectCollection) {
|
||||||
|
DynamicObject contract = dynamicObject.getDynamicObject(contractKey);
|
||||||
|
if(contract != null){
|
||||||
|
long inContractId = contract.getLong("id");
|
||||||
|
ids.add(inContractId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
qFilterList.add(new QFilter("id", QCP.not_in,ids));
|
||||||
|
}
|
||||||
|
|
||||||
|
arg0.setCustomQFilters(qFilterList);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue