费用报销和对公报销费用项目和会计科目关联

This commit is contained in:
zhangzhiguo 2024-12-09 10:44:55 +08:00
parent a2782869eb
commit f229e5b383
2 changed files with 312 additions and 57 deletions

View File

@ -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<QFilter> qFilterList = new ArrayList<QFilter>();
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);
}
}
}

View File

@ -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<QFilter> qFilterList = new ArrayList<QFilter>();
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);
}
}
}