通用成本中心表单插件成本中心初始化赋值

This commit is contained in:
zengweihai 2024-06-26 19:58:47 +08:00
parent 20f9a9e13c
commit 5df1e116f0
1 changed files with 42 additions and 13 deletions

View File

@ -25,7 +25,7 @@ import java.util.List;
public class CommonCostCenterBillFormPlugin extends AbstractBillPlugIn implements BeforeF7SelectListener,Plugin {
//不同成本中心对应的单据标识
List<String> costList = new ArrayList<String>(Arrays.asList("er_repaymentbill"));//还款单
List<String> costList = new ArrayList<String>(Arrays.asList("er_repaymentbill","er_tripreimbursebill"));//还款单
List<String> entryCostList = new ArrayList<String>(Arrays.asList("er_dailyreimbursebill","er_prepaybill","er_dailyloanbill",
"er_publicreimbursebill"));//费用报销单预付单员工借款单对公报销单
List<String> travelCostList = new ArrayList<String>(Arrays.asList("er_tripreimbursebill"));//差旅报销单
@ -52,6 +52,10 @@ public class CommonCostCenterBillFormPlugin extends AbstractBillPlugIn implement
/**
*注册实物卡片F7字段监听事件
* @param e
@ -70,12 +74,13 @@ public class CommonCostCenterBillFormPlugin extends AbstractBillPlugIn implement
if (edit != null) {
edit.addBeforeF7SelectListener(this);
}
} else if (travelCostList.contains(entityId)) {
BasedataEdit edit = this.getView().getControl("travelcostcenter");
if (edit != null){
edit.addBeforeF7SelectListener(this);
}
}
// } else if (travelCostList.contains(entityId)) {
// BasedataEdit edit = this.getView().getControl("travelcostcenter");
// if (edit != null){
// edit.addBeforeF7SelectListener(this);
// }
// }
}
/**
@ -86,15 +91,39 @@ public class CommonCostCenterBillFormPlugin extends AbstractBillPlugIn implement
public void afterCreateNewData(EventObject e) {
super.afterCreateNewData(e);
DynamicObject dataEntity = this.getModel().getDataEntity();
if (payList.contains(entityId)){//当页面编码为xxxx时设置支付公司
DynamicObject applier = dataEntity.getDynamicObject("applier");//申请人
if (applier != null){
DynamicObject bos_user = BusinessDataServiceHelper.loadSingle(applier.getPkValue(), "bos_user");
if (payList.contains(entityId)){//当页面编码为xxxx时设置支付公司
DynamicObject shkd_labororg = bos_user.getDynamicObject("shkd_labororg");
this.getModel().setValue("paycompany",shkd_labororg);//设置支付公司为申请人员上的劳动主体
}
if (costList.contains(entityId)){//表头成本中心初始化
DynamicObjectCollection costEntity = bos_user.getDynamicObjectCollection("shkd_costentity");
if (costEntity.size() > 0){
DynamicObject shkd_e_cost = costEntity.get(0).getDynamicObject("shkd_e_cost");
this.getModel().setValue("std_costcenter",shkd_e_cost);
if (entityId.equals("er_tripreimbursebill")){
DynamicObjectCollection entryentity = this.getModel().getEntryEntity("entryentity");
for (int i = 0 ; i < entryentity.size(); i++){
this.getModel().setValue("travelcostcenter",shkd_e_cost,i);
}
}
}
}
if (entryCostList.contains(entityId)){
DynamicObjectCollection costEntity = bos_user.getDynamicObjectCollection("shkd_costentity");
if (costEntity.size() > 0){
DynamicObject shkd_e_cost = costEntity.get(0).getDynamicObject("shkd_e_cost");
DynamicObjectCollection expenseentryentity = this.getModel().getEntryEntity("expenseentryentity");
for (int i = 0 ; i < expenseentryentity.size(); i++){
this.getModel().setValue("std_entrycostcenter",shkd_e_cost,i);
}
}
}
}
}
@Override