解答:
多类别基础资料取值,赋值
1、表单页面,点击客商录入,弹出表单,输入信息,返回数据赋值到父页面的多类别基础资料类型和多类别基础资料
2、列表页面,点击按钮输入客商,填写表单数据,更新列表数据
3、部分代码
PurchaseListPlugin
@Override
public void closedCallBack(ClosedCallBackEvent closedCallBackEvent) {
// TODO Auto-generated method stub
super.closedCallBack(closedCallBackEvent);
if (StringUtils.equals(closedCallBackEvent.getActionId(), "itemdata_callback")
&& closedCallBackEvent.getReturnData() != null) {
HashMap<String, String> returnDate =(HashMap<String, String>) closedCallBackEvent.getReturnData();
String type = returnDate.get("basedata_type");
String pk = returnDate.get("basedata_pk");
BillList billList = this.getView().getControl("billlistap");
ListSelectedRowCollection selectedRows = billList.getSelectedRows();
Object id = selectedRows.get(0).getPrimaryKeyValue();
DynamicObject obj = BusinessDataServiceHelper.loadSingle(id, "kdec_pur_apply");
//多类别基础资料类型
obj.set("kdec_itemclasstypefield", type);
//多类别基础资料
obj.set("kdec_itemclassfield", pk);
//单据体
DynamicObject obj = BusinessDataServiceHelper.loadSingle(id, "kdec_pur_apply");
DynamicObjectCollection col = obj.getDynamicObjectCollection("单据体标识");
col.addNew();
int len= col.size();
DynamicObject object = col.get(len - 1);
object.set("kdec_itemclasstypefield",type);
object.set("kdec_itemclassfield", pk);
col.set(len-1, object);
obj.set("单据体标识", col);
Object[] o = SaveServiceHelper.save(new DynamicObject[] {obj});
//如果用SaveServiceHelper.saveOperate,将pk换成BusinessDataServiceHelper.loadSingle(pk, type);
if(o!=null&&o.length>0) {
billList.refresh();
}
}
}
PurchaseFormPlugin
@Override
public void closedCallBack(ClosedCallBackEvent closedCallBackEvent) {
// TODO Auto-generated method stub
super.closedCallBack(closedCallBackEvent);
if (StringUtils.equals(closedCallBackEvent.getActionId(), "itemdata_callback")
&& closedCallBackEvent.getReturnData() != null) {
HashMap<String, String> returnDate =(HashMap<String, String>) closedCallBackEvent.getReturnData();
String type = returnDate.get("basedata_type");
String pk = returnDate.get("basedata_pk");
//类型
this.getModel().setValue("kdec_itemclasstypefield", type);
this.getModel().setValue("kdec_itemclassfield", pk);
}
}
ItemClassControlFormPlugin
@Override
public void click(EventObject evt) {
// TODO Auto-generated method stub
super.click(evt);
Control con = (Control) evt.getSource();
if(StringUtils.equals(con.getKey(),"kdec_buttonap")) {
String type = (String) this.getModel().getValue("kdec_itemclasstypefield");
DynamicObject obj = (DynamicObject) this.getModel().getValue("kdec_itemclassfield");
HashMap<String, String> returnDate = new HashMap<>();
returnDate.put("basedata_type", type);
if(obj!=null) {
returnDate.put("basedata_pk", obj.getString("id"));
}
this.getView().returnDataToParent(returnDate);
this.getView().close();
}
}
更多资料在附件下载
itemclass.rar(2.56KB)
推荐阅读