多类别基础资料的简单使用原创
金蝶云社区-闫方亮
闫方亮
5人赞赏了该文章 4,598次浏览 未经作者许可,禁止转载编辑于2021年03月22日 14:36:37


解答:

    多类别基础资料取值,赋值


1、表单页面,点击客商录入,弹出表单,输入信息,返回数据赋值到父页面的多类别基础资料类型和多类别基础资料

image.png

2、列表页面,点击按钮输入客商,填写表单数据,更新列表数据

image.png

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();
  }
 }

更多资料在附件下载


图标赞 5
5人点赞
还没有人点赞,快来当第一个点赞的人吧!
图标打赏
0人打赏
还没有人打赏,快来当第一个打赏的人吧!