金蝶云苍穹套打插件的简单使用
原创约 813 字大约 3 分钟...
59-金蝶云苍穹套打插件的简单使用.md
注意
本博文仅供学术研究和交流参考,严禁将其用于商业用途。如因违规使用产生的任何法律问题,使用者需自行负责。
前置条件
必须完成采购申请单
必须完成采购申请单打印模板
编码
beforeloadData事件
- 编码
package kd.bos.wlplugin;
import kd.bos.entity.plugin.AbstractPrintServicePlugin;
import kd.bos.entity.plugin.args.BeforeLoadDataArgs;
import kd.bos.entity.plugin.args.CustomPrintDataEntitiesArgs;
import kd.bos.entity.plugin.args.OutputElementArgs;
/**
* <p>Title: </p>
* <p>
* Description:
* </p>
* <p>Copyright: Copyright (c) 2020</p>
* @author xx
* @date 2020年3月4日
* @version 1.0
*/
public class PrintPluginDemo extends AbstractPrintServicePlugin {
/**
* <p>Title: </p>
* <p>
* Description:
* 系统读取数据前执行的事件
* </p>
* <p>Copyright: Copyright (c) 2020</p>
* @author xx
* @date 2020年3月4日
* @param param the bare_field_name
* @param e
* @see kd.bos.entity.plugin.IPrintServicePlugin#beforeLoadData(kd.bos.entity.plugin.args.BeforeLoadDataArgs)
* @version 1.0
*/
@Override
public void beforeLoadData(BeforeLoadDataArgs e) {
//加载数据前执行的事情,可以取消系统读取数据
//取消默认读取分录数据的动作
String source = e.getDataSourceName();
if("entryentity".equalsIgnoreCase(source)) {//采购申请单分录标识
e.setCancel(true);
}
}
}
注册插件保后重启服务
测试
未开启插件运行效果

开启插件运行效果

customPrintDataEntities和beforeOuputElement事件
- 添加文本,并进行如下图所示操作

- 编码
/**
* <p>Title: </p>
* <p>
* Description:
* 对系统读取的数据集进行加工或自定义数据包
* </p>
* <p>Copyright: Copyright (c) 2020</p>
* @author xx
* @date 2020年3月4日
* @param param the bare_field_name
* @param e
* @see kd.bos.entity.plugin.IPrintServicePlugin#customPrintDataEntities(kd.bos.entity.plugin.args.CustomPrintDataEntitiesArgs)
* @version 1.0
*/
@Override
public void customPrintDataEntities(CustomPrintDataEntitiesArgs e) {
// 对系统读取的数据集进行加工或自定义数据包
//打印表单上不存在的字段
List<DynamicObject> sysDataEntities = e.getDataEntities();
List<DynamicObject> newDataEntities = new ArrayList<>();
Set<String> customFields = e.getCustomFields();
String ds = e.getDataSourceName();
if("wlzy_apply".equalsIgnoreCase(ds)){
for(DynamicObject dataEntity : sysDataEntities) {
DynamicObject dataEntityType = (DynamicObject) dataEntity.getDataEntityType();
DynamicObject cloneType = null;
try {
cloneType = (DynamicObject) dataEntityType.clone();
for(String customField : customFields) {
DynamicSimpleProperty demoProp = new DynamicSimpleProperty(customField,String.class,"自定义字段默认值");
cloneType.registerSimpleProperty(demoProp);
}
DynamicObject person = dataEntity.getDynamicObject("applier");
DynamicObject newObj = (new CloneUtils(false,false)).clone(cloneType,dataEntity);
for(String customField : customFields) {
newObj.set(customField, "自定义字段value");
}
newObj.set("applier", person);
newObj.set("billno","newBillno");
newDataEntities.add(newObj);
} catch (Exception e1) {
System.out.println("demo fail");
}
}
e.setDataEntities(newDataEntities);
}
}
/**
* <p>Title: </p>
* <p>
* Description:
* 控件输出前事件
* </p>
* <p>Copyright: Copyright (c) 2020</p>
* @author xx
* @date 2020年3月4日
* @param param the bare_field_name
* @param e
* @see kd.bos.entity.plugin.IPrintServicePlugin#beforeOuputElement(kd.bos.entity.plugin.args.OutputElementArgs)
* @version 1.0
*/
@Override
public void beforeOuputElement(OutputElementArgs e) {
//设置自定义控件不打印
String key = e.getKey();
if("text1".equals(key)) {
e.getOutput().setHide(true);
}
}
备注: 第一个方法的clone报错,未找到原因,暂时跳过
注册插件保后重启服务
测试
afterOutputElement事件
- 添加文本,并进行如下图所示设置

- 编码
/**
* <p>Title: </p>
* <p>
* Description:
* 控件输出后事件
* </p>
* <p>Copyright: Copyright (c) 2020</p>
* @author xx
* @date 2020年3月4日
* @param param the bare_field_name
* @param e
* @see kd.bos.entity.plugin.IPrintServicePlugin#afterOutputElement(kd.bos.entity.plugin.args.OutputElementArgs)
* @version 1.0
*/
@Override
public void afterOutputElement(OutputElementArgs e) {
super.afterOutputElement(e);
//根据控件绑定的字段的值的不同、打印不同的样式
String key = e.getKey();
if("text2".equalsIgnoreCase(key)) {
IPrintScriptable apw = e.getOutput();
int pagenumber = apw.getPageNumber();
apw.setValue(pagenumber);
}
}
- 测试
分割线
相关信息
以上就是我关于 金蝶云苍穹套打插件的简单使用 知识点的整理与总结的全部内容,希望对你有帮助。。。。。。
Powered by Waline v2.15.4