费用项目与会计科目映射配置
This commit is contained in:
parent
43687bf827
commit
e076419ead
|
@ -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);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue