差旅报销单是否委托功能二开

This commit is contained in:
zengweihai 2024-10-23 17:07:49 +08:00
parent a4fd743f93
commit ffdef4fc48
1 changed files with 37 additions and 0 deletions

View File

@ -2,6 +2,7 @@ package shkd.fi.em.plugin.formplugin;
import kd.bos.dataentity.entity.DynamicObject;
import kd.bos.dataentity.entity.DynamicObjectCollection;
import kd.bos.dataentity.metadata.ISimpleProperty;
import kd.bos.entity.datamodel.RowDataEntity;
import kd.bos.entity.datamodel.events.AfterAddRowEventArgs;
import kd.bos.entity.datamodel.events.ChangeData;
@ -15,11 +16,14 @@ import kd.bos.list.ListShowParameter;
import kd.bos.orm.query.QCP;
import kd.bos.orm.query.QFilter;
import kd.bos.servicehelper.BusinessDataServiceHelper;
import kd.bos.servicehelper.user.UserServiceHelper;
import kd.sdk.plugin.Plugin;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Date;
import java.util.EventObject;
import java.util.HashSet;
/**
* 动态表单插件
@ -41,6 +45,10 @@ public class TripReimBillStaAmountCalculationFormPlugin extends AbstractFormPlug
if (edit != null){
edit.addBeforeF7SelectListener(this);
}
BasedataEdit entruster_edit = this.getView().getControl("shkd_entruster");
if (edit != null){
entruster_edit.addBeforeF7SelectListener(this);
}
}
@Override
@ -67,6 +75,12 @@ public class TripReimBillStaAmountCalculationFormPlugin extends AbstractFormPlug
for (int i = 0 ; i < entryentity.size(); i++){
this.getModel().setValue("travelcostcenter",newValue,i);
}
}else if ("shkd_isentrust".equals(name)){
ChangeData[] changeSet = e.getChangeSet();
boolean newValue = (boolean) changeSet[0].getNewValue();
if (!newValue){
this.getModel().setValue("shkd_entruster",null);
}
}
@ -131,6 +145,29 @@ public class TripReimBillStaAmountCalculationFormPlugin extends AbstractFormPlug
}
}
}else if ("shkd_entruster".equals(name)){
//er_tripreimbursebill
QFilter cl_QF= new QFilter("bill_number", QCP.equals, "er_tripreimbursebill");
DynamicObject dynamicObject = BusinessDataServiceHelper.loadSingle("er_billtype", "id", cl_QF.toArray());
if (dynamicObject != null){
Object id = dynamicObject.getPkValue();
Long userId = UserServiceHelper.getCurrentUserId();//获取当前用户
QFilter qFilter = new QFilter("trustee.id", QCP.equals, userId);//受托人为当前用户
Date date = new Date();//当前时间
qFilter.and("startdate",QCP.less_equals,date);//等于或晚于开始时间
qFilter.and("enddate" ,QCP.large_equals,date);//早于或等于结束时间
qFilter.and("entrustedscope.fbasedataid",QCP.equals,id);//等于实体id
DynamicObject[] er_entrustreimburses = BusinessDataServiceHelper.load("er_entrustreimburse", "id,consignor.id", qFilter.toArray());
HashSet<Long> longs = new HashSet<>();
for (DynamicObject er_entrustreimbur : er_entrustreimburses) {
DynamicObject consignor = er_entrustreimbur.getDynamicObject("consignor");
long aLong = consignor.getLong("id");
longs.add(aLong);
}
QFilter user_qf = new QFilter("id", QCP.in, longs);
ListShowParameter formShowParameter = (ListShowParameter) beforeF7SelectEvent.getFormShowParameter();
formShowParameter.getListFilterParameter().setFilter(user_qf);
}
}
}
}