From e076419ead4c2e3b33ab5528813e8f15228b8202 Mon Sep 17 00:00:00 2001 From: zhangzhiguo <17621308561@163.com> Date: Thu, 5 Dec 2024 20:02:32 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B4=B9=E7=94=A8=E9=A1=B9=E7=9B=AE=E4=B8=8E?= =?UTF-8?q?=E4=BC=9A=E8=AE=A1=E7=A7=91=E7=9B=AE=E6=98=A0=E5=B0=84=E9=85=8D?= =?UTF-8?q?=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../form/PublicreimbursebillPlugin.java | 129 ++++++++++++++++++ 1 file changed, 129 insertions(+) create mode 100644 code/zcdev/zcgj-zcdev-zcdev-fs/src/main/java/zcgj/zcdev/zcdev/fs/plugin/form/PublicreimbursebillPlugin.java 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 new file mode 100644 index 0000000..21a5093 --- /dev/null +++ b/code/zcdev/zcgj-zcdev-zcdev-fs/src/main/java/zcgj/zcdev/zcdev/fs/plugin/form/PublicreimbursebillPlugin.java @@ -0,0 +1,129 @@ +package zcgj.zcdev.zcdev.fs.plugin.form; + +import kd.bos.bill.AbstractBillPlugIn; +import kd.bos.dataentity.entity.CloneUtils; +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.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.BeforeF7SelectEvent; +import kd.bos.form.field.events.BeforeF7SelectListener; +import kd.bos.list.ListShowParameter; +import kd.bos.logging.Log; +import kd.bos.logging.LogFactory; +import kd.bos.orm.query.QCP; +import kd.bos.orm.query.QFilter; +import kd.bos.servicehelper.BusinessDataServiceHelper; +import kd.sdk.plugin.Plugin; + +import java.util.EventObject; + +/** + * 对公报销单插件 + */ +public class PublicreimbursebillPlugin extends AbstractBillPlugIn implements Plugin, BeforeF7SelectListener { + + private static final Log log = LogFactory.getLog(PublicreimbursebillPlugin.class); + //开发商标识 + private static final String prefix ="zcgj"; + + //界面回调标识(自定义) + private final static String ACTION_ID="accountview_form"; + //费用报销单的费用明细标识 + private final static String EXPENSE_ENTRY_ENTITY = "expenseentryentity"; + //会计科目与费用项目映射表分录 + private final static String MAP_TABLE = "zcgj_accountsitemsmap"; + //会计科目与费用项目映射表分录标识 + private final static String MAP_ENTRY_ENTITY = "zcgj_entryentity"; + + //对公报销中的费用项目标识 + private final static String EXPENSE_ITEM ="expenseitem"; + //对公报销中的会计科目标识 + private final static String ACCOUNT_ITEM ="zcgj_account_item"; + + + @Override + public void registerListener(EventObject e) { + super.registerListener(e); + BasedataEdit fieldEdit = this.getView().getControl(ACCOUNT_ITEM); + fieldEdit.addBeforeF7SelectListener(this); + } + + @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); + } + } + + @Override + public void closedCallBack(ClosedCallBackEvent closedCallBackEvent) { + super.closedCallBack(closedCallBackEvent); + String actionId = closedCallBackEvent.getActionId(); + Object returnData = closedCallBackEvent.getReturnData(); + boolean current= true; + + if(returnData!=null && actionId.equals(ACTION_ID)){ + //获取选中的索引 + 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){ + //选择行进行更改,其他行进行插入 + //给会计科目赋值 + 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); + }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); + } + }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); + + } + } + } + } + +}