差旅报销单分录成本中心同步、补助报销金额自动计算及成本中心必录设置

This commit is contained in:
zengweihai 2024-06-26 19:27:47 +08:00
parent e4cfd53241
commit 20f9a9e13c
1 changed files with 55 additions and 0 deletions

View File

@ -0,0 +1,55 @@
package shkd.fi.em.plugin.formplugin;
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.control.Control;
import kd.bos.form.field.BasedataEdit;
import kd.bos.form.plugin.AbstractFormPlugin;
import kd.sdk.plugin.Plugin;
import java.math.BigDecimal;
import java.util.EventObject;
/**
* 动态表单插件
*/
public class TripReimBillStaAmountCalculationFormPlugin extends AbstractFormPlugin implements Plugin {
@Override
public void afterBindData(EventObject e) {
super.afterBindData(e);
BasedataEdit std_costcenter = this.getControl("std_costcenter");
std_costcenter.setMustInput(true);
}
@Override
public void propertyChanged(PropertyChangedArgs e) {
super.propertyChanged(e);
String name = e.getProperty().getName();
if ("caldaycount".equals(name)){
ChangeData[] changeSet = e.getChangeSet();
int rowIndex = changeSet[0].getRowIndex();//获取天数变更行下标
BigDecimal newValue = (BigDecimal) changeSet[0].getNewValue();
DynamicObjectCollection entryentity = this.getModel().getEntryEntity("entryentity");
DynamicObject dynamicObject = entryentity.get(rowIndex);
DynamicObject expenseitem = dynamicObject.getDynamicObject("expenseitem");
String longnumber = expenseitem.getString("longnumber");//获取编码
if ("0016".equals(longnumber)){
this.getModel().setValue("orientryamount",newValue.multiply(BigDecimal.valueOf(100)),rowIndex);
}
}else if ("std_costcenter".equals(name)){
ChangeData[] changeSet = e.getChangeSet();
DynamicObject newValue = (DynamicObject) changeSet[0].getNewValue();
DynamicObjectCollection entryentity = this.getModel().getEntryEntity("entryentity");
for (int i = 0 ; i < entryentity.size(); i++){
this.getModel().setValue("travelcostcenter",newValue,i);
}
}
}
}