From f229e5b383108f650f6ec4826621aa2471757178 Mon Sep 17 00:00:00 2001 From: zhangzhiguo <17621308561@163.com> Date: Mon, 9 Dec 2024 10:44:55 +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 | 183 ++++++++++++++--- .../form/PublicreimbursebillPlugin.java | 186 +++++++++++++++--- 2 files changed, 312 insertions(+), 57 deletions(-) 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 77c1292..8cbda3e 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 @@ -9,14 +9,16 @@ import kd.bos.dataentity.entity.DynamicObjectCollection; import kd.bos.entity.datamodel.IDataModel; 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.entity.operate.Submit; import kd.bos.form.CloseCallBack; import kd.bos.form.ShowFormHelper; import kd.bos.form.events.BeforeDoOperationEventArgs; import kd.bos.form.events.ClosedCallBackEvent; import kd.bos.form.field.BasedataEdit; -import kd.bos.form.field.events.BeforeF7SelectEvent; -import kd.bos.form.field.events.BeforeF7SelectListener; +import kd.bos.form.field.events.*; +import kd.bos.list.ListFilterParameter; import kd.bos.list.ListShowParameter; import kd.bos.logging.Log; import kd.bos.logging.LogFactory; @@ -32,19 +34,22 @@ import java.time.Month; import java.time.ZoneId; import java.time.temporal.ChronoUnit; import java.time.temporal.TemporalAdjusters; +import java.util.ArrayList; import java.util.Date; import java.util.EventObject; +import java.util.List; /** * 费用报销单探亲检查插件 */ -public class DailyreimbursPlugin extends AbstractBillPlugIn implements Plugin, BeforeF7SelectListener { +public class DailyreimbursPlugin extends AbstractBillPlugIn implements Plugin, BeforeF7SelectListener, AfterF7SelectListener { private static final Log log = LogFactory.getLog(DailyreimbursPlugin.class); //开发商标识 private static final String prefix ="zcgj"; //界面回调标识(自定义) private final static String ACTION_ID="accountview_form"; + private final static String ACTION_ID_EXPENSE="expenseitem_form"; //费用报销单的费用明细标识 private final static String EXPENSE_ENTRY_ENTITY = "expenseentryentity"; //会计科目与费用项目映射表分录 @@ -57,6 +62,9 @@ public class DailyreimbursPlugin extends AbstractBillPlugIn implements Plugin, //费用报销中的会计科目标识 private final static String ACCOUNT_ITEM ="zcgj_account_item"; + //分录值改变的行号 + private static Integer selectRow = null; + @Override public void beforeDoOperation(BeforeDoOperationEventArgs args) { try{ @@ -296,18 +304,80 @@ public class DailyreimbursPlugin extends AbstractBillPlugIn implements Plugin, super.registerListener(e); BasedataEdit fieldEdit = this.getView().getControl(ACCOUNT_ITEM); fieldEdit.addBeforeF7SelectListener(this); + + BasedataEdit fieldEditExpense = this.getView().getControl(EXPENSE_ITEM); + fieldEditExpense.addBeforeF7SelectListener(this); + fieldEditExpense.addAfterF7SelectListener(this); + } + @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); + } + }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); + } + } + + } @Override public void beforeF7Select(BeforeF7SelectEvent arg0) { String name = arg0.getProperty().getName(); if(name.equals(ACCOUNT_ITEM)){ - arg0.setCancel(true); - ListShowParameter showParameter = ShowFormHelper.createShowListForm("bd_accountview", true); - showParameter.setCloseCallBack(new CloseCallBack(this,ACTION_ID)); - this.getView().showForm(showParameter); + if("click".equals(arg0.getSourceMethod())){ + arg0.setCancel(true); + Object value = this.getModel().getValue("zcgj_accounttable_number"); + //设置自定义F7弹框,增加过滤条件 + List qFilterList = new ArrayList(); + qFilterList.add(new QFilter("accounttable.number", QCP.equals,value)); + ListFilterParameter listFilterParameter =new ListFilterParameter(qFilterList,null); + ListShowParameter showParameter = ShowFormHelper.createShowListForm("bd_accountview", true); + showParameter.setCloseCallBack(new CloseCallBack(this,ACTION_ID)); + showParameter.setListFilterParameter(listFilterParameter); + this.getView().showForm(showParameter); + }else if("setItemByIdFromClient".equals(arg0.getSourceMethod()) ){ + selectRow = arg0.getRow(); + ((BasedataEdit) arg0.getSource()).addAfterF7SelectListener(this); + } + }else if(name.equals(EXPENSE_ITEM)){ + if("click".equals(arg0.getSourceMethod())){ + arg0.setCancel(true); + ListShowParameter showParameter = ShowFormHelper.createShowListForm("er_expenseitemedit", true); + showParameter.setCloseCallBack(new CloseCallBack(this,ACTION_ID_EXPENSE)); + this.getView().showForm(showParameter); + }else if("setItemByIdFromClient".equals(arg0.getSourceMethod()) ){ + selectRow = arg0.getRow(); + ((BasedataEdit) arg0.getSource()).addAfterF7SelectListener(this); + } + } } @@ -332,42 +402,97 @@ public class DailyreimbursPlugin extends AbstractBillPlugIn implements Plugin, //选择行进行更改,其他行进行插入 //给会计科目赋值 this.getModel().setValue(ACCOUNT_ITEM,listSelectedRow.getPrimaryKeyValue(),index); - QFilter nameQFilter = new QFilter(prefix+"_accounts",QCP.equals,listSelectedRow.getPrimaryKeyValue()); - DynamicObject dynamicObject1 = BusinessDataServiceHelper.loadSingle(MAP_TABLE, "createorg,zcgj_entryentity,zcgj_entryentity.zcgj_entity_items", new QFilter[]{nameQFilter}); - if(dynamicObject1!=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"); - this.getModel().setValue(EXPENSE_ITEM,aLong,index); + Object expense = this.getModel().getValue(EXPENSE_ITEM, index); + if(expense == null){ + QFilter nameQFilter = new QFilter(prefix+"_accounts",QCP.equals,listSelectedRow.getPrimaryKeyValue()); + DynamicObject dynamicObject1 = BusinessDataServiceHelper.loadSingle(MAP_TABLE, "createorg,zcgj_entryentity,zcgj_entryentity.zcgj_entity_items", new QFilter[]{nameQFilter}); + if(dynamicObject1!=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"); + this.getModel().setValue(EXPENSE_ITEM,aLong,index); + }else{ + this.getModel().setValue(EXPENSE_ITEM,null,index); + } }else{ this.getModel().setValue(EXPENSE_ITEM,null,index); } - }else{ - this.getModel().setValue(EXPENSE_ITEM,null,index); } current = false; }else{ - QFilter nameQFilter = new QFilter(prefix+"_accounts",QCP.equals,listSelectedRow.getPrimaryKeyValue()); - DynamicObject dynamicObject1 = BusinessDataServiceHelper.loadSingle(MAP_TABLE, "createorg,zcgj_entryentity,zcgj_entryentity.zcgj_entity_items", new QFilter[]{nameQFilter}); - if(dynamicObject1!=null){ - DynamicObjectCollection zcgjEntryentity = (DynamicObjectCollection) dynamicObject1.get(MAP_ENTRY_ENTITY); - if(zcgjEntryentity!=null){ - DynamicObject dynamicObject = zcgjEntryentity.get(0); - DynamicObject itemDynamicObject= dynamicObject.getDynamicObject(prefix+"_entity_items"); - //费用项目 - insertRow.set(EXPENSE_ITEM,itemDynamicObject); + Object expense = this.getModel().getValue(EXPENSE_ITEM, index); + if(expense==null){ + QFilter nameQFilter = new QFilter(prefix+"_accounts",QCP.equals,listSelectedRow.getPrimaryKeyValue()); + DynamicObject dynamicObject1 = BusinessDataServiceHelper.loadSingle(MAP_TABLE, "createorg,zcgj_entryentity,zcgj_entryentity.zcgj_entity_items", new QFilter[]{nameQFilter}); + if(dynamicObject1!=null){ + DynamicObjectCollection zcgjEntryentity = (DynamicObjectCollection) dynamicObject1.get(MAP_ENTRY_ENTITY); + if(zcgjEntryentity!=null){ + DynamicObject dynamicObject = zcgjEntryentity.get(0); + DynamicObject itemDynamicObject= dynamicObject.getDynamicObject(prefix+"_entity_items"); + //费用项目 + insertRow.set(EXPENSE_ITEM,itemDynamicObject); + } + }else{ + insertRow.set(EXPENSE_ITEM,null); } - }else{ - insertRow.set(EXPENSE_ITEM,null); } //会计科目 QFilter nameQFilterAccItem = new QFilter("id",QCP.equals,listSelectedRow.getPrimaryKeyValue()); DynamicObject dynamicObjectAccItem = BusinessDataServiceHelper.loadSingle("bd_accountview", "number,name", new QFilter[]{nameQFilterAccItem}); insertRow.set(ACCOUNT_ITEM,dynamicObjectAccItem); this.getModel().createNewEntryRow(EXPENSE_ENTRY_ENTITY,insertRow); + } + } + }else if(returnData!=null && actionId.equals(ACTION_ID_EXPENSE)){ + //获取选中的索引 + int index = this.getModel().getEntryCurrentRowIndex(EXPENSE_ENTRY_ENTITY); + //操作的行数据,获取之前的数据 + DynamicObject selectRow = this.getModel().getEntryRowEntity(EXPENSE_ENTRY_ENTITY, index); + //克隆新的行 + DynamicObject insertRow = (DynamicObject) (new CloneUtils(false, false)).clone(selectRow); + ListSelectedRowCollection listSelectedRows = (ListSelectedRowCollection) closedCallBackEvent.getReturnData(); + for (ListSelectedRow listSelectedRow : listSelectedRows) { + if(current){ + //选择行进行更改,其他行进行插入 + Object accountItem = this.getModel().getValue(ACCOUNT_ITEM, index); + //给费用项目赋值 + this.getModel().setValue(EXPENSE_ITEM,listSelectedRow.getPrimaryKeyValue(),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]; + long aLong = dynamicObject.getLong("zcgj_accounts_id"); + this.getModel().setValue(ACCOUNT_ITEM,aLong,index); + }else{ + this.getModel().setValue(ACCOUNT_ITEM,null,index); + } + } + 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); + } + } + //费用项目科目 + 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 21a5093..5d324d0 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 @@ -10,8 +10,11 @@ import kd.bos.form.CloseCallBack; import kd.bos.form.ShowFormHelper; import kd.bos.form.events.ClosedCallBackEvent; import kd.bos.form.field.BasedataEdit; +import kd.bos.form.field.events.AfterF7SelectEvent; +import kd.bos.form.field.events.AfterF7SelectListener; import kd.bos.form.field.events.BeforeF7SelectEvent; import kd.bos.form.field.events.BeforeF7SelectListener; +import kd.bos.list.ListFilterParameter; import kd.bos.list.ListShowParameter; import kd.bos.logging.Log; import kd.bos.logging.LogFactory; @@ -20,19 +23,25 @@ import kd.bos.orm.query.QFilter; import kd.bos.servicehelper.BusinessDataServiceHelper; import kd.sdk.plugin.Plugin; +import java.util.ArrayList; import java.util.EventObject; +import java.util.List; /** * 对公报销单插件 */ -public class PublicreimbursebillPlugin extends AbstractBillPlugIn implements Plugin, BeforeF7SelectListener { +public class PublicreimbursebillPlugin extends AbstractBillPlugIn implements Plugin, BeforeF7SelectListener, AfterF7SelectListener { private static final Log log = LogFactory.getLog(PublicreimbursebillPlugin.class); //开发商标识 private static final String prefix ="zcgj"; + //会计科目科目表编码 + private final static String ACCOUNT_ACCOUNTTABLE="0003"; + //界面回调标识(自定义) private final static String ACTION_ID="accountview_form"; + private final static String ACTION_ID_EXPENSE="expenseitem_form"; //费用报销单的费用明细标识 private final static String EXPENSE_ENTRY_ENTITY = "expenseentryentity"; //会计科目与费用项目映射表分录 @@ -44,23 +53,86 @@ public class PublicreimbursebillPlugin extends AbstractBillPlugIn implements Plu private final static String EXPENSE_ITEM ="expenseitem"; //对公报销中的会计科目标识 private final static String ACCOUNT_ITEM ="zcgj_account_item"; - + //分录值改变的行号 + private static Integer selectRow = null; @Override public void registerListener(EventObject e) { 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); + fieldEditExpense.addAfterF7SelectListener(this); + } + + @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); + } + }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); + } + } + } @Override public void beforeF7Select(BeforeF7SelectEvent arg0) { String name = arg0.getProperty().getName(); if(name.equals(ACCOUNT_ITEM)){ - arg0.setCancel(true); - ListShowParameter showParameter = ShowFormHelper.createShowListForm("bd_accountview", true); - showParameter.setCloseCallBack(new CloseCallBack(this,ACTION_ID)); - this.getView().showForm(showParameter); + if("click".equals(arg0.getSourceMethod())){ + arg0.setCancel(true); + Object value = this.getModel().getValue("zcgj_accounttable_number"); + //设置自定义F7弹框,增加过滤条件 + List qFilterList = new ArrayList(); + qFilterList.add(new QFilter("accounttable.number", QCP.equals,value)); + ListFilterParameter listFilterParameter =new ListFilterParameter(qFilterList,null); + ListShowParameter showParameter = ShowFormHelper.createShowListForm("bd_accountview", true); + showParameter.setCloseCallBack(new CloseCallBack(this,ACTION_ID)); + showParameter.setListFilterParameter(listFilterParameter); + this.getView().showForm(showParameter); + }else if("setItemByIdFromClient".equals(arg0.getSourceMethod()) ){ + selectRow = arg0.getRow(); + ((BasedataEdit) arg0.getSource()).addAfterF7SelectListener(this); + } + }else if(name.equals(EXPENSE_ITEM)){ + if("click".equals(arg0.getSourceMethod())){ + arg0.setCancel(true); + ListShowParameter showParameter = ShowFormHelper.createShowListForm("er_expenseitemedit", true); + showParameter.setCloseCallBack(new CloseCallBack(this,ACTION_ID_EXPENSE)); + this.getView().showForm(showParameter); + }else if("setItemByIdFromClient".equals(arg0.getSourceMethod()) ){ + selectRow = arg0.getRow(); + ((BasedataEdit) arg0.getSource()).addAfterF7SelectListener(this); + } } } @@ -84,36 +156,43 @@ public class PublicreimbursebillPlugin extends AbstractBillPlugIn implements Plu if(current){ //选择行进行更改,其他行进行插入 //给会计科目赋值 + Object expense = this.getModel().getValue(EXPENSE_ITEM, index); this.getModel().setValue(ACCOUNT_ITEM,listSelectedRow.getPrimaryKeyValue(),index); - QFilter nameQFilter = new QFilter(prefix+"_accounts", QCP.equals,listSelectedRow.getPrimaryKeyValue()); - DynamicObject dynamicObject1 = BusinessDataServiceHelper.loadSingle(MAP_TABLE, "createorg,zcgj_entryentity,zcgj_entryentity.zcgj_entity_items", new QFilter[]{nameQFilter}); - if(dynamicObject1!=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"); - this.getModel().setValue(EXPENSE_ITEM,aLong,index); + if(expense==null){ + QFilter nameQFilter = new QFilter(prefix+"_accounts", QCP.equals,listSelectedRow.getPrimaryKeyValue()); + DynamicObject dynamicObject1 = BusinessDataServiceHelper.loadSingle(MAP_TABLE, "createorg,zcgj_entryentity,zcgj_entryentity.zcgj_entity_items", new QFilter[]{nameQFilter}); + if(dynamicObject1!=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"); + this.getModel().setValue(EXPENSE_ITEM,aLong,index); + }else{ + this.getModel().setValue(EXPENSE_ITEM,null,index); + } }else{ this.getModel().setValue(EXPENSE_ITEM,null,index); } - }else{ - this.getModel().setValue(EXPENSE_ITEM,null,index); } + current = false; }else{ - QFilter nameQFilter = new QFilter(prefix+"_accounts",QCP.equals,listSelectedRow.getPrimaryKeyValue()); - DynamicObject dynamicObject1 = BusinessDataServiceHelper.loadSingle(MAP_TABLE, "createorg,zcgj_entryentity,zcgj_entryentity.zcgj_entity_items", new QFilter[]{nameQFilter}); - if(dynamicObject1!=null){ - DynamicObjectCollection zcgjEntryentity = (DynamicObjectCollection) dynamicObject1.get(MAP_ENTRY_ENTITY); - if(zcgjEntryentity!=null){ - DynamicObject dynamicObject = zcgjEntryentity.get(0); - DynamicObject itemDynamicObject= dynamicObject.getDynamicObject(prefix+"_entity_items"); - //费用项目 - insertRow.set(EXPENSE_ITEM,itemDynamicObject); + Object expense = this.getModel().getValue(EXPENSE_ITEM, index); + if(expense==null){ + QFilter nameQFilter = new QFilter(prefix+"_accounts",QCP.equals,listSelectedRow.getPrimaryKeyValue()); + DynamicObject dynamicObject1 = BusinessDataServiceHelper.loadSingle(MAP_TABLE, "createorg,zcgj_entryentity,zcgj_entryentity.zcgj_entity_items", new QFilter[]{nameQFilter}); + if(dynamicObject1!=null){ + DynamicObjectCollection zcgjEntryentity = (DynamicObjectCollection) dynamicObject1.get(MAP_ENTRY_ENTITY); + if(zcgjEntryentity!=null){ + DynamicObject dynamicObject = zcgjEntryentity.get(0); + DynamicObject itemDynamicObject= dynamicObject.getDynamicObject(prefix+"_entity_items"); + //费用项目 + insertRow.set(EXPENSE_ITEM,itemDynamicObject); + } + }else{ + insertRow.set(EXPENSE_ITEM,null); } - }else{ - insertRow.set(EXPENSE_ITEM,null); } //会计科目 QFilter nameQFilterAccItem = new QFilter("id",QCP.equals,listSelectedRow.getPrimaryKeyValue()); @@ -121,6 +200,57 @@ public class PublicreimbursebillPlugin extends AbstractBillPlugIn implements Plu insertRow.set(ACCOUNT_ITEM,dynamicObjectAccItem); this.getModel().createNewEntryRow(EXPENSE_ENTRY_ENTITY,insertRow); + } + } + }else if(returnData!=null && actionId.equals(ACTION_ID_EXPENSE)){ + //获取选中的索引 + int index = this.getModel().getEntryCurrentRowIndex(EXPENSE_ENTRY_ENTITY); + //操作的行数据,获取之前的数据 + DynamicObject selectRow = this.getModel().getEntryRowEntity(EXPENSE_ENTRY_ENTITY, index); + //克隆新的行 + DynamicObject insertRow = (DynamicObject) (new CloneUtils(false, false)).clone(selectRow); + ListSelectedRowCollection listSelectedRows = (ListSelectedRowCollection) closedCallBackEvent.getReturnData(); + + for (ListSelectedRow listSelectedRow : listSelectedRows) { + if(current){ + //选择行进行更改,其他行进行插入 + Object accountItem = this.getModel().getValue(ACCOUNT_ITEM, index); + //给费用项目赋值 + this.getModel().setValue(EXPENSE_ITEM,listSelectedRow.getPrimaryKeyValue(),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]; + long aLong = dynamicObject.getLong("zcgj_accounts_id"); + this.getModel().setValue(ACCOUNT_ITEM,aLong,index); + }else{ + this.getModel().setValue(ACCOUNT_ITEM,null,index); + } + } + 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); + } + } + //费用项目科目 + 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); + } } }