package tqq9.lc123.cloud.app.plugin.form.conm; import com.alibaba.fastjson.JSONObject; import kd.bos.bill.AbstractBillPlugIn; import kd.bos.dataentity.entity.DynamicObject; import kd.bos.dataentity.entity.DynamicObjectCollection; import kd.bos.dataentity.utils.StringUtils; import kd.bos.entity.param.CustomParam; import kd.bos.form.FormShowParameter; import kd.bos.form.control.events.ItemClickEvent; import kd.bos.logging.Log; import kd.bos.logging.LogFactory; import kd.bos.orm.query.QCP; import kd.bos.orm.query.QFilter; import kd.bos.servicehelper.BusinessDataServiceHelper; import kd.sdk.plugin.Plugin; import java.util.EventObject; import java.util.HashMap; import java.util.Map; /** * 返利规则表单插件 * 同步采购合同信息 */ public class RebateRulesBillPlugin extends AbstractBillPlugIn implements Plugin { private final static Log logger = LogFactory.getLog(RebateRulesBillPlugin.class); @Override public void registerListener(EventObject e) { super.registerListener(e); this.addItemClickListeners("tbmain"); } @Override public void afterCreateNewData(EventObject e) { // 获取当前页面的FormShowParameter对象 FormShowParameter formShowParameter = this.getView().getFormShowParameter(); // 获取自定义参数 String billno = (String) formShowParameter.getCustomParam("purcontract_billno"); JSONObject purcontract_supplier = formShowParameter.getCustomParam("purcontract_supplier"); JSONObject purcontract_tqq9_dxpp = formShowParameter.getCustomParam("purcontract_tqq9_dxpp"); DynamicObject supplier = null; DynamicObject tqq9_dxpp = null; if (purcontract_supplier != null) { String number = purcontract_supplier.get("number").toString(); supplier = BusinessDataServiceHelper.loadSingle("bd_supplier", new QFilter[]{new QFilter("number", QCP.equals, number)}); } if (purcontract_tqq9_dxpp != null) { String number = purcontract_tqq9_dxpp.get("number").toString(); tqq9_dxpp = BusinessDataServiceHelper.loadSingle("tqq9_brand", new QFilter[]{new QFilter("number", QCP.equals, number)}); } // 把参数值赋值到页面文本字段上 DynamicObject purcontract = BusinessDataServiceHelper.loadSingle("conm_purcontract", new QFilter[]{new QFilter("billno", QCP.equals, billno)}); DynamicObjectCollection tqq9_supplier = this.getModel().getDataEntity().getDynamicObjectCollection("tqq9_supplier"); DynamicObjectCollection tqq9_rebatebrand = this.getModel().getDataEntity().getDynamicObjectCollection("tqq9_rebatebrand"); DynamicObject newsupplier = new DynamicObject(tqq9_supplier.getDynamicObjectType()); DynamicObject newbrand = new DynamicObject(tqq9_rebatebrand.getDynamicObjectType()); if (supplier != null) { newsupplier.set("fbasedataId", supplier); tqq9_supplier.add(newsupplier); this.getModel().setValue("tqq9_supplier", tqq9_supplier); } if (tqq9_dxpp != null) { newbrand.set("fbasedataId", tqq9_dxpp); tqq9_rebatebrand.add(newbrand); this.getModel().setValue("tqq9_rebatebrand", tqq9_rebatebrand); } this.getModel().setValue("tqq9_conm_purcontract", purcontract); } @Override public void itemClick(ItemClickEvent evt) { super.itemClick(evt); String itemKey = evt.getItemKey(); if (StringUtils.equals("tqq9_confirm", itemKey)) { DynamicObject dataEntity = this.getModel().getDataEntity(true); HashMap map = new HashMap<>(); map.put("tqq9_pur_rebate", dataEntity); this.getView().returnDataToParent(map); this.getView().close(); } } }