//凭证列表插件,给报错信息添加凭证类型
public class VoucherListErrorPlugin extends AbstractListPlugin {
@Override
public void afterDoOperation(AfterDoOperationEventArgs event) {
super.afterDoOperation(event);
OperationResult operationResult = event.getOperationResult();
//获取操作结果是否有校验信息
if (operationResult != null) {
String message = operationResult.getMessage();
//判断是否有错误信息,有错误信息进入错误信息修改
if (message != null) {
ListSelectedRowCollection selectedRows = getSelectedRows();
List<IOperateInfo> allErrorOrValidateInfo = operationResult.getAllErrorOrValidateInfo();
int minSize = Math.min(selectedRows.size(), allErrorOrValidateInfo.size());
for (int i = 0; i < minSize; i++) {
ListSelectedRow listSelectedRow = selectedRows.get(i);
QFilter f1 = new QFilter("billno", "=", listSelectedRow.getBillNo());
DynamicObject bos_user = BusinessDataServiceHelper.loadSingle("gl_voucher", "voucherType", new QFilter[]{f1});//凭证
DynamicObject voucherType = bos_user.getDynamicObject("vouchertype");//凭证类型
String voucherTypeName = voucherType.getString("name");//凭证类型名称
//修改报错信息内容
OperateErrorInfo iOperateInfo = (OperateErrorInfo) allErrorOrValidateInfo.get(i);
IOperateInfo iOperateInfo1 = allErrorOrValidateInfo.get(i);
String message1 = iOperateInfo1.getMessage();
iOperateInfo.setMessage("凭证类型: " + voucherTypeName + " ; " + message1);
}
}
}
}
}
推荐阅读