NC65 如何在系统单据上加自定义按钮
程序员文章站
2022-03-08 07:58:07
...
效果如下图:
供应链-->库存管理-->出库申请单 上加一个自定义按钮(关闭/打开行数据)
思路:1、新写一个配置文件 然后在出库申请单的功能注册上添加参数注册
2、通过Uap Studio下的SpringXml To Java
3、新建一个按钮类
1、新建一个配置文件:
新建包:package nc.ui.ic.m4455
把下面配置文件命名为:PluginBeanConfigFilePath.xml 把下面的内容拷贝到xml下
<?xml version="1.0" encoding="GBK"?>
<!DOCTYPE beans PUBLIC ".//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
<beans>
<!--新增按钮-->
<bean class="nc.ui.pubapp.plugin.action.InsertActionInfo">
<property name="actionContainer" ref="actionsOfCard" />
<property name="actionType" value="notedit" />
<property name="target" ref="printMngAction" />
<property name="pos" value="after" />
<property name="action" ref="closeRowNewAction" />
</bean>
<!--新增按钮-->
<bean class="nc.ui.pubapp.plugin.action.InsertActionInfo">
<property name="actionContainer" ref="actionsOfList" />
<property name="actionType" value="notedit" />
<property name="target" ref="printMngAction" />
<property name="pos" value="after" />
<property name="action" ref="closeRowNewAction" />
</bean>
<!--测试-->
<bean id="closeRowNewAction" class="nc.ui.ic.m4455.action.CloseRowNewAction">
<property name="model" ref="icBizModel" />
<property name="editor" ref="card" />
<property name="code" value="closeRowNewAction" />
</bean>
</beans>
2、功能注册下配置参数信息
如下图:
3、Uap Studio下右键新建的xml文件-->选择 SpringXml To Java
生成如下java文件
注:生成java文件之前自己定义一个按钮类 参考第四步 不然会生成失败!
package nc.ui.ic.m4455;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import nc.ui.uif2.factory.AbstractJavaBeanDefinition;
public class PluginBeanConfigFilePath extends AbstractJavaBeanDefinition {
private Map<String, Object> context = new HashMap();
public nc.ui.pubapp.plugin.action.InsertActionInfo getInsertActionInfo_0() {
if (context.get("nc.ui.pubapp.plugin.action.InsertActionInfo#0") != null)
return (nc.ui.pubapp.plugin.action.InsertActionInfo) context
.get("nc.ui.pubapp.plugin.action.InsertActionInfo#0");
nc.ui.pubapp.plugin.action.InsertActionInfo bean = new nc.ui.pubapp.plugin.action.InsertActionInfo();
context.put("nc.ui.pubapp.plugin.action.InsertActionInfo#0", bean);
bean.setActionContainer((nc.ui.uif2.actions.IActionContainer) findBeanInUIF2BeanFactory("actionsOfCard"));
bean.setActionType("notedit");
bean.setTarget((javax.swing.Action) findBeanInUIF2BeanFactory("printMngAction"));
bean.setPos("after");
bean.setAction(getCloseRowNewAction());
setBeanFacotryIfBeanFacatoryAware(bean);
invokeInitializingBean(bean);
return bean;
}
public nc.ui.pubapp.plugin.action.InsertActionInfo getInsertActionInfo_1() {
if (context.get("nc.ui.pubapp.plugin.action.InsertActionInfo#1") != null)
return (nc.ui.pubapp.plugin.action.InsertActionInfo) context
.get("nc.ui.pubapp.plugin.action.InsertActionInfo#1");
nc.ui.pubapp.plugin.action.InsertActionInfo bean = new nc.ui.pubapp.plugin.action.InsertActionInfo();
context.put("nc.ui.pubapp.plugin.action.InsertActionInfo#1", bean);
bean.setActionContainer((nc.ui.uif2.actions.IActionContainer) findBeanInUIF2BeanFactory("actionsOfList"));
bean.setActionType("notedit");
bean.setTarget((javax.swing.Action) findBeanInUIF2BeanFactory("printMngAction"));
bean.setPos("after");
bean.setAction(getCloseRowNewAction());
setBeanFacotryIfBeanFacatoryAware(bean);
invokeInitializingBean(bean);
return bean;
}
public nc.ui.ic.m4455.action.CloseRowNewAction getCloseRowNewAction() {
if (context.get("closeRowNewAction") != null)
return (nc.ui.ic.m4455.action.CloseRowNewAction) context
.get("closeRowNewAction");
nc.ui.ic.m4455.action.CloseRowNewAction bean = new nc.ui.ic.m4455.action.CloseRowNewAction();
context.put("closeRowNewAction", bean);
bean.setModel((nc.ui.uif2.model.AbstractUIAppModel) findBeanInUIF2BeanFactory("icBizModel"));
bean.setEditor((nc.ui.pubapp.uif2app.view.BillForm) findBeanInUIF2BeanFactory("card"));
bean.setCode("closeRowNewAction");
setBeanFacotryIfBeanFacatoryAware(bean);
invokeInitializingBean(bean);
return bean;
}
}
4、新建一个按钮类
如下图:
package nc.ui.ic.m4455.action;
import java.awt.event.ActionEvent;
import java.util.ArrayList;
import java.util.Properties;
import nc.bs.framework.common.NCLocator;
import nc.itf.fdgyl.IFdDBService;
import nc.itf.uap.IUAPQueryBS;
import nc.jdbc.framework.processor.BeanListProcessor;
import nc.ui.pub.beans.MessageDialog;
import nc.ui.pubapp.uif2app.view.BillForm;
import nc.ui.tools.query.PubTools;
import nc.ui.uif2.NCAction;
import nc.ui.uif2.editor.BillListView;
import nc.ui.uif2.model.AbstractUIAppModel;
import nc.vo.ic.m4455.entity.SapplyBillBodyVO;
import nc.vo.ic.m4455.entity.SapplyBillHeadVO;
import nc.vo.ic.m4455.entity.SapplyBillVO;
import nc.vo.pubapp.pattern.model.entity.bill.AbstractBill;
public class CloseRowNewAction extends NCAction{
private static final long serialVersionUID = 1L;
private String design = null;
private nc.ui.uif2.model.AbstractUIAppModel model = null;
private BillForm editor;
private BillListView list;
public BillListView getListEditor() {
return list;
}
public void setListEditor(BillListView list) {
this.list = list;
}
public BillForm getEditor() {
return editor;
}
public void setEditor(BillForm editor) {
this.editor = editor;
}
public AbstractUIAppModel getModel() {
return model;
}
public void setModel(AbstractUIAppModel model) {
this.model = model;
}
public CloseRowNewAction() {
super.setBtnName("关闭/打开行数据");
}
@Override
public void doAction(ActionEvent arg0) throws Exception {
Properties p = PubTools.getParameterInfo();
design = p.getProperty("design");
IFdDBService iupdate = (IFdDBService) NCLocator.getInstance().lookup(IFdDBService.class);
SapplyBillVO aggvo = (SapplyBillVO) this.model.getSelectedData();
if(aggvo==null){
MessageDialog.showWarningDlg(editor, "提示", "请先查询并选择一行数据!");
return;
}
SapplyBillHeadVO hvo = aggvo.getHead();
Object obj = this.model.getSelectedData();
AbstractBill oldVO = (AbstractBill) obj;
String pk = oldVO.getParentVO().getPrimaryKey();
String user = this.model.getContext().getPk_loginUser();// 当前登录用户
int[] selectRows = null;
String sqlwhereopen = "";
String sqlwhereclose = "";
SapplyBillBodyVO bvo = new SapplyBillBodyVO();
if(true){
selectRows = getEditor().getBillCardPanel().getBillTable().getSelectedRows();
if(selectRows.length==0){
MessageDialog.showWarningDlg(editor, "提示", "请选择需要关闭或打开的表体行!");
return ;
}
for(int i =0; i<selectRows.length;i++)
{
int selectrow =selectRows[i];
bvo = (SapplyBillBodyVO) getEditor().getBillCardPanel().getBillModel().getBodyValueRowVO(selectrow, SapplyBillBodyVO.class.getName());
String Cgeneralbid = bvo.getCgeneralbid();
String vbdef20 =bvo.getVbdef20();
if(vbdef20!=null&&vbdef20.length()>0)
{
if("".equals(sqlwhereopen))
{
sqlwhereopen = sqlwhereopen+"('"+Cgeneralbid+"'";
}else
{
sqlwhereopen = sqlwhereopen+",'"+Cgeneralbid+"'";
}
}else
{
if("".equals(sqlwhereclose))
{
sqlwhereclose = sqlwhereclose+"('"+Cgeneralbid+"'";
}else
{
sqlwhereclose = sqlwhereclose+",'"+Cgeneralbid+"'";
}
}
}
if(1== MessageDialog.showOkCancelDlg(editor, "提示", "当前操作会关闭或打开行数据?\n确定执行 点击确定 ?"))
{
String sql = "";
StringBuffer sbupdate = new StringBuffer();
if(sqlwhereopen!=null&&sqlwhereopen.length()>0)
{
sqlwhereopen = sqlwhereopen +")";
sql = "update ic_sapply_b set vbdef20 = '',isclosed ='N' where cgeneralbid in "+sqlwhereopen+" and dr = 0;";
sbupdate.append(sql);
}
if(sqlwhereclose!=null&&sqlwhereclose.length()>0)
{
sqlwhereclose = sqlwhereclose +")";
sql = "update ic_sapply_b set vbdef20 = '"+user+"',isclosed ='Y' where cgeneralbid in "+sqlwhereclose+" and dr = 0;";
sbupdate.append(sql);
}
if(sbupdate!=null)
{
iupdate.updateDatas(sbupdate,design);
IUAPQueryBS iuap = NCLocator.getInstance().lookup(IUAPQueryBS.class);
String sqlquery = "select * from ic_sapply_b where nvl(dr,0)=0 and cgeneralhid='"
+ pk + "' ORDER BY to_number(crowno) asc";
@SuppressWarnings("unchecked")
ArrayList<SapplyBillBodyVO[]> bodyList = (ArrayList<SapplyBillBodyVO[]>) iuap
.executeQuery(sqlquery, new BeanListProcessor(
SapplyBillBodyVO.class));
SapplyBillVO aggvonew = new SapplyBillVO();
aggvonew.setParentVO(hvo);
aggvonew.setChildrenVO(bodyList.toArray(new SapplyBillBodyVO[0]));
this.editor.getModel().directlyUpdate(aggvonew);
}
}
}
}
}
5、重启服务器 测试按钮功能
说明:重写配置文件是因为系统的单据不支持在他们的配置下文件下添加按钮 但是给出了新配置文件的方式!
推荐阅读