diff --git a/code/zcdev/zcgj-zcdev-zcdev-pr/src/main/java/zcgj/zcdev/zcdev/pr/plugin/form/ContractSettleBillPlugin.java b/code/zcdev/zcgj-zcdev-zcdev-pr/src/main/java/zcgj/zcdev/zcdev/pr/plugin/form/ContractSettleBillPlugin.java index c466c7f..a97701f 100644 --- a/code/zcdev/zcgj-zcdev-zcdev-pr/src/main/java/zcgj/zcdev/zcdev/pr/plugin/form/ContractSettleBillPlugin.java +++ b/code/zcdev/zcgj-zcdev-zcdev-pr/src/main/java/zcgj/zcdev/zcdev/pr/plugin/form/ContractSettleBillPlugin.java @@ -8,6 +8,7 @@ import kd.bos.entity.datamodel.events.PropertyChangedArgs; import kd.bos.entity.operate.result.OperationResult; import kd.bos.form.control.Control; import kd.bos.form.control.events.BeforeClickEvent; +import kd.bos.form.control.events.BeforeItemClickEvent; import kd.bos.orm.query.QFilter; import kd.bos.servicehelper.BusinessDataServiceHelper; import kd.bos.servicehelper.operation.SaveServiceHelper; @@ -39,46 +40,57 @@ public class ContractSettleBillPlugin extends AbstractBillPlugIn implements Plug public void registerListener(EventObject e) { super.registerListener(e); // 注册按钮点击事件 - this.addClickListeners("bar_save"); + this.addClickListeners("bar_audit"); + this.addItemClickListeners("bar_audit"); } @Override public void beforeClick(BeforeClickEvent evt) { super.beforeClick(evt); + + } + + @Override + public void click(EventObject evt) { + super.click(evt); + } + + @Override + public void beforeItemClick(BeforeItemClickEvent evt) { + super.beforeItemClick(evt); Control source = (Control) evt.getSource(); - if (StringUtils.equals("bar_save", source.getKey())) { - // 在此添加业务逻辑 - Object changetype = this.getModel().getValue("changetype"); - if (changetype != null) { - if (changetype.toString().equals("03")) { - Object contract = this.getModel().getValue("contract"); - DynamicObject contractInfo = (DynamicObject) contract; - String billName = contractInfo.getDataEntityType().getName(); - DynamicObject zcgjParta = (DynamicObject)this.getModel().getValue("zcgj_parta"); - Object zcgjOtherpart = this.getModel().getValue("zcgj_otherpart"); - if (billName.equals("ec_out_contract_f7")) { - QFilter f1 = new QFilter("number", "=", contractInfo.getString("number")); - DynamicObject outContractF7 = BusinessDataServiceHelper.loadSingle("ec_out_contract_f7", new QFilter[]{f1}); - outContractF7.set("parta",zcgjParta); - OperationResult saveOperationResult = SaveServiceHelper.saveOperate("ec_out_contract_f7", new DynamicObject[]{outContractF7}, null);//支出合同F7实体 - - QFilter f2 = new QFilter("billno", "=", contractInfo.getString("number")); - DynamicObject outContract = BusinessDataServiceHelper.loadSingle("ec_out_contract", new QFilter[]{f2}); - outContract.set("parta",zcgjParta); - if(zcgjOtherpart!=null){ - DynamicObjectCollection otherpart = (DynamicObjectCollection) this.getModel().getValue("zcgj_otherpart"); - outContract.set("otherpart",otherpart); - outContract.set("ismulticontract",true); - } - OperationResult saveOperationResult1 = SaveServiceHelper.saveOperate("ec_out_contract", new DynamicObject[]{outContractF7}, null);//支出合同实体 - System.out.println(saveOperationResult1); - }else{ + if (StringUtils.equals("bar_audit", source.getKey())) { + // 在此添加业务逻辑 + Object changetype = this.getModel().getValue("changetype"); + if (changetype != null) { + if (changetype.toString().equals("03")) { + Object contract = this.getModel().getValue("contract"); + DynamicObject contractInfo = (DynamicObject) contract; + String billName = contractInfo.getDataEntityType().getName(); + DynamicObject zcgjParta = (DynamicObject)this.getModel().getValue("zcgj_parta"); + Object zcgjOtherpart = this.getModel().getValue("zcgj_otherpart"); + if (billName.equals("ec_out_contract_f7")) { + QFilter f1 = new QFilter("number", "=", contractInfo.getString("number")); + DynamicObject outContractF7 = BusinessDataServiceHelper.loadSingle("ec_out_contract_f7", new QFilter[]{f1}); + outContractF7.set("parta",zcgjParta); + OperationResult saveOperationResult = SaveServiceHelper.saveOperate("ec_out_contract_f7", new DynamicObject[]{outContractF7}, null);//支出合同F7实体 + QFilter f2 = new QFilter("billno", "=", contractInfo.getString("number")); + DynamicObject outContract = BusinessDataServiceHelper.loadSingle("ec_out_contract", new QFilter[]{f2}); + outContract.set("parta",zcgjParta); + if(zcgjOtherpart!=null){ + DynamicObjectCollection otherpart = (DynamicObjectCollection) this.getModel().getValue("zcgj_otherpart"); + outContract.set("otherpart",otherpart); + outContract.set("ismulticontract",true); } + OperationResult saveOperationResult1 = SaveServiceHelper.saveOperate("ec_out_contract", new DynamicObject[]{outContractF7}, null);//支出合同实体 + System.out.println(saveOperationResult1); + }else{ + } } + } evt.setCancel(true); // 取消后续处理,将不会再触发click事件 - } } diff --git a/code/zcdev/zcgj-zcdev-zcdev-pr/src/main/java/zcgj/zcdev/zcdev/pr/plugin/form/EcContractFromPlugin.java b/code/zcdev/zcgj-zcdev-zcdev-pr/src/main/java/zcgj/zcdev/zcdev/pr/plugin/form/EcContractFromPlugin.java index 88e405c..83f3036 100644 --- a/code/zcdev/zcgj-zcdev-zcdev-pr/src/main/java/zcgj/zcdev/zcdev/pr/plugin/form/EcContractFromPlugin.java +++ b/code/zcdev/zcgj-zcdev-zcdev-pr/src/main/java/zcgj/zcdev/zcdev/pr/plugin/form/EcContractFromPlugin.java @@ -1,8 +1,12 @@ package zcgj.zcdev.zcdev.pr.plugin.form; import kd.bos.bill.AbstractBillPlugIn; +import kd.bos.dataentity.entity.DynamicObject; +import kd.bos.entity.datamodel.events.ChangeData; +import kd.bos.entity.datamodel.events.PropertyChangedArgs; import kd.sdk.plugin.Plugin; +import java.math.BigDecimal; import java.util.EventObject; /** @@ -15,4 +19,88 @@ public class EcContractFromPlugin extends AbstractBillPlugIn implements Plugin { super.afterCreateNewData(e); } + + @Override + public void propertyChanged(PropertyChangedArgs e) { + super.propertyChanged(e); + String name = e.getProperty().getName(); + ChangeData changeData = e.getChangeSet()[0]; + + Object taxrate = this.getModel().getValue("taxrate"); + if (taxrate != null) { + DynamicObject taxrateInfo = (DynamicObject) taxrate; + BigDecimal trate = taxrateInfo.getBigDecimal("taxrate"); + BigDecimal pRate = trate.divide(new BigDecimal(100)).add(new BigDecimal(1)); + BigDecimal amount = new BigDecimal(0); + BigDecimal ofamount = new BigDecimal(0); + BigDecimal rate = new BigDecimal(0); + DynamicObject dataEntity = this.getModel().getDataEntity(true); + if (name.equals("zcgj_pjnhhshte")) { + Object zcgjPjnhbhshte = this.getModel().getValue("zcgj_pjnhhshte"); + System.out.println(); + if (zcgjPjnhbhshte != null) { + ofamount = new BigDecimal(zcgjPjnhbhshte.toString()); + } + amount = ofamount.divide(pRate, 6, BigDecimal.ROUND_HALF_UP); + rate = ofamount.subtract(amount); + dataEntity.set("zcgj_pjnhbhshte", amount); + dataEntity.set("zcgj_pjnhse", rate); +// this.getModel().setValue("zcgj_pjnhbhshte", amount); +// this.getModel().setValue("zcgj_pjnhse", rate); + } else if (name.equals("zcgj_pjnhbhshte")) { + Object zcgjPjnhhshte = this.getModel().getValue("zcgj_pjnhbhshte"); + System.out.println(); + if (zcgjPjnhhshte != null) { + amount = new BigDecimal(zcgjPjnhhshte.toString()); + } + ofamount = amount.multiply(pRate); + rate = ofamount.subtract(amount); +// this.getModel().setValue("zcgj_pjnhhshte", ofamount); +// this.getModel().setValue("zcgj_pjnhse", rate); + dataEntity.set("zcgj_pjnhhshte", ofamount); + dataEntity.set("zcgj_pjnhse", rate); + }else if (name.equals("zcgj_yjhshtsr")) { + Object zcgjyjhshtsr = this.getModel().getValue("zcgj_yjhshtsr"); + System.out.println(); + if (zcgjyjhshtsr != null) { + ofamount = new BigDecimal(zcgjyjhshtsr.toString()); + } + amount = ofamount.divide(pRate, 6, BigDecimal.ROUND_HALF_UP); + rate = ofamount.subtract(amount); +// this.getModel().setValue("zcgj_yjbhshtsr", amount); +// this.getModel().setValue("zcgj_yjzse", rate); + dataEntity.set("zcgj_yjbhshtsr", amount); + dataEntity.set("zcgj_yjzse", rate); + } else if (name.equals("zcgj_yjbhshtsr")) { + Object zcgjyjbhshtsr = this.getModel().getValue("zcgj_yjbhshtsr"); + System.out.println(); + if (zcgjyjbhshtsr != null) { + amount = new BigDecimal(zcgjyjbhshtsr.toString()); + } + ofamount = amount.multiply(pRate); + rate = ofamount.subtract(amount); +// this.getModel().setValue("zcgj_yjhshtsr", ofamount); +// this.getModel().setValue("zcgj_yjzse", rate); + dataEntity.set("zcgj_yjhshtsr", ofamount); + dataEntity.set("zcgj_yjzse", rate); + }else if (name.equals("zcgj_hshtdj")) { + Object zcgjhshtdj = this.getModel().getValue("zcgj_hshtdj"); + if (zcgjhshtdj != null) { + ofamount = new BigDecimal(zcgjhshtdj.toString()); + } + amount = ofamount.divide(pRate,6, BigDecimal.ROUND_HALF_UP); + dataEntity.set("zcgj_bhshtdj", amount); +// this.getModel().setValue("zcgj_bhshtdj", ofamount); + }else if (name.equals("zcgj_bhshtdj")) { + Object zcgjbhshtdj = this.getModel().getValue("zcgj_bhshtdj"); + if (zcgjbhshtdj != null) { + amount = new BigDecimal(zcgjbhshtdj.toString()); + } + ofamount = amount.multiply(pRate); + dataEntity.set("zcgj_hshtdj", ofamount); +// this.getModel().setValue("zcgj_hshtdj", ofamount); + } + this.getView().updateView(); + } + } } \ No newline at end of file