单据类型初始化通用插件

This commit is contained in:
zengweihai 2024-05-27 18:08:14 +08:00
parent b3f3ffd6f3
commit a64fa20e49
1 changed files with 56 additions and 0 deletions

View File

@ -0,0 +1,56 @@
package shkd.fi.er.plugin.formplugin;
import kd.bos.bill.AbstractBillPlugIn;
import kd.bos.dataentity.entity.DynamicObject;
import kd.bos.form.FormShowParameter;
import kd.bos.orm.query.QFilter;
import kd.bos.servicehelper.BusinessDataServiceHelper;
import kd.sdk.plugin.Plugin;
import java.util.EventObject;
import java.util.Map;
/**
* 表单插件公共方法<br>
* 1.获取菜单参数配置的单据类型编码菜单参数:<br>
* key=billType,value=单据类型编码 <br>
* key=filedMark,value=单据类型字段标识 <br>
* 2.将单据类型编码转换为编辑界面单据类型字段的值
*/
public class CommonFormPlugin extends AbstractBillPlugIn implements Plugin {
/**
* 初始化时从获取参数类型设置单据类型值
* @param e
*/
@Override
public void afterCreateNewData(EventObject e) {
super.afterCreateNewData(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);
}
}
}
}
}
}