93 lines
4.1 KiB
Java
93 lines
4.1 KiB
Java
package tqq9.lc123.cloud.app.plugin.form.conm;
|
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
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 =formShowParameter.getCustomParam("purcontract_billno");
|
|
JSONObject purcontract_supplier = formShowParameter.getCustomParam("purcontract_supplier");
|
|
JSONArray purcontract_tqq9_dxpp = formShowParameter.getCustomParam("purcontract_tqq9_dxpp");
|
|
DynamicObject supplier = null;
|
|
// DynamicObject tqq9_dxpp = null;
|
|
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());
|
|
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) {
|
|
for (int i = 0; i < purcontract_tqq9_dxpp.size(); i++) {
|
|
JSONObject jsonObject = (JSONObject)purcontract_tqq9_dxpp.get(i);
|
|
JSONObject fbasedataid = jsonObject.getJSONObject("fbasedataid");
|
|
String number = fbasedataid.getString("number");
|
|
DynamicObject tqq9_dxpp = BusinessDataServiceHelper.loadSingle("tqq9_brand", new QFilter[]{new QFilter("number", QCP.equals, number)});
|
|
if (tqq9_dxpp != null) {
|
|
DynamicObject newbrand = new DynamicObject(tqq9_rebatebrand.getDynamicObjectType());
|
|
newbrand.set("fbasedataId", tqq9_dxpp);
|
|
tqq9_rebatebrand.add(newbrand);
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// 把参数值赋值到页面文本字段上
|
|
if (supplier != null) {
|
|
newsupplier.set("fbasedataId", supplier);
|
|
tqq9_supplier.add(newsupplier);
|
|
this.getModel().setValue("tqq9_supplier", tqq9_supplier);
|
|
}
|
|
this.getModel().setValue("tqq9_conm_purcontract", purcontract);
|
|
this.getModel().setValue("tqq9_rebatebrand", tqq9_rebatebrand);
|
|
|
|
}
|
|
|
|
@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<String, DynamicObject> map = new HashMap<>();
|
|
map.put("tqq9_pur_rebate", dataEntity);
|
|
this.getView().returnDataToParent(map);
|
|
this.getView().close();
|
|
}
|
|
}
|
|
} |