单据转换的配置参考https://vip.kingdee.com/article/50883994132676097
三种方法如下
1、单据转换插件
(1)代码
import java.util.List;
import kd.bos.entity.botp.plugin.AbstractConvertPlugIn;
import kd.bos.entity.botp.plugin.args.BeforeBuildRowConditionEventArgs;
import kd.bos.entity.datamodel.ListSelectedRow;
import kd.bos.orm.query.QCP;
import kd.bos.orm.query.QFilter;
import kd.bos.servicehelper.botp.BFTrackerServiceHelper;
public class BeforeBuildRowConditionSample extends AbstractConvertPlugIn {
@Override
public void beforeBuildRowCondition(BeforeBuildRowConditionEventArgs e) {
String entityNumber = this.getSrcMainType().getName();
List<ListSelectedRow> rows = e.getSelectedRows();
boolean flag = false;
for (ListSelectedRow row : rows) {
Long billId = (Long) row.getPrimaryKeyValue();
flag= BFTrackerServiceHelper.isPush(entityNumber, billId);
if(flag) {
break;
}
}
if (flag){
e.setCustFilterDesc("已经存在下游单据,不允许再下推单据"); // 给出不允许下推的原因
// 设置条件表达式,用于脚本执行 (必选)
e.setCustFilterExpression(" 1 != 1 ");
// 同时设置具有相同含义的QFilter条件,用于选单数据查询 (必选)
QFilter qFilter = new QFilter("1", QCP.not_equals, "1");
e.getCustQFilters().add(qFilter);
}
}
}
(2)注册
(3)效果图
2、表单插件
(1)代码
import java.util.EventObject;
import com.kingdee.bos.ctrl.common.util.StringUtil;
import kd.bos.dataentity.entity.DynamicObject;
import kd.bos.dataentity.entity.DynamicObjectCollection;
import kd.bos.entity.datamodel.ListSelectedRow;
import kd.bos.entity.datamodel.ListSelectedRowCollection;
import kd.bos.form.control.events.ItemClickEvent;
import kd.bos.form.events.BeforeDoOperationEventArgs;
import kd.bos.form.operate.FormOperate;
import kd.bos.list.BillList;
import kd.bos.list.ListShowParameter;
import kd.bos.list.plugin.AbstractListPlugin;
import kd.bos.orm.query.QFilter;
import kd.bos.servicehelper.BusinessDataServiceHelper;
import kd.bos.servicehelper.botp.BFTrackerServiceHelper;
public class TestListDemoPlugin extends AbstractListPlugin {
@Override
public void beforeDoOperation(BeforeDoOperationEventArgs e) {
FormOperate formOperate = (FormOperate) e.getSource();
String key = formOperate.getOperateKey();
if(key.equalsIgnoreCase("push")) {
ListSelectedRowCollection col = e.getListSelectedData();
ListShowParameter showParameter = (ListShowParameter) this.getView().getFormShowParameter();
String entityNumber =showParameter.getBillFormId();
for (ListSelectedRow row : col) {
Long billId = (Long) row.getPrimaryKeyValue();
boolean flag= BFTrackerServiceHelper.isPush(entityNumber, billId);
if(flag) {
this.getView().showTipNotification("已经存在下游单据,不允许再下推单据");
e.setCancel(true);
break;
}
}
}
}
(2)注册
(3)效果图
3、加字段配置
(1)在上游采购申请单添加字段
(2)单据转换数据规则配置
(3)反写配置
(4)效果
推荐阅读