|
@@ -2,6 +2,7 @@ package fi.em.formPlugin;
|
|
|
|
|
|
import kd.bos.dataentity.entity.DynamicObject;
|
|
import kd.bos.dataentity.entity.DynamicObject;
|
|
import kd.bos.dataentity.entity.DynamicObjectCollection;
|
|
import kd.bos.dataentity.entity.DynamicObjectCollection;
|
|
|
|
+import kd.bos.entity.datamodel.events.PropertyChangedArgs;
|
|
import kd.bos.entity.operate.result.OperationResult;
|
|
import kd.bos.entity.operate.result.OperationResult;
|
|
import kd.bos.form.control.EntryGrid;
|
|
import kd.bos.form.control.EntryGrid;
|
|
import kd.bos.form.events.AfterDoOperationEventArgs;
|
|
import kd.bos.form.events.AfterDoOperationEventArgs;
|
|
@@ -25,18 +26,65 @@ public class TravelTotalPlugin extends AbstractFormPlugin {
|
|
private static String entryentity="nckd_entryentity";//差旅汇总标识
|
|
private static String entryentity="nckd_entryentity";//差旅汇总标识
|
|
private static String invoiceandexpense="nckd_invoiceandexpense";//条线产品分摊明细分
|
|
private static String invoiceandexpense="nckd_invoiceandexpense";//条线产品分摊明细分
|
|
|
|
|
|
- @Override
|
|
|
|
- public void beforeDoOperation(BeforeDoOperationEventArgs args) {
|
|
|
|
- super.beforeDoOperation(args);
|
|
|
|
- AbstractOperate op = (AbstractOperate)args.getSource();
|
|
|
|
- String operateKey = op.getOperateKey();
|
|
|
|
|
|
+// @Override
|
|
|
|
+// public void beforeDoOperation(BeforeDoOperationEventArgs args) {
|
|
|
|
+// super.beforeDoOperation(args);
|
|
|
|
+// AbstractOperate op = (AbstractOperate)args.getSource();
|
|
|
|
+// String operateKey = op.getOperateKey();
|
|
|
|
+// //获取当前单据
|
|
|
|
+// DynamicObject dynamicObject=this.getModel().getDataEntity(true);
|
|
|
|
+// //差旅汇总分录
|
|
|
|
+// DynamicObjectCollection nckd_entryentity=dynamicObject.getDynamicObjectCollection(entryentity);
|
|
|
|
+// //汇总map
|
|
|
|
+// Map<DynamicObject,BigDecimal> allMap=new HashMap<>();
|
|
|
|
+// if (bar_save.equals(operateKey)) {
|
|
|
|
+// //获取行程信息
|
|
|
|
+// DynamicObjectCollection dynamicObjectCollection=dynamicObject.getDynamicObjectCollection("tripentry");
|
|
|
|
+// //子卡片分录信息
|
|
|
|
+// for (DynamicObject item:dynamicObjectCollection) {
|
|
|
|
+// for (DynamicObject entry:item.getDynamicObjectCollection("entryentity")) {
|
|
|
|
+// //差旅项目获取
|
|
|
|
+// DynamicObject expenseitem=entry.getDynamicObject("expenseitem");
|
|
|
|
+// //报销金额获取
|
|
|
|
+// BigDecimal orientryamount=entry.getBigDecimal("orientryamount");
|
|
|
|
+// //差旅项目不存在则加进map
|
|
|
|
+// if (!allMap.containsKey(expenseitem)) {
|
|
|
|
+// allMap.put(expenseitem,orientryamount);
|
|
|
|
+// }else {
|
|
|
|
+// //存在则对该项目进行累加
|
|
|
|
+// BigDecimal account = allMap.get(expenseitem);
|
|
|
|
+// account=account.add(orientryamount);
|
|
|
|
+// allMap.put(expenseitem,account);
|
|
|
|
+// }
|
|
|
|
+// }
|
|
|
|
+// }
|
|
|
|
+// Iterator<Map.Entry<DynamicObject, BigDecimal>> iter = allMap.entrySet().iterator();
|
|
|
|
+// //清空分录
|
|
|
|
+// this.getModel().deleteEntryData(entryentity);
|
|
|
|
+// //遍历汇总map
|
|
|
|
+// while (iter.hasNext()) {
|
|
|
|
+// Map.Entry<DynamicObject, BigDecimal> entry = iter.next();
|
|
|
|
+// //新增动态单据分录行
|
|
|
|
+// int rowIndex = this.getModel().createNewEntryRow(entryentity);
|
|
|
|
+// this.getModel().setValue("nckd_travelitem",entry.getKey(),rowIndex);
|
|
|
|
+// this.getModel().setValue("nckd_oriamount",entry.getValue(),rowIndex);
|
|
|
|
+// this.getModel().setValue("nckd_triamount",entry.getValue(),rowIndex);
|
|
|
|
+// }
|
|
|
|
+// //刷新分录
|
|
|
|
+// this.getView().updateView("nckd_entryentity");
|
|
|
|
+// }
|
|
|
|
+// }
|
|
|
|
+
|
|
|
|
+ public void propertyChanged(PropertyChangedArgs e) {
|
|
|
|
+ String fieldKey = e.getProperty().getName();
|
|
//获取当前单据
|
|
//获取当前单据
|
|
DynamicObject dynamicObject=this.getModel().getDataEntity(true);
|
|
DynamicObject dynamicObject=this.getModel().getDataEntity(true);
|
|
//差旅汇总分录
|
|
//差旅汇总分录
|
|
DynamicObjectCollection nckd_entryentity=dynamicObject.getDynamicObjectCollection(entryentity);
|
|
DynamicObjectCollection nckd_entryentity=dynamicObject.getDynamicObjectCollection(entryentity);
|
|
//汇总map
|
|
//汇总map
|
|
Map<DynamicObject,BigDecimal> allMap=new HashMap<>();
|
|
Map<DynamicObject,BigDecimal> allMap=new HashMap<>();
|
|
- if (bar_save.equals(operateKey)) {
|
|
|
|
|
|
+ //付现金额的值发生改变,则重新计算汇总金额
|
|
|
|
+ if (fieldKey.equals("nckd_amountfield4")) {
|
|
//获取行程信息
|
|
//获取行程信息
|
|
DynamicObjectCollection dynamicObjectCollection=dynamicObject.getDynamicObjectCollection("tripentry");
|
|
DynamicObjectCollection dynamicObjectCollection=dynamicObject.getDynamicObjectCollection("tripentry");
|
|
//子卡片分录信息
|
|
//子卡片分录信息
|
|
@@ -73,4 +121,5 @@ public class TravelTotalPlugin extends AbstractFormPlugin {
|
|
this.getView().updateView("nckd_entryentity");
|
|
this.getView().updateView("nckd_entryentity");
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+
|
|
}
|
|
}
|