133 lines
		
	
	
		
			6.6 KiB
		
	
	
	
		
			Java
		
	
	
	
			
		
		
	
	
			133 lines
		
	
	
		
			6.6 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.datamodel.IDataModel;
 | |
| import kd.bos.form.FormShowParameter;
 | |
| import kd.bos.form.events.AfterDoOperationEventArgs;
 | |
| import kd.bos.form.field.MulBasedataEdit;
 | |
| import kd.bos.form.field.events.BeforeF7SelectEvent;
 | |
| import kd.bos.form.field.events.BeforeF7SelectListener;
 | |
| import kd.bos.list.ListShowParameter;
 | |
| 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 java.util.Date;
 | |
| import java.util.EventObject;
 | |
| import java.util.HashMap;
 | |
| 
 | |
| /**
 | |
|  * 返利规则表单插件
 | |
|  * 同步采购合同信息
 | |
|  */
 | |
| public class RebateRulesBillPlugin extends AbstractBillPlugIn implements BeforeF7SelectListener {
 | |
|     private final static Log logger = LogFactory.getLog(RebateRulesBillPlugin.class);
 | |
| 
 | |
|     @Override
 | |
|     public void registerListener(EventObject e) {
 | |
|         super.registerListener(e);
 | |
|         this.addItemClickListeners("tbmain");
 | |
|         MulBasedataEdit control = this.getControl("tqq9_exclunopur");
 | |
|         control.addBeforeF7SelectListener(this);
 | |
|     }
 | |
| 
 | |
|     @Override
 | |
|     public void beforeF7Select(BeforeF7SelectEvent beforeF7SelectEvent) {
 | |
|         IDataModel model = this.getModel();
 | |
|         String tqq9_excludnum = model.getDataEntity().getString("tqq9_excludnum");
 | |
|         Date tqq9_startexcludate = model.getDataEntity().getDate("tqq9_startexcludate");
 | |
|         Date tqq9_endexcludate = model.getDataEntity().getDate("tqq9_endexcludate");
 | |
|         if (tqq9_startexcludate == null || tqq9_endexcludate == null) {
 | |
|             beforeF7SelectEvent.setCancel(true);
 | |
|             this.getView().showMessage("请先填写排除时间段");
 | |
|         }
 | |
|         if (StringUtils.equals("1", tqq9_excludnum)) {
 | |
|             ListShowParameter param = (ListShowParameter) beforeF7SelectEvent.getFormShowParameter();
 | |
|             QFilter qF1 = new QFilter("biztime", QCP.large_equals, tqq9_startexcludate);
 | |
|             QFilter qF2 = new QFilter("biztime", QCP.less_equals, tqq9_endexcludate);
 | |
|             param.getListFilterParameter().getQFilters().add(qF1.and(qF2));
 | |
|         }
 | |
|     }
 | |
| 
 | |
|     @Override
 | |
|     public void afterDoOperation(AfterDoOperationEventArgs afterDoOperationEventArgs) {
 | |
|         super.afterDoOperation(afterDoOperationEventArgs);
 | |
|         String itemKey = afterDoOperationEventArgs.getOperateKey();
 | |
|         if (StringUtils.equals("donothing", itemKey)) {
 | |
|             Object name = this.getModel().getValue("name");
 | |
|             String status = this.getModel().getValue("status").toString();
 | |
|             if(StringUtils.equals("A",status)){
 | |
|                 this.getView().showErrorNotification("返利规则编辑完成后请先提交返利规则再单击确认");
 | |
|             }
 | |
|             Object tqq9_supplier = this.getModel().getValue("tqq9_supplier");
 | |
|             Object tqq9_startdate = this.getModel().getValue("tqq9_startdate");
 | |
|             Object tqq9_enddate = this.getModel().getValue("tqq9_enddate");
 | |
|             Object tqq9_estimatepro = this.getModel().getValue("tqq9_estimatepro");
 | |
|             Object tqq9_rebatebrand = this.getModel().getValue("tqq9_rebatebrand");
 | |
|             Object tqq9_rebategoods = this.getModel().getValue("tqq9_rebategoods");
 | |
|             if (name == null || tqq9_supplier == null || tqq9_startdate == null || tqq9_enddate == null || tqq9_estimatepro == null || tqq9_rebatebrand == null || tqq9_rebategoods == null) {
 | |
|                 this.getView().showErrorNotification("请确认必录项是否为空");
 | |
|             } else {
 | |
|                 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();
 | |
|             }
 | |
|         }
 | |
|     }
 | |
| 
 | |
|     @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);
 | |
| 
 | |
|     }
 | |
| 
 | |
| 
 | |
| } |