解决:
介绍单据列表单头显示属性的使用
实现单据列表过滤分录数据
展示其他表单数据等
1、通过空白创建动态表单,在动态表单加个单据体,添加字段与采购申请单分录字段对应
2、在动态表单,注册插件初始化数据,插件如下
import java.util.EventObject;
import kd.bos.dataentity.entity.DynamicObject;
import kd.bos.dataentity.entity.DynamicObjectCollection;
import kd.bos.entity.datamodel.AbstractFormDataModel;
import kd.bos.entity.datamodel.TableValueSetter;
import kd.bos.form.plugin.AbstractFormPlugin;
import kd.bos.mvc.form.FormView;
import kd.bos.orm.query.QCP;
import kd.bos.orm.query.QFilter;
import kd.bos.servicehelper.QueryServiceHelper;
public class TestFormPlugin extends AbstractFormPlugin {
@Override
public void beforeBindData(EventObject e) {
// 这里
FormView fv = (FormView) this.getView();
Object pk = fv.getFormShowParameter().getCustomParam("pkId");
QFilter filter = new QFilter("id", QCP.equals, pk);
// 根据某字段过滤分录数据
filter.and(new QFilter("kdec_entryentity.kdec_amountfield", QCP.large_equals, 100));
DynamicObjectCollection obj2 = QueryServiceHelper.query("kdec_pur_apply",
"id,kdec_entryentity,kdec_entryentity.kdec_materielfield,kdec_entryentity.kdec_unitfield,"
+ "kdec_entryentity.kdec_qtyfield,kdec_entryentity.kdec_pricefield,kdec_entryentity.kdec_amountfield",
new QFilter[] { filter });
// 实体的单据体标识
if (obj2 != null&&obj2.size()>0) {
AbstractFormDataModel model = (AbstractFormDataModel) this.getModel();
model.beginInit();
TableValueSetter vs = new TableValueSetter();
vs.addField("kdec_materielfield");
vs.addField("kdec_unitfield");
vs.addField("kdec_qtyfield");
vs.addField("kdec_pricefield");
vs.addField("kdec_amountfield");
for (DynamicObject dynamicObject : obj2) {
vs.addRow(dynamicObject.get("kdec_entryentity.kdec_materielfield"),
dynamicObject.get("kdec_entryentity.kdec_unitfield"), dynamicObject.get("kdec_entryentity.kdec_qtyfield"),
dynamicObject.get("kdec_entryentity.kdec_pricefield"), dynamicObject.get("kdec_entryentity.kdec_amountfield"));
}
// 动态表单单据体的标识
model.batchCreateNewEntryRow("kdec_entryentity", vs);
model.endInit();
// }
}
}
}
3、采购申请单列表配置
4、效果
不用动态表单,开启单头显示的效果
5、BusinessDataServiceHelper.loadSingle与QueryServiceHelper.queryOne的一些区别
(1)loadSingle取出数据是有结构化的
(2)queryOne取出的数据是平铺的
(3)loadSingle取出数据可以再保存,queryOne不可以
(4)queryOne取分录数据时,只能取到第一条分录的数据,支持根据分录字段QFilter
推荐阅读