From 5db8d9ce0c19c98b2adac18d36daf46c120cc5d0 Mon Sep 17 00:00:00 2001 From: zhangzhiguo <17621308561@163.com> Date: Tue, 10 Dec 2024 13:51:10 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B4=B9=E7=94=A8=E6=8A=A5=E9=94=80=E5=92=8C?= =?UTF-8?q?=E5=AF=B9=E5=85=AC=E6=8A=A5=E9=94=80=E8=B4=B9=E7=94=A8=E9=A1=B9?= =?UTF-8?q?=E7=9B=AE=E5=92=8C=E4=BC=9A=E8=AE=A1=E7=A7=91=E7=9B=AE=E5=85=B3?= =?UTF-8?q?=E8=81=94?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fs/plugin/form/DailyreimbursPlugin.java | 110 +++++++++------ .../form/PublicreimbursebillPlugin.java | 128 ++++++++++++------ .../plugin/form/TripreimbursebillPlugin.java | 76 +++++++++++ 3 files changed, 234 insertions(+), 80 deletions(-) create mode 100644 code/zcdev/zcgj-zcdev-zcdev-fs/src/main/java/zcgj/zcdev/zcdev/fs/plugin/form/TripreimbursebillPlugin.java diff --git a/code/zcdev/zcgj-zcdev-zcdev-fs/src/main/java/zcgj/zcdev/zcdev/fs/plugin/form/DailyreimbursPlugin.java b/code/zcdev/zcgj-zcdev-zcdev-fs/src/main/java/zcgj/zcdev/zcdev/fs/plugin/form/DailyreimbursPlugin.java index 8cbda3e..8ac8db3 100644 --- a/code/zcdev/zcgj-zcdev-zcdev-fs/src/main/java/zcgj/zcdev/zcdev/fs/plugin/form/DailyreimbursPlugin.java +++ b/code/zcdev/zcgj-zcdev-zcdev-fs/src/main/java/zcgj/zcdev/zcdev/fs/plugin/form/DailyreimbursPlugin.java @@ -27,6 +27,7 @@ import kd.bos.orm.query.QFilter; import kd.bos.servicehelper.BusinessDataServiceHelper; import kd.bos.servicehelper.QueryServiceHelper; import kd.sdk.plugin.Plugin; +import org.apache.commons.lang3.StringUtils; import java.text.SimpleDateFormat; import java.time.LocalDate; @@ -304,6 +305,7 @@ public class DailyreimbursPlugin extends AbstractBillPlugIn implements Plugin, super.registerListener(e); BasedataEdit fieldEdit = this.getView().getControl(ACCOUNT_ITEM); fieldEdit.addBeforeF7SelectListener(this); + fieldEdit.addAfterF7SelectListener(this); BasedataEdit fieldEditExpense = this.getView().getControl(EXPENSE_ITEM); fieldEditExpense.addBeforeF7SelectListener(this); @@ -315,33 +317,46 @@ public class DailyreimbursPlugin extends AbstractBillPlugIn implements Plugin, public void afterF7Select(AfterF7SelectEvent afterF7SelectEvent) { String name = ((BasedataEdit) afterF7SelectEvent.getSource()).getKey(); if(ACCOUNT_ITEM.equals(name)){ - String id = (String) afterF7SelectEvent.getInputValue(); - QFilter nameQFilter = new QFilter(prefix+"_accounts",QCP.equals,Long.valueOf(id)); - DynamicObject dynamicObject1 = BusinessDataServiceHelper.loadSingle(MAP_TABLE, "createorg,zcgj_entryentity,zcgj_entryentity.zcgj_entity_items", new QFilter[]{nameQFilter}); - Object value = this.getModel().getValue(EXPENSE_ITEM, selectRow); - if(value == null && dynamicObject1!=null&&selectRow!=null){ - DynamicObjectCollection zcgjEntryentity = (DynamicObjectCollection) dynamicObject1.get(MAP_ENTRY_ENTITY); - if(zcgjEntryentity!=null){ - DynamicObject dynamicObject = zcgjEntryentity.get(0); - DynamicObject itemDynamicObject= dynamicObject.getDynamicObject(prefix+"_entity_items"); - long aLong = itemDynamicObject.getLong("id"); - System.out.println(); - this.getModel().setValue(EXPENSE_ITEM,aLong,selectRow); - }else{ - // this.getModel().setValue(EXPENSE_ITEM,null,index); + Long id = null; + // 获取选中行 + ListSelectedRow selectRowList = afterF7SelectEvent.getListSelectedRow(); + Object inputValue = afterF7SelectEvent.getInputValue(); + if(selectRowList != null){//弹框选择 + id = (Long) selectRowList.getPrimaryKeyValue(); + }else if(inputValue != null){//模糊查询 + id=Long.valueOf(inputValue.toString()); + } + if(id!=null){ + QFilter nameQFilter = new QFilter(prefix+"_accounts",QCP.equals,id); + DynamicObject dynamicObject1 = BusinessDataServiceHelper.loadSingle(MAP_TABLE, "createorg,zcgj_entryentity,zcgj_entryentity.zcgj_entity_items", new QFilter[]{nameQFilter}); + DynamicObject dynamicObject2 = this.getModel().getDataEntity(true).getDynamicObjectCollection(EXPENSE_ENTRY_ENTITY).get(selectRow); + boolean isEx = false; + if(dynamicObject2!=null){ + isEx = dynamicObject2.get(EXPENSE_ITEM) == null; + } + if(isEx && dynamicObject1!=null&&selectRow!=null){ + DynamicObjectCollection zcgjEntryentity = (DynamicObjectCollection) dynamicObject1.get(MAP_ENTRY_ENTITY); + if(zcgjEntryentity!=null){ + DynamicObject dynamicObject = zcgjEntryentity.get(0); + DynamicObject itemDynamicObject= dynamicObject.getDynamicObject(prefix+"_entity_items"); + long aLong = itemDynamicObject.getLong("id"); + System.out.println(); + this.getModel().setValue(EXPENSE_ITEM,aLong,selectRow); + } } - }else{ - //this.getModel().setValue(EXPENSE_ITEM,null,index); } }else if(EXPENSE_ITEM.equals(name)){ - String id = (String) afterF7SelectEvent.getInputValue(); - QFilter nameQFilter = new QFilter(prefix+"_entryentity.zcgj_entity_items.id", QCP.equals,Long.valueOf(id)); - DynamicObject[] load = BusinessDataServiceHelper.load(MAP_TABLE, "createorg,zcgj_accounts", new QFilter[]{nameQFilter}); - Object value = this.getModel().getValue(ACCOUNT_ITEM, selectRow); - if(value==null && load!=null && load.length>0){ - DynamicObject dynamicObject = load[0]; - long aLong = dynamicObject.getLong("zcgj_accounts_id"); - this.getModel().setValue(ACCOUNT_ITEM,aLong,selectRow); + Object inputValue = afterF7SelectEvent.getInputValue(); + if(inputValue!=null){ + String id = String.valueOf(inputValue) ; + QFilter nameQFilter = new QFilter(prefix+"_entryentity.zcgj_entity_items.id", QCP.equals,Long.valueOf(id)); + DynamicObject[] load = BusinessDataServiceHelper.load(MAP_TABLE, "createorg,zcgj_accounts", new QFilter[]{nameQFilter}); + Object value = this.getModel().getValue(ACCOUNT_ITEM, selectRow); + if(value==null && load!=null && load.length>0){ + DynamicObject dynamicObject = load[0]; + long aLong = dynamicObject.getLong("zcgj_accounts_id"); + this.getModel().setValue(ACCOUNT_ITEM,aLong,selectRow); + } } } @@ -352,12 +367,21 @@ public class DailyreimbursPlugin extends AbstractBillPlugIn implements Plugin, public void beforeF7Select(BeforeF7SelectEvent arg0) { String name = arg0.getProperty().getName(); if(name.equals(ACCOUNT_ITEM)){ - if("click".equals(arg0.getSourceMethod())){ + selectRow = arg0.getRow(); + /* List qFilterList = new ArrayList(); + qFilterList.add(new QFilter("number", QCP.like,"Sups%")); + arg0.setCustomQFilters(qFilterList);*/ + + /*if("click".equals(arg0.getSourceMethod())){ arg0.setCancel(true); Object value = this.getModel().getValue("zcgj_accounttable_number"); + DynamicObject costcompany = (DynamicObject)this.getModel().getValue("costcompany"); + long costcompanyId = costcompany.getLong("id"); //设置自定义F7弹框,增加过滤条件 List qFilterList = new ArrayList(); qFilterList.add(new QFilter("accounttable.number", QCP.equals,value)); + //qFilterList.add(new QFilter("createorg", QCP.equals,Long.parseLong(costcompanyId+""))); + ListFilterParameter listFilterParameter =new ListFilterParameter(qFilterList,null); ListShowParameter showParameter = ShowFormHelper.createShowListForm("bd_accountview", true); showParameter.setCloseCallBack(new CloseCallBack(this,ACTION_ID)); @@ -366,6 +390,10 @@ public class DailyreimbursPlugin extends AbstractBillPlugIn implements Plugin, }else if("setItemByIdFromClient".equals(arg0.getSourceMethod()) ){ selectRow = arg0.getRow(); ((BasedataEdit) arg0.getSource()).addAfterF7SelectListener(this); + }*/ + if("setItemByIdFromClient".equals(arg0.getSourceMethod()) ){ + selectRow = arg0.getRow(); + ((BasedataEdit) arg0.getSource()).addAfterF7SelectListener(this); } }else if(name.equals(EXPENSE_ITEM)){ if("click".equals(arg0.getSourceMethod())){ @@ -388,7 +416,7 @@ public class DailyreimbursPlugin extends AbstractBillPlugIn implements Plugin, Object returnData = closedCallBackEvent.getReturnData(); boolean current= true; - if(returnData!=null && actionId.equals(ACTION_ID)){ + /*if(returnData!=null && actionId.equals(ACTION_ID)){ //获取选中的索引 int index = this.getModel().getEntryCurrentRowIndex(EXPENSE_ENTRY_ENTITY); //操作的行数据,获取之前的数据 @@ -445,7 +473,8 @@ public class DailyreimbursPlugin extends AbstractBillPlugIn implements Plugin, this.getModel().createNewEntryRow(EXPENSE_ENTRY_ENTITY,insertRow); } } - }else if(returnData!=null && actionId.equals(ACTION_ID_EXPENSE)){ + }else */ + if(returnData!=null && actionId.equals(ACTION_ID_EXPENSE)){ //获取选中的索引 int index = this.getModel().getEntryCurrentRowIndex(EXPENSE_ENTRY_ENTITY); //操作的行数据,获取之前的数据 @@ -473,26 +502,27 @@ public class DailyreimbursPlugin extends AbstractBillPlugIn implements Plugin, } current = false; }else{ - Object accountItem = this.getModel().getValue(ACCOUNT_ITEM, index); - if(accountItem==null){ - QFilter nameQFilter = new QFilter(prefix+"_entryentity.zcgj_entity_items.id", QCP.equals,listSelectedRow.getPrimaryKeyValue()); - DynamicObject[] load = BusinessDataServiceHelper.load(MAP_TABLE, "createorg,zcgj_accounts", new QFilter[]{nameQFilter}); - if(load!=null && load.length>0){ - DynamicObject dynamicObject = load[0]; - DynamicObject zcgjAccounts = dynamicObject.getDynamicObject("zcgj_accounts"); - if(zcgjAccounts!=null){ - //会计科目 - insertRow.set(ACCOUNT_ITEM,zcgjAccounts); - } - }else{ - insertRow.set(ACCOUNT_ITEM,null); + //Object accountItem = this.getModel().getValue(ACCOUNT_ITEM, index); + //if(accountItem == null){ + QFilter nameQFilter = new QFilter(prefix+"_entryentity.zcgj_entity_items.id", QCP.equals,listSelectedRow.getPrimaryKeyValue()); + DynamicObject[] load = BusinessDataServiceHelper.load(MAP_TABLE, "createorg,zcgj_accounts", new QFilter[]{nameQFilter}); + if(load!=null && load.length>0){ + DynamicObject dynamicObject = load[0]; + DynamicObject zcgjAccounts = dynamicObject.getDynamicObject("zcgj_accounts"); + if(zcgjAccounts!=null){ + //会计科目 + insertRow.set(ACCOUNT_ITEM,zcgjAccounts); } + }else{ + insertRow.set(ACCOUNT_ITEM,null); } + //} //费用项目科目 QFilter nameQFilterAccItem = new QFilter("id",QCP.equals,listSelectedRow.getPrimaryKeyValue()); DynamicObject dynamicObjectAccItem = BusinessDataServiceHelper.loadSingle("er_expenseitemedit", "number,name", new QFilter[]{nameQFilterAccItem}); insertRow.set(EXPENSE_ITEM,dynamicObjectAccItem); this.getModel().createNewEntryRow(EXPENSE_ENTRY_ENTITY,insertRow); + } } } diff --git a/code/zcdev/zcgj-zcdev-zcdev-fs/src/main/java/zcgj/zcdev/zcdev/fs/plugin/form/PublicreimbursebillPlugin.java b/code/zcdev/zcgj-zcdev-zcdev-fs/src/main/java/zcgj/zcdev/zcdev/fs/plugin/form/PublicreimbursebillPlugin.java index 5d324d0..f32e2da 100644 --- a/code/zcdev/zcgj-zcdev-zcdev-fs/src/main/java/zcgj/zcdev/zcdev/fs/plugin/form/PublicreimbursebillPlugin.java +++ b/code/zcdev/zcgj-zcdev-zcdev-fs/src/main/java/zcgj/zcdev/zcdev/fs/plugin/form/PublicreimbursebillPlugin.java @@ -6,6 +6,8 @@ import kd.bos.dataentity.entity.DynamicObject; import kd.bos.dataentity.entity.DynamicObjectCollection; import kd.bos.entity.datamodel.ListSelectedRow; import kd.bos.entity.datamodel.ListSelectedRowCollection; +import kd.bos.entity.datamodel.events.ChangeData; +import kd.bos.entity.datamodel.events.PropertyChangedArgs; import kd.bos.form.CloseCallBack; import kd.bos.form.ShowFormHelper; import kd.bos.form.events.ClosedCallBackEvent; @@ -21,7 +23,9 @@ import kd.bos.logging.LogFactory; import kd.bos.orm.query.QCP; import kd.bos.orm.query.QFilter; import kd.bos.servicehelper.BusinessDataServiceHelper; +import kd.bos.tree.TreeFilterParameter; import kd.sdk.plugin.Plugin; +import org.apache.commons.lang3.StringUtils; import java.util.ArrayList; import java.util.EventObject; @@ -68,38 +72,65 @@ public class PublicreimbursebillPlugin extends AbstractBillPlugIn implements Plu fieldEditExpense.addAfterF7SelectListener(this); } + @Override + public void propertyChanged(PropertyChangedArgs e) { + super.propertyChanged(e); + String name = e.getProperty().getName(); + if(name.equals(ACCOUNT_ITEM)){ + ChangeData[] changeSet = e.getChangeSet(); + DynamicObject dynamicObject = (DynamicObject)changeSet[0].getNewValue(); + System.out.println(); + //Object fh = String.valueOf(dynamicObject.get(8)); + //this.getModel().setValue("ooo0_remark",fh); + } + } + @Override public void afterF7Select(AfterF7SelectEvent afterF7SelectEvent) { String name = ((BasedataEdit) afterF7SelectEvent.getSource()).getKey(); if(ACCOUNT_ITEM.equals(name)){ - String id = (String) afterF7SelectEvent.getInputValue(); - QFilter nameQFilter = new QFilter(prefix+"_accounts",QCP.equals,Long.valueOf(id)); - DynamicObject dynamicObject1 = BusinessDataServiceHelper.loadSingle(MAP_TABLE, "createorg,zcgj_entryentity,zcgj_entryentity.zcgj_entity_items", new QFilter[]{nameQFilter}); - Object value = this.getModel().getValue(EXPENSE_ITEM, selectRow); - if(value == null && dynamicObject1!=null&&selectRow!=null){ - DynamicObjectCollection zcgjEntryentity = (DynamicObjectCollection) dynamicObject1.get(MAP_ENTRY_ENTITY); - if(zcgjEntryentity!=null){ - DynamicObject dynamicObject = zcgjEntryentity.get(0); - DynamicObject itemDynamicObject= dynamicObject.getDynamicObject(prefix+"_entity_items"); - long aLong = itemDynamicObject.getLong("id"); - System.out.println(); - this.getModel().setValue(EXPENSE_ITEM,aLong,selectRow); - }else{ - // this.getModel().setValue(EXPENSE_ITEM,null,index); + Long id = null; + // 获取选中行 + ListSelectedRow selectRowList = afterF7SelectEvent.getListSelectedRow(); + Object inputValue = afterF7SelectEvent.getInputValue(); + if(selectRowList != null){//弹框选择 + id = (Long) selectRowList.getPrimaryKeyValue(); + }else if(inputValue != null){//模糊查询 + id=Long.valueOf(inputValue.toString()); + } + if(id!=null){ + QFilter nameQFilter = new QFilter(prefix+"_accounts",QCP.equals,id); + DynamicObject dynamicObject1 = BusinessDataServiceHelper.loadSingle(MAP_TABLE, "createorg,zcgj_entryentity,zcgj_entryentity.zcgj_entity_items", new QFilter[]{nameQFilter}); + DynamicObject dynamicObject2 = this.getModel().getDataEntity(true).getDynamicObjectCollection("expenseentryentity").get(selectRow); + boolean isEx = false; + if(dynamicObject2!=null){ + isEx = dynamicObject2.get(EXPENSE_ITEM) == null; + } + if(isEx && dynamicObject1!=null&&selectRow!=null){ + DynamicObjectCollection zcgjEntryentity = (DynamicObjectCollection) dynamicObject1.get(MAP_ENTRY_ENTITY); + if(zcgjEntryentity!=null){ + DynamicObject dynamicObject = zcgjEntryentity.get(0); + DynamicObject itemDynamicObject= dynamicObject.getDynamicObject(prefix+"_entity_items"); + long aLong = itemDynamicObject.getLong("id"); + System.out.println(); + this.getModel().setValue(EXPENSE_ITEM,aLong,selectRow); + } } - }else{ - //this.getModel().setValue(EXPENSE_ITEM,null,index); } }else if(EXPENSE_ITEM.equals(name)){ - String id = (String) afterF7SelectEvent.getInputValue(); - QFilter nameQFilter = new QFilter(prefix+"_entryentity.zcgj_entity_items.id", QCP.equals,Long.valueOf(id)); - DynamicObject[] load = BusinessDataServiceHelper.load(MAP_TABLE, "createorg,zcgj_accounts", new QFilter[]{nameQFilter}); - Object value = this.getModel().getValue(ACCOUNT_ITEM, selectRow); - if(value==null && load!=null && load.length>0){ - DynamicObject dynamicObject = load[0]; - long aLong = dynamicObject.getLong("zcgj_accounts_id"); - this.getModel().setValue(ACCOUNT_ITEM,aLong,selectRow); + Object inputValue = afterF7SelectEvent.getInputValue(); + if(inputValue!=null){ + String id = String.valueOf(inputValue) ; + QFilter nameQFilter = new QFilter(prefix+"_entryentity.zcgj_entity_items.id", QCP.equals,Long.valueOf(id)); + DynamicObject[] load = BusinessDataServiceHelper.load(MAP_TABLE, "createorg,zcgj_accounts", new QFilter[]{nameQFilter}); + Object value = this.getModel().getValue(ACCOUNT_ITEM, selectRow); + if(value==null && load!=null && load.length>0){ + DynamicObject dynamicObject = load[0]; + long aLong = dynamicObject.getLong("zcgj_accounts_id"); + this.getModel().setValue(ACCOUNT_ITEM,aLong,selectRow); + } } + } } @@ -108,20 +139,36 @@ public class PublicreimbursebillPlugin extends AbstractBillPlugIn implements Plu public void beforeF7Select(BeforeF7SelectEvent arg0) { String name = arg0.getProperty().getName(); if(name.equals(ACCOUNT_ITEM)){ - if("click".equals(arg0.getSourceMethod())){ + selectRow = arg0.getRow(); + /*if("click".equals(arg0.getSourceMethod())){ arg0.setCancel(true); Object value = this.getModel().getValue("zcgj_accounttable_number"); + DynamicObject costcompany = (DynamicObject)this.getModel().getValue("costcompany"); + long costcompanyId = costcompany.getLong("id"); + //((ListShowParameter)beforeF7SelectEvent.getFormShowParameter()).getTreeFilterParameter().getQFilters().add(new QFilter("name", "=", "长度")) //设置自定义F7弹框,增加过滤条件 List qFilterList = new ArrayList(); qFilterList.add(new QFilter("accounttable.number", QCP.equals,value)); + //qFilterList.add(new QFilter("createorg", QCP.equals,Long.parseLong(costcompanyId+""))); ListFilterParameter listFilterParameter =new ListFilterParameter(qFilterList,null); ListShowParameter showParameter = ShowFormHelper.createShowListForm("bd_accountview", true); showParameter.setCloseCallBack(new CloseCallBack(this,ACTION_ID)); showParameter.setListFilterParameter(listFilterParameter); + + List qFilterList1 = new ArrayList(); + qFilterList1.add(new QFilter("accounttable.number", QCP.equals,value)); + TreeFilterParameter treeFilterParameter = new TreeFilterParameter(); + treeFilterParameter.setQFilters(qFilterList1); + showParameter.setTreeFilterParameter(treeFilterParameter); + this.getView().showForm(showParameter); }else if("setItemByIdFromClient".equals(arg0.getSourceMethod()) ){ selectRow = arg0.getRow(); ((BasedataEdit) arg0.getSource()).addAfterF7SelectListener(this); + }*/ + if("setItemByIdFromClient".equals(arg0.getSourceMethod()) ){ + selectRow = arg0.getRow(); + ((BasedataEdit) arg0.getSource()).addAfterF7SelectListener(this); } }else if(name.equals(EXPENSE_ITEM)){ if("click".equals(arg0.getSourceMethod())){ @@ -143,7 +190,7 @@ public class PublicreimbursebillPlugin extends AbstractBillPlugIn implements Plu Object returnData = closedCallBackEvent.getReturnData(); boolean current= true; - if(returnData!=null && actionId.equals(ACTION_ID)){ + /*if(returnData!=null && actionId.equals(ACTION_ID)){ //获取选中的索引 int index = this.getModel().getEntryCurrentRowIndex(EXPENSE_ENTRY_ENTITY); //操作的行数据,获取之前的数据 @@ -202,7 +249,8 @@ public class PublicreimbursebillPlugin extends AbstractBillPlugIn implements Plu } } - }else if(returnData!=null && actionId.equals(ACTION_ID_EXPENSE)){ + }else*/ + if(returnData!=null && actionId.equals(ACTION_ID_EXPENSE)){ //获取选中的索引 int index = this.getModel().getEntryCurrentRowIndex(EXPENSE_ENTRY_ENTITY); //操作的行数据,获取之前的数据 @@ -230,21 +278,21 @@ public class PublicreimbursebillPlugin extends AbstractBillPlugIn implements Plu } current = false; }else{ - Object accountItem = this.getModel().getValue(ACCOUNT_ITEM, index); - if(accountItem == null){ - QFilter nameQFilter = new QFilter(prefix+"_entryentity.zcgj_entity_items.id", QCP.equals,listSelectedRow.getPrimaryKeyValue()); - DynamicObject[] load = BusinessDataServiceHelper.load(MAP_TABLE, "createorg,zcgj_accounts", new QFilter[]{nameQFilter}); - if(load!=null && load.length>0){ - DynamicObject dynamicObject = load[0]; - DynamicObject zcgjAccounts = dynamicObject.getDynamicObject("zcgj_accounts"); - if(zcgjAccounts!=null){ - //会计科目 - insertRow.set(ACCOUNT_ITEM,zcgjAccounts); - } - }else{ - insertRow.set(ACCOUNT_ITEM,null); + //Object accountItem = this.getModel().getValue(ACCOUNT_ITEM, index); + //if(accountItem == null){ + QFilter nameQFilter = new QFilter(prefix+"_entryentity.zcgj_entity_items.id", QCP.equals,listSelectedRow.getPrimaryKeyValue()); + DynamicObject[] load = BusinessDataServiceHelper.load(MAP_TABLE, "createorg,zcgj_accounts", new QFilter[]{nameQFilter}); + if(load!=null && load.length>0){ + DynamicObject dynamicObject = load[0]; + DynamicObject zcgjAccounts = dynamicObject.getDynamicObject("zcgj_accounts"); + if(zcgjAccounts!=null){ + //会计科目 + insertRow.set(ACCOUNT_ITEM,zcgjAccounts); } + }else{ + insertRow.set(ACCOUNT_ITEM,null); } + //} //费用项目科目 QFilter nameQFilterAccItem = new QFilter("id",QCP.equals,listSelectedRow.getPrimaryKeyValue()); DynamicObject dynamicObjectAccItem = BusinessDataServiceHelper.loadSingle("er_expenseitemedit", "number,name", new QFilter[]{nameQFilterAccItem}); diff --git a/code/zcdev/zcgj-zcdev-zcdev-fs/src/main/java/zcgj/zcdev/zcdev/fs/plugin/form/TripreimbursebillPlugin.java b/code/zcdev/zcgj-zcdev-zcdev-fs/src/main/java/zcgj/zcdev/zcdev/fs/plugin/form/TripreimbursebillPlugin.java new file mode 100644 index 0000000..76ef8e8 --- /dev/null +++ b/code/zcdev/zcgj-zcdev-zcdev-fs/src/main/java/zcgj/zcdev/zcdev/fs/plugin/form/TripreimbursebillPlugin.java @@ -0,0 +1,76 @@ +package zcgj.zcdev.zcdev.fs.plugin.form; + +import kd.bos.bill.AbstractBillPlugIn; +import kd.bos.dataentity.entity.DynamicObject; +import kd.bos.dataentity.entity.DynamicObjectCollection; +import kd.bos.entity.datamodel.IDataModel; +import kd.bos.entity.operate.Submit; +import kd.bos.form.events.BeforeDoOperationEventArgs; +import kd.bos.logging.Log; +import kd.bos.logging.LogFactory; +import kd.sdk.plugin.Plugin; + +import java.math.BigDecimal; + +/** + * 差旅报销单插件 + */ +public class TripreimbursebillPlugin extends AbstractBillPlugIn implements Plugin { + + private static final Log log = LogFactory.getLog(TripreimbursebillPlugin.class); + //开发商标识 + private static final String prefix ="zcgj"; + + @Override + public void beforeDoOperation(BeforeDoOperationEventArgs args) { + if((args.getSource() instanceof Submit) ){ + Submit source = (Submit)args.getSource(); + if(source.getOperateKey().equals("submit") ){ + //highseasontripstdshow + //提交时校验附件是否必填 + IDataModel model = this.getModel(); + String zsKey = String.valueOf(model.getValue("zcgj_zs_key")); + boolean isfloating20 = Boolean.parseBoolean(model.getValue("zcgj_isfloating20")+""); + + //获取当前费用为住宿的 + DynamicObjectCollection tripentryCollection = model.getEntryEntity("tripentry"); + //tripentry.get(0).getDynamicObjectCollection("entryentity").get(2).getDynamicObject("expenseitem").getString("number"); + for (DynamicObject tripentry : tripentryCollection) { + DynamicObjectCollection entryentityCollection = tripentry.getDynamicObjectCollection("entryentity"); + for (DynamicObject entryentity : entryentityCollection) { + DynamicObject expenseitem = entryentity.getDynamicObject("expenseitem"); + String zsNumber = expenseitem.getString("number"); + if(zsKey.equals(zsNumber)){ + BigDecimal orientryamount = entryentity.getBigDecimal("orientryamount");//报销金额 + BigDecimal tripstandardamount = entryentity.getBigDecimal("tripstandardamount");//差旅标准金额 + Integer caldaycount = entryentity.getInt("caldaycount");//标准天数 + //如果选择了上浮20%,则按照上浮20%进行判断 + if(isfloating20){ + BigDecimal multiply = tripstandardamount.multiply(new BigDecimal("1.2")).multiply(new BigDecimal(caldaycount)); + //-1表示小于,0是等于,1是大于 + if(orientryamount.compareTo(multiply) > 0){ + this.getView().showTipNotification("报销住宿超出标准!(上浮20%)"); + //取消提交操作 + args.setCancel(true); + } + }else{ + BigDecimal multiply = tripstandardamount.multiply(new BigDecimal(caldaycount)); + //-1表示小于,0是等于,1是大于 + if(orientryamount.compareTo(multiply) > 0){ + this.getView().showTipNotification("报销住宿超出标准!"); + //取消提交操作 + args.setCancel(true); + } + } + } + } + + } + + //获取当前差旅标准 + /* Object value = model.getValue("tripstandardamount"); + this.getView().showTipNotification(value+"");*/ + } + } + } +}