diff --git a/code/zcdev/zcgj-zcdev-zcdev-pr/src/main/java/zcgj/zcdev/zcdev/pr/plugin/form/ContractPriceChangedWarnPlugin.java b/code/zcdev/zcgj-zcdev-zcdev-pr/src/main/java/zcgj/zcdev/zcdev/pr/plugin/form/ContractPriceChangedWarnPlugin.java index 85215d6..9caaa3e 100644 --- a/code/zcdev/zcgj-zcdev-zcdev-pr/src/main/java/zcgj/zcdev/zcdev/pr/plugin/form/ContractPriceChangedWarnPlugin.java +++ b/code/zcdev/zcgj-zcdev-zcdev-pr/src/main/java/zcgj/zcdev/zcdev/pr/plugin/form/ContractPriceChangedWarnPlugin.java @@ -2,6 +2,7 @@ package zcgj.zcdev.zcdev.pr.plugin.form; import kd.bos.bill.AbstractBillPlugIn; import kd.bos.dataentity.entity.DynamicObject; +import kd.bos.dataentity.entity.DynamicObjectCollection; import kd.bos.entity.datamodel.events.ChangeData; import kd.bos.entity.datamodel.events.PropertyChangedArgs; import kd.bos.form.field.events.BeforeF7SelectListener; @@ -19,25 +20,44 @@ public class ContractPriceChangedWarnPlugin extends AbstractBillPlugIn implement super.propertyChanged(e); String price = e.getProperty().getName(); if(price.equals("currentprice")){ - StringBuilder sb = new StringBuilder(); - ChangeData[] changeSet = e.getChangeSet(); - for(ChangeData changeData : changeSet){ - int rowIndex = changeData.getRowIndex(); - DynamicObject oldValue = (DynamicObject) changeData.getOldValue(); - DynamicObject newValue = (DynamicObject) changeData.getNewValue(); - int oldPrice = oldValue.getInt("currentprice"); - int newPrice = newValue.getInt("currentprice"); - if((newPrice >= oldPrice * 2)||(newPrice <= oldPrice * 0.5)){ - String resname = (String)this.getModel().getValue("resname", rowIndex); - sb.append(resname).append(","); - } - } - if(sb.length()>0){ - sb.deleteCharAt(sb.length()-1); + ChangeData changeData = e.getChangeSet()[0];//获取改变的数据 + DynamicObject oldValue = (DynamicObject) changeData.getOldValue(); + DynamicObject newValue = (DynamicObject) changeData.getNewValue(); + int oldPrice = oldValue.getInt("currentprice"); + int newPrice = newValue.getInt("currentprice"); + + + int parentRowIndex = changeData.getParentRowIndex();//获取父索引(获取第几个子单据体) + int rowIndex = changeData.getRowIndex();//获取分录行号 + + DynamicObjectCollection listEntry = this.getModel().getDataEntity().getDynamicObjectCollection("listmodelentry"); + DynamicObject listentry = listEntry.get(parentRowIndex).getDynamicObjectCollection("listentry").get(rowIndex); + + if((newPrice >= oldPrice * 2)||(newPrice <= oldPrice * 0.5)){ + String resname = listentry.getString("resname"); this.getView().showTipNotification( - "请注意,清单项:"+sb.toString()+"的单价变动较大,\n" + + "请注意,清单项:"+resname+"的单价变动较大,\n" + " 请检查是否存在错误"); } +// StringBuilder sb = new StringBuilder(); +// ChangeData[] changeSet = e.getChangeSet(); +// for(ChangeData changeData : changeSet){ +// int rowIndex = changeData.getRowIndex(); +// DynamicObject oldValue = (DynamicObject) changeData.getOldValue(); +// DynamicObject newValue = (DynamicObject) changeData.getNewValue(); +// int oldPrice = oldValue.getInt("currentprice"); +// int newPrice = newValue.getInt("currentprice"); +// if((newPrice >= oldPrice * 2)||(newPrice <= oldPrice * 0.5)){ +// String resname = (String)this.getModel().getValue("resname", rowIndex); +// sb.append(resname).append(","); +// } +// } +// if(sb.length()>0){ +// sb.deleteCharAt(sb.length()-1); +// this.getView().showTipNotification( +// "请注意,清单项:"+sb.toString()+"的单价变动较大,\n" + +// " 请检查是否存在错误"); +// } } }