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

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,13 +25,13 @@ import java.util.List;
public class CommonCostCenterBillFormPlugin extends AbstractBillPlugIn implements BeforeF7SelectListener,Plugin { 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", List<String> entryCostList = new ArrayList<String>(Arrays.asList("er_dailyreimbursebill","er_prepaybill","er_dailyloanbill",
"er_publicreimbursebill"));//费用报销单预付单员工借款单对公报销单 "er_publicreimbursebill"));//费用报销单预付单员工借款单对公报销单
List<String> travelCostList = new ArrayList<String>(Arrays.asList("er_tripreimbursebill"));//差旅报销单 List<String> travelCostList = new ArrayList<String>(Arrays.asList("er_tripreimbursebill"));//差旅报销单
//存在支付公司的单据标识集合 //存在支付公司的单据标识集合
List<String> payList = new ArrayList<String>(Arrays.asList("er_publicreimbursebill","er_dailyloanbill","er_prepaybill", List<String> payList = new ArrayList<String>(Arrays.asList("er_publicreimbursebill","er_dailyloanbill","er_prepaybill",
"er_dailyreimbursebill", "er_tripreimbursebill" ));//对公报销单员工借款单预付单费用报销单差旅报销单 "er_dailyreimbursebill", "er_tripreimbursebill" ));//对公报销单员工借款单预付单费用报销单差旅报销单
@ -52,6 +52,10 @@ public class CommonCostCenterBillFormPlugin extends AbstractBillPlugIn implement
/** /**
*注册实物卡片F7字段监听事件 *注册实物卡片F7字段监听事件
* @param e * @param e
@ -65,17 +69,18 @@ public class CommonCostCenterBillFormPlugin extends AbstractBillPlugIn implement
if (edit != null){ if (edit != null){
edit.addBeforeF7SelectListener(this); edit.addBeforeF7SelectListener(this);
} }
}else if (costList.contains(entityId)){ }else if (costList.contains(entityId)) {
BasedataEdit edit = this.getView().getControl("std_costcenter"); BasedataEdit edit = this.getView().getControl("std_costcenter");
if (edit != null){ if (edit != null) {
edit.addBeforeF7SelectListener(this);
}
} else if (travelCostList.contains(entityId)) {
BasedataEdit edit = this.getView().getControl("travelcostcenter");
if (edit != null){
edit.addBeforeF7SelectListener(this); edit.addBeforeF7SelectListener(this);
} }
} }
// } else if (travelCostList.contains(entityId)) {
// BasedataEdit edit = this.getView().getControl("travelcostcenter");
// if (edit != null){
// edit.addBeforeF7SelectListener(this);
// }
// }
} }
/** /**
@ -86,14 +91,38 @@ public class CommonCostCenterBillFormPlugin extends AbstractBillPlugIn implement
public void afterCreateNewData(EventObject e) { public void afterCreateNewData(EventObject e) {
super.afterCreateNewData(e); super.afterCreateNewData(e);
DynamicObject dataEntity = this.getModel().getDataEntity(); DynamicObject dataEntity = this.getModel().getDataEntity();
if (payList.contains(entityId)){//当页面编码为xxxx时设置支付公司 DynamicObject applier = dataEntity.getDynamicObject("applier");//申请人
DynamicObject applier = dataEntity.getDynamicObject("applier");//申请人 if (applier != null){
if (applier != null){ DynamicObject bos_user = BusinessDataServiceHelper.loadSingle(applier.getPkValue(), "bos_user");
DynamicObject bos_user = BusinessDataServiceHelper.loadSingle(applier.getPkValue(), "bos_user"); if (payList.contains(entityId)){//当页面编码为xxxx时设置支付公司
DynamicObject shkd_labororg = bos_user.getDynamicObject("shkd_labororg"); DynamicObject shkd_labororg = bos_user.getDynamicObject("shkd_labororg");
this.getModel().setValue("paycompany",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);
}
}
}
} }
} }