资源描述
先看对应标准单据上的xml文件。。。
<!--======= 动作:[CloseAction] [关闭] =========== -->
<bean id="CloseAction" class="nc.ui.so.applybuylargess.ace.action.CloseAction">
<property name="model">
<ref bean="bmModel" />
</property>
<property name="editor">
<ref bean="billForm" />
</property>
<property name="exceptionHandler">
<ref bean="exceptionHandler" />
</property>
</bean>
<property name="actions">
<list>
<ref bean="addAction" />
<ref bean="editAction" />
<ref bean="deleteScriptAction" />
<ref bean="defaultQueryAction" />
<ref bean="copyAction" />
<ref bean="separatorAction" />
<ref bean="defaultRefreshAction" />
<ref bean="separatorAction" />
<ref bean="commitScriptAction" />
<ref bean="unCommitScriptAction" />
<ref bean="approveScriptAction" />
<!--ref bean="uNApproveScriptAction" />-->
<ref bean="separatorAction" />
<!-- ref bean="linkQueryAction" /> -->
<ref bean="separatorAction" />
<ref bean="metaDataBasedPrintAction" />
<ref bean="metaDataBasedPrintActiona" />
<ref bean="outputAction" />
<ref bean="separatorAction" />
<ref bean="pFApproveStatusInfoAction" />
<ref bean="CloseAction" />
</list>
</property>
接下来看对应定义新加按钮的处理
import java.awt.event.ActionEvent;
import mon.NCLocator;
import nc.desktop.ui.WorkbenchEnvironment;
import nc.itf.so.IBuyLargess;
import nc.ui.pub.beans.MessageDialog;
import nc.ui.pub.beans.UIDialog;
import nc.ui.pubapp.uif2app.AppUiState;
import nc.ui.pubapp.uif2app.model.BillManageModel;
import nc.ui.pubapp.uif2app.view.BillForm;
import nc.ui.uif2.NCAction;
import nc.vo.pub.lang.UFDateTime;
import nc.vo.pubapp.pattern.exception.ExceptionUtils;
import nc.vo.so.applybuylargess.AggApplyBuylargessVO;
import nc.vo.so.applybuylargess.ApplyBuylargessVO;
public class CloseAction extends NCAction {
private static final long serialVersionUID = -2496634582717390348L;
public CloseAction() {
super();
this.setBtnName("关闭");
this.setCode("Close");
}
@Override
public void doAction(ActionEvent e) throws Exception {
Object[] objects = model.getSelectedOperaDatas();
if (objects == null || objects.length == 0) {
ExceptionUtils.wrappBusinessException("未选中买赠设置申请单据,不能进行关闭操作!!!");
}
if (MessageDialog.showYesNoDlg(WorkbenchEnvironment.getInstance()
.getWorkbench().getParent(), "关闭", "当前是否进行关闭操作?此操作不可逆!!!") == UIDialog.ID_YES) {
// 当前对应的买赠设置申请单
AggApplyBuylargessVO aggApplyBuylargessVO = (AggApplyBuylargessVO) this
.getModel().getSelectedData();
// 定义买赠设置申请单的接口
IBuyLargess BuyLargessService = NCLocator.getInstance().lookup(
IBuyLargess.class);
// 买赠设置申请点击关闭删除之前对应的买赠设置单据
aggApplyBuylargessVO = BuyLargessService
.delBuyLargess(aggApplyBuylargessVO);
this.model.directlyUpdate(aggApplyBuylargessVO); // 刷新当前对应的AggVo
}
}
@Override
protected boolean isActionEnable() {
boolean isEnable = this.getModel().getAppUiState() == AppUiState.NOT_EDIT
&& null != this.getModel().getSelectedData();
if (isEnable) {
AggApplyBuylargessVO selectedData = (AggApplyBuylargessVO) this
.getModel().getSelectedData(); // 选中的当前买赠设置申请单
ApplyBuylargessVO applyBuylargessVo = selectedData.getParentVO(); // 买赠设置申请单表头VO
Integer billstatus = applyBuylargessVo.getFstatusflag(); // 对应买赠设置申请单据的单据状态
UFDateTime dclosetime = applyBuylargessVo.getDclosedtime(); // 买赠设置申请单的关闭时间(有对应的关闭时间,表示当前已经执行关闭)
isEnable = billstatus.equals(1) && null == dclosetime; // 返利促销申请单关闭时间要为空,表示还未生成对应的汇总单据
}
return isEnable;
}
private BillForm editor;
private BillManageModel model;
public BillForm geteditor() {
return editor;
}
public void seteditor(BillForm billForm) {
this.editor = billForm;
}
public BillManageModel getModel() {
return this.model;
}
public void setModel(BillManageModel model) {
this.model = model;
this.model.addAppEventListener(this); // 监听一定要添加进去
}
}
展开阅读全文