工程进度表分录拆分
This commit is contained in:
parent
eebd9c6b40
commit
e6d569774c
|
@ -0,0 +1,81 @@
|
|||
package shkd.repc.recon.formplugin;
|
||||
|
||||
import kd.bos.dataentity.entity.DynamicObject;
|
||||
import kd.bos.dataentity.entity.DynamicObjectCollection;
|
||||
import kd.bos.dataentity.utils.OrmUtils;
|
||||
import kd.bos.dataentity.utils.StringUtils;
|
||||
import kd.bos.entity.datamodel.RowDataEntity;
|
||||
import kd.bos.entity.datamodel.events.AfterAddRowEventArgs;
|
||||
import kd.bos.form.events.AfterDoOperationEventArgs;
|
||||
import kd.bos.form.events.BeforeDoOperationEventArgs;
|
||||
import kd.bos.form.operate.FormOperate;
|
||||
import kd.bos.form.plugin.AbstractFormPlugin;
|
||||
import kd.bos.servicehelper.BusinessDataServiceHelper;
|
||||
import kd.bos.servicehelper.operation.SaveServiceHelper;
|
||||
import kd.sdk.plugin.Plugin;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 动态表单插件
|
||||
*/
|
||||
public class ProjectProgressBillPlugin extends AbstractFormPlugin implements Plugin {
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
*将分录拆分成表单
|
||||
*/
|
||||
@Override
|
||||
public void beforeDoOperation(BeforeDoOperationEventArgs args) {
|
||||
super.beforeDoOperation(args);
|
||||
FormOperate source = (FormOperate) args.getSource();
|
||||
String operateKey = source.getOperateKey();
|
||||
if ("save".equals(operateKey)){
|
||||
DynamicObjectCollection entryEntity = this.getView().getModel().getEntryEntity("qeug_entryentity");
|
||||
if (null!=entryEntity&&entryEntity.size()>1){
|
||||
// 从倒数第二条开始循环,到第一条
|
||||
for (int i = entryEntity.size() - 1; i >= 0; i--) {
|
||||
if (i == 0) {
|
||||
break; // 退出循环
|
||||
}
|
||||
//拆分
|
||||
DynamicObject projectProgress = BusinessDataServiceHelper.newDynamicObject("qeug_projectprogress");
|
||||
DynamicObjectCollection entry = projectProgress.getDynamicObjectCollection("qeug_entryentity");
|
||||
DynamicObject cloneTargetTrip = (DynamicObject) OrmUtils.clone(entryEntity.get(i), false, true);
|
||||
entry.add(cloneTargetTrip);
|
||||
SaveServiceHelper.save(new DynamicObject[]{projectProgress});
|
||||
this.getModel().deleteEntryRow("qeug_entryentity", i);
|
||||
}
|
||||
this.getView().showMessage("数据已拆分显示,请退出查看!");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void afterAddRow(AfterAddRowEventArgs e) {
|
||||
super.afterAddRow(e);
|
||||
if (StringUtils.equals("qeug_entryentity",e.getEntryProp().getName())){
|
||||
RowDataEntity[] rowDataEntities = e.getRowDataEntities();
|
||||
for (int i = 0; i < rowDataEntities.length; i++) {
|
||||
RowDataEntity rowDataEntity = rowDataEntities[i];
|
||||
int rowIndex = rowDataEntity.getRowIndex();
|
||||
int number=rowIndex+1;
|
||||
this.getModel().setValue("qeug_number","GCJD-"+getNumber()+"-"+number,rowIndex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public String getNumber(){
|
||||
Date currentDate = new Date();
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd");
|
||||
|
||||
return sdf.format(currentDate);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue