一、GUI DEP在编辑界面和序时簿界面的操作-附件管理中增加前置脚本即可。
1、通过DEP在编辑界面-操作-附件管理中增加前置脚本
var imp = JavaImporter();
imp.importPackage(Packages.com.kingdee.eas.base.attachment.common);
imp.importPackage(Packages.com.kingdee.eas.scm.common);
with(imp){
var acm = AttachmentManagerFactory.getClientManager();
var editData = pluginCtx.getDataObject();//获取当前界面对象
if (BillBaseStatusEnum.ADD.equals(editData.getBaseStatus())) {
//新增状态不要处理走原逻辑
} else {
var boID = editData.getId() != null? editData.getId().toString() : null;
if (BillBaseStatusEnum.TEMPORARILYSAVED.equals(editData.getBaseStatus())){//保存
acm.showAttachmentListUIByBoID(boID, this,
true, //是否允许新增
true, //是否允许删除
true); //是否允许编辑
} else if(BillBaseStatusEnum.SUBMITED.equals(editData.getBaseStatus())){//提交
acm.showAttachmentListUIByBoID(boID, this,
true, //是否允许新增
true, //是否允许删除
true); //是否允许编辑
}else if(BillBaseStatusEnum.AUDITED.equals(editData.getBaseStatus())){//审核
acm.showAttachmentListUIByBoID(boID, this,
true, //是否允许新增
false, //是否允许删除
false); //是否允许编辑
}else if(BillBaseStatusEnum.CLOSED.equals(editData.getBaseStatus())){//关闭
acm.showAttachmentListUIByBoID(boID, this,
true, //是否允许新增
false, //是否允许删除
false); //是否允许编辑
}else{//默认
acm.showAttachmentListUIByBoID(boID, this,
true, //是否允许新增
false, //是否允许删除
false); //是否允许编辑
}
com.kingdee.eas.util.SysUtil.abort(); //直接中断原逻辑处理
}
}
2、通过DEP在序时簿界面-操作-附件管理中增加前置脚本
var imp = JavaImporter();
imp.importPackage(Packages.com.kingdee.eas.base.attachment.common);
imp.importPackage(Packages.com.kingdee.eas.scm.common);
with(imp){
var acm = AttachmentManagerFactory.getClientManager();
var table = pluginCtx.getKDTable("tblMain");
//获取选择单据ID
var selectRows = com.kingdee.bos.ctrl.kdf.table.util.KDTableUtil.getSelectedRows(table);
var boID =com.kingdee.eas.framework.client.ListUiHelper.getSelectedKeyValue(selectRows,table,"id");
if (table.getRowCount() == 0 || table.getSelectManager().size() == 0)
{
com.kingdee.eas.util.client.MsgBox.showWarning("请先选中分录行");
com.kingdee.eas.util.SysUtil.abort();
}
if (boID == null) {
com.kingdee.eas.util.SysUtil.abort();
}
//获取当前单据信息(不同单据需用不同接口取值)
var scmInfo = com.kingdee.eas.scm.im.inv.PurInWarehsBillFactory.getRemoteInstance().getPurInWarehsBillInfo("select baseStatus where id ='" + boID + "'");
if (BillBaseStatusEnum.TEMPORARILYSAVED.equals(scmInfo.getBaseStatus())){//保存
acm.showAttachmentListUIByBoID(boID, this,
true, //是否允许新增
true, //是否允许删除
true); //是否允许编辑
} else if(BillBaseStatusEnum.SUBMITED.equals(scmInfo.getBaseStatus())){//提交
acm.showAttachmentListUIByBoID(boID, this,
true, //是否允许新增
true, //是否允许删除
true); //是否允许编辑
}else if(BillBaseStatusEnum.AUDITED.equals(scmInfo.getBaseStatus())){//审核
acm.showAttachmentListUIByBoID(boID, this,
true, //是否允许新增
false, //是否允许删除
false); //是否允许编辑
}else if(BillBaseStatusEnum.CLOSED.equals(scmInfo.getBaseStatus())){//关闭
acm.showAttachmentListUIByBoID(boID, this,
true, //是否允许新增
false, //是否允许删除
false); //是否允许编辑
}else{//默认
acm.showAttachmentListUIByBoID(boID, this,
true, //是否允许新增
false, //是否允许删除
false); //是否允许编辑
}
com.kingdee.eas.util.SysUtil.abort();
}
二、通过DEP脚本判断单据在工作流和非工作流状态时附件是否允许编辑;
1、在编辑界面-操作-附件管理的前置脚本中添加如下内容
var imp = JavaImporter();
imp.importPackage(Packages.com.kingdee.eas.base.attachment.common);
imp.importPackage(Packages.com.kingdee.eas.scm.common);
with(imp){
var acm = AttachmentManagerFactory.getClientManager();
var editData = pluginCtx.getDataObject();//获取当前界面对象
if (BillBaseStatusEnum.ADD.equals(editData.getBaseStatus())) {
//新增状态不要处理走原逻辑
} else {
var boID = editData.getId() != null? editData.getId().toString() : null;
//获取单据是否在工作流中
var idArr = [boID];
var isinWorkFlow = com.kingdee.eas.scm.common.SCMBillCommonFacadeFactory.getRemoteInstance().getIsBillMultiapprove(idArr);
if (BillBaseStatusEnum.TEMPORARILYSAVED.equals(editData.getBaseStatus())){//保存
acm.showAttachmentListUIByBoID(boID, this,
true, //是否允许新增
true, //是否允许删除
true); //是否允许编辑
} else if(BillBaseStatusEnum.SUBMITED.equals(editData.getBaseStatus())){//提交
if(isinWorkFlow){//如果在工作流中
acm.showAttachmentListUIByBoID(boID, this,
false, //是否允许新增
false, //是否允许删除
false); //是否允许编辑
}else{
acm.showAttachmentListUIByBoID(boID, this,
true, //是否允许新增
true, //是否允许删除
true); //是否允许编辑
}
}else if(BillBaseStatusEnum.AUDITED.equals(editData.getBaseStatus())){//审核
acm.showAttachmentListUIByBoID(boID, this,
true, //是否允许新增
false, //是否允许删除
false); //是否允许编辑
}else if(BillBaseStatusEnum.CLOSED.equals(editData.getBaseStatus())){//关闭
acm.showAttachmentListUIByBoID(boID, this,
true, //是否允许新增
false, //是否允许删除
false); //是否允许编辑
}else{//默认
acm.showAttachmentListUIByBoID(boID, this,
true, //是否允许新增
false, //是否允许删除
false); //是否允许编辑
}
com.kingdee.eas.util.SysUtil.abort(); //直接中断原逻辑处理
}
}
2、在序时簿-操作-附件管理的前置脚本中添加如下内容:
var imp = JavaImporter();
imp.importPackage(Packages.com.kingdee.eas.base.attachment.common);
imp.importPackage(Packages.com.kingdee.eas.scm.common);
with(imp){
var acm = AttachmentManagerFactory.getClientManager();
var table = pluginCtx.getKDTable("tblMain");
//获取选择单据ID
var selectRows = com.kingdee.bos.ctrl.kdf.table.util.KDTableUtil.getSelectedRows(table);
var boID =com.kingdee.eas.framework.client.ListUiHelper.getSelectedKeyValue(selectRows,table,"id");
if (table.getRowCount() == 0 || table.getSelectManager().size() == 0)
{
com.kingdee.eas.util.client.MsgBox.showWarning("请先选中分录行");
com.kingdee.eas.util.SysUtil.abort();
}
if (boID == null) {
com.kingdee.eas.util.SysUtil.abort();
}
//获取当前单据信息(不同单据需用不同接口取值)
var scmInfo = com.kingdee.eas.scm.im.inv.PurInWarehsBillFactory.getRemoteInstance().getPurInWarehsBillInfo("select baseStatus where id ='" + boID + "'");
//获取单据是否在工作流中
var idArr = [boID];
var isinWorkFlow = com.kingdee.eas.scm.common.SCMBillCommonFacadeFactory.getRemoteInstance().getIsBillMultiapprove(idArr);
if (BillBaseStatusEnum.TEMPORARILYSAVED.equals(scmInfo.getBaseStatus())){//保存
acm.showAttachmentListUIByBoID(boID, this,
true, //是否允许新增
true, //是否允许删除
true); //是否允许编辑
} else if(BillBaseStatusEnum.SUBMITED.equals(scmInfo.getBaseStatus())){//提交
if(isinWorkFlow){//如果在工作流中
acm.showAttachmentListUIByBoID(boID, this,
false, //是否允许新增
false, //是否允许删除
false); //是否允许编辑
}else{
acm.showAttachmentListUIByBoID(boID, this,
true, //是否允许新增
true, //是否允许删除
true); //是否允许编辑
}
}else if(BillBaseStatusEnum.AUDITED.equals(scmInfo.getBaseStatus())){//审核
acm.showAttachmentListUIByBoID(boID, this,
true, //是否允许新增
false, //是否允许删除
false); //是否允许编辑
}else if(BillBaseStatusEnum.CLOSED.equals(scmInfo.getBaseStatus())){//关闭
acm.showAttachmentListUIByBoID(boID, this,
true, //是否允许新增
false, //是否允许删除
false); //是否允许编辑
}else{//默认
acm.showAttachmentListUIByBoID(boID, this,
true, //是否允许新增
false, //是否允许删除
false); //是否允许编辑
}
com.kingdee.eas.util.SysUtil.abort();
}
推荐阅读