NC二开新增按钮,弹框并展示数据

NC二开,在功能节点上新增自己的按钮,并弹框,展示数据的步骤

 

 

1、功能注册里找到节点本身的XML,在XML所属文件夹中有对应的.java文件 

 

 

2、在XML中找一个按钮的来作为参照,改成自己需要的,在到java中田间action方法 

 

<!-- 自己的按钮 -->
   	<bean id="myAction"  class="nc.ui.ic.m4c.action.MyButtonAction">
   		<!-- model、editor属性名与按钮类对应 -->
   		<property name="model" ref="icBizModel" />
		<property name="editorModel" ref="icBizEditorModel" />
		<property name="editor" ref="card" />
   	</bean>

显示按钮组这里加上 

<bean id="actionsOfCard" class="nc.ui.uif2.actions.StandAloneToftPanelActionContainer">
		<constructor-arg ref="card" />
		<property name="model" ref="icBizModel" />
		<!-- 可以配置非编辑状态下和编辑状态下分别可见的Action,没有此需求时可以配置得一样 -->
		<property name="actions">
			<list>
				<!-- 新增 -->
				<ref bean="addMenu" />
				<!-- 修改 -->
				<ref bean="saleOuteditAction" />
				<!-- 删除 -->
				<ref bean="deleteAction" />
				<!-- 复制 -->
				<ref bean="copyAction" />

				<!-- 分割 -->
				<ref bean="separatorAction" />
				<!-- 查询 -->
				<ref bean="queryAction" />
				<!-- 刷新 -->
				<ref bean="refreshCardAction" />
				<!-- 分割 -->
				<ref bean="separatorAction" />
				<!-- 维护 -->
				<ref bean="maintainMenu" />
				<!-- 签字按钮组 -->
				<ref bean="signActionMenu" />
				<!-- 关联功能 -->
				<ref bean="relatFunctionBrowseAction_OUT" />
				<!-- 分割 -->
				<ref bean="separatorAction" />
				<!-- 联查 -->
				<ref bean="linkQryBrowseGroupAction" />
				<!-- 分割 -->
				<ref bean="separatorAction" />
				<!-- 导入导出 -->
				<ref bean="importExportAction" />
				<!-- 打印 -->
				<ref bean="printMngAction" />
				<!-- 分割 -->
				<ref bean="separatorAction" />
				<!-- 分割 -->
				<ref bean="myAction" />
			</list>
		</property>

.java文件中加入自己的Action,不然不显示按钮,其中参数可参考同文件中的其他按钮,一个模块的参数基本都一样 ,另外要在listAction中添加自己的Action(两个地方需要添加)

/* TODO自己的button*/
  public MyButtonAction getMyAction() {
	    if (this.context.get("myAction") != null)
	      return (MyButtonAction)this.context.get("myAction");
	    MyButtonAction bean = new MyButtonAction();
	    this.context.put("myAction", bean);
	    bean.setModel(getIcBizModel());
	    bean.setEditorModel((ICGenBizEditorModel)findBeanInUIF2BeanFactory("icBizEditorModel"));
	    bean.setEditor(getCard());
	    setBeanFacotryIfBeanFacatoryAware(bean);
	    invokeInitializingBean(bean);
	    return bean;
	  }
 private List getManagedList8() {
    List list = new ArrayList(); list.add(getAddMenu()); list.add(getSaleOuteditAction()); list.add(getDeleteAction()); list.add(getCopyAction()); list.add((Action)findBeanInUIF2BeanFactory("separatorAction")); list.add((Action)findBeanInUIF2BeanFactory("queryAction")); list.add((Action)findBeanInUIF2BeanFactory("refreshCardAction")); list.add((Action)findBeanInUIF2BeanFactory("separatorAction")); list.add((Action)findBeanInUIF2BeanFactory("maintainMenu")); list.add((Action)findBeanInUIF2BeanFactory("signActionMenu")); list.add(getRelatFunctionBrowseAction_OUT()); list.add((Action)findBeanInUIF2BeanFactory("separatorAction")); list.add(getLinkQryBrowseGroupAction()); list.add((Action)findBeanInUIF2BeanFactory("separatorAction")); list.add((Action)findBeanInUIF2BeanFactory("importExportAction")); list.add(getPrintMngAction());list.add(getMyAction()); return list;
  }

最后是自己的Action按钮方法和弹窗的方法 

package nc.ui.ic.m4c.action;
 
import java.awt.event.ActionEvent;
import java.util.ArrayList;

import nc.bs.framework.common.NCLocator;
import nc.desktop.ui.WorkbenchEnvironment;
import nc.funcnode.ui.AbstractFunclet;
import nc.funcnode.ui.FuncletWindowLauncher;
import nc.itf.uap.IUAPQueryBS;
import nc.itf.uap.qrytemplate.IQueryTemplateQry;
import nc.jdbc.framework.processor.ArrayListProcessor;
import nc.sfbase.client.ClientToolKit;
import nc.ui.ic.general.model.ICGenBizEditorModel;
import nc.ui.ic.m4c.view.SaleOutBizView;
import nc.ui.ic.pub.model.ICBizModel;
import nc.ui.mmf.framework.util.FuncNodeLauncher;
import nc.ui.pub.beans.MessageDialog;
import nc.ui.pub.bill.BillCardPanel;
import nc.ui.uif2.NCAction;
import nc.ui.uif2.model.BillManageModel;
import nc.vo.ic.m4c.entity.SaleOutVO;
import nc.vo.querytemplate.QryTempletVOWithInfo;
import nc.vo.sm.funcreg.FuncRegisterVO;
 
@SuppressWarnings("restriction")
public class MyButtonAction extends NCAction {
	
	//根据节点xml中其他按钮bean选择model、editor的类型
    private ICBizModel model;
    private ICGenBizEditorModel editorModel;
    private SaleOutBizView editor;
	
	/**
	 * 销售订单维护
	 */
	private static final long serialVersionUID = 1L;
 
	public MyButtonAction(){
		setCode("myAction");
		super.setBtnName("测试按钮展示数据");
	}
	
	@Override
	public void doAction(ActionEvent arg0) throws Exception {
		//MessageDialog.showHintDlg(getModel().getContext().getEntranceUI(), "测试", "测试信息");
		
		SaleOutVO out=(SaleOutVO) this.getModel().getSelectedData();
		AbstractFunclet funclet = (AbstractFunclet) getModel().getContext()
				.getEntranceUI();
		SplitLineDialog dlg=new SplitLineDialog(funclet);

		//dlg.showModal();
		int res=dlg.initData(out.getBodys());
		if(res==1){
			dlg.showModal();
		}
	}
	public ICBizModel getModel() {
		return model;
	}

	public void setModel(ICBizModel model) {
		this.model = model;
		this.model.addAppEventListener(this); // 监听
	}

	public ICGenBizEditorModel getEditorModel() {
		return editorModel;
	}

	public void setEditorModel(ICGenBizEditorModel saleOutBizView) {
		this.editorModel = saleOutBizView;
	}

	public void setEditor(SaleOutBizView card) {
		this.editor = card;
		
	}
	public SaleOutBizView getEditor() {
		return editor;
	}
}

 弹框所需要的模板需要在模板里新建自己需要的模板,也可以根据需求调用其他模板,然后赋值操作就行,重要的地方代码里都有注释,也可以参考界面其他按钮的方法进行操作

 

package nc.ui.ic.m4c.action;
 
import java.awt.BorderLayout;
import java.awt.Container;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

import javax.swing.JPanel;
import nc.bs.framework.common.NCLocator;
import nc.funcnode.ui.AbstractFunclet;
import nc.itf.bd.supplier.baseinfo.ISupplierBaseInfoQryService;
import nc.itf.uap.IUAPQueryBS;
import nc.jdbc.framework.processor.ArrayListProcessor;
import nc.jdbc.framework.processor.MapListProcessor;
import nc.pubitf.ic.m4c.ISaleOutRefQuery;
import nc.ui.pub.beans.UIDialog;
import nc.ui.pub.beans.UIPanel;
import nc.ui.pub.bill.BillCardPanel;
import nc.ui.pub.bill.BillEditEvent;
import nc.ui.pub.bill.BillEditListener;
import nc.ui.pub.bill.BillEditListener2;
import nc.vo.ic.m4c.entity.SaleOutBodyVO;
import nc.vo.ic.m4c.entity.SaleOutHeadVO;
import nc.vo.ic.m4c.entity.SaleOutVO;
import nc.vo.pub.BusinessException;
import nc.vo.pub.CircularlyAccessibleValueObject;
import nc.vo.pub.lang.UFBoolean;
 
/**
 * 
 * @ClassName: SplitLineDialog
 * @Description: TODO(拆行对话框)
 * @author Administrator
 * @version 1.0
 */
public class SplitLineDialog extends UIDialog implements BillEditListener,
		BillEditListener2 {
 
	private static final long serialVersionUID = 5064747027574608058L;
	private AbstractFunclet parent;
	/** UI JPanel */
	private JPanel uiContentPane;
	/** 按钮模板 */
	private UIPanel btnUIPanel;
	private BillCardPanel billPanel;
 
	// 生产计划编制选择的表体行
	private int row = -1;
	// 生产计划编制选择 的表体行vo
	private SaleOutHeadVO curBody = null;
 
	public SplitLineDialog(AbstractFunclet  parent) {
		super(parent);
		this.parent = parent;
		this.initialize();
	}
 
	public int initData(SaleOutBodyVO[] bodys) throws BusinessException {
		String cgeneralhid = bodys[0].getCgeneralhid();
		IUAPQueryBS iquery = (IUAPQueryBS)NCLocator.getInstance().lookup(IUAPQueryBS.class);
        // 创建VO  
        SaleOutHeadVO splivo =  new SaleOutHeadVO();
        //给VO赋值
        String sql = "select vbillcode,fbillflag,vtrantypecode from ic_saleout_h where cgeneralhid = '"+cgeneralhid+"' and dr = 0";
        List<HashMap<String, Object>> list = (List<HashMap<String, Object>>)iquery.executeQuery(sql,new MapListProcessor());
        if(list.size()>0){
        	 splivo.setVbillcode(String.valueOf(list.get(0).get("vbillcode")));
             splivo.setFbillflag(Integer.parseInt(list.get(0).get("fbillflag").toString()));
             splivo.setVtrantypecode(String.valueOf(list.get(0).get("vtrantypecode")));
        }
        //在界面上创建一一行
        this.billPanel.getBillModel().addLine();
        //将VO放入节点当中
        String[] names = splivo.getAttributeNames();  
        for (String name : names) {  
            this.billPanel.setHeadItem(name, splivo.getAttributeValue(name));  
        }
        this.billPanel.setHeadItem("fis3", UFBoolean.TRUE);
        for(int i = 0;i<bodys.length;i++){
        	this.billPanel.getBillModel().setBodyRowVO(bodys[i], i);
        }
		return 1;
	}

	private void initialize() {
		this.setName("mpsSplitDialog");
		this.setDefaultCloseOperation(DISPOSE_ON_CLOSE);
		this.setTitle("数据展示");
		int w = 1000;
		int h = 600;
		this.setBounds(500, 400, w, h);
		this.setResizable(true);
		// 设置模板
		this.setContentPane(this.getUIContentPane());
		
	}
 
	private Container getUIContentPane() {
		if (null == this.uiContentPane) {
			this.uiContentPane = new JPanel();
			this.uiContentPane.setName("UIDialogContentPane");
			this.uiContentPane.setLayout(new BorderLayout());
			this.getUIContentPane().add(this.getBillPanel(), "Center");
			this.getUIContentPane().add(this.getBtnUIPanel(), "South");
		}
		return this.uiContentPane;
	}
	//单据模板pk查询
	//select  pk_billtemplet  from pub_billtemplet  where  bill_templetcaption='单据模版名称'
	private BillCardPanel getBillPanel() {
		// TODO Auto-generated method stub
		if (this.billPanel == null) {
			this.billPanel = new BillCardPanel();
			this.billPanel.setName("mpsSplitPanel");
			this.billPanel.loadTemplet("1001Z8100000000008NZ");
			this.billPanel.addEditListener(this);
			this.billPanel.addBillEditListenerHeadTail(this);
			this.billPanel.getBillTable().setSelectionMode(
					javax.swing.ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
			this.billPanel.setTatolRowShow(true);
			this.billPanel.setBodyMenuShow(false);
		}
		return this.billPanel;
	}
 
	/**
	 * 按钮pannelgetter
	 * 
	 * @return 按钮pannel
	 */
	public UIPanel getBtnUIPanel() {
		if (this.btnUIPanel == null) {
			this.btnUIPanel = new nc.ui.pub.beans.UIPanel();
			this.btnUIPanel.setName("BtnUIPanel");
		}
		return this.btnUIPanel;
	}

	@Override
	public boolean beforeEdit(BillEditEvent arg0) {
		// TODO 自动生成的方法存根
		return false;
	}

	@Override
	public void afterEdit(BillEditEvent arg0) {
		// TODO 自动生成的方法存根
		
	}

	@Override
	public void bodyRowChange(BillEditEvent arg0) {
		// TODO 自动生成的方法存根
		
	}
 
}

 

 

 

 

用友NC是一款非常常用的企业管理软件,通过发可以对其进行定制和扩展,满足企业个性化的需求。 使用用友NC进行发需要一些基础知识和技能。首先,需要具备Java编程基础,使用Java语言进行发。其次,需要了解用友NC的架构和架,包括模块化设计、基础数据结构和常用发接口等。还需要掌握用友NC数据库结构和相关发工具,如Eclipse集成发环境和用友NC Studio发工具。 学习用友NC发,可以通过以下几个步骤实施: 1. 学习用友NC的基础知识:了解用友NC的功能和模块,掌握其基本操作和基础数据结构,为后续的发做好准备。 2. 学习Java编程:掌握Java语言的基础知识和面向对象编程的概念,了解Java架和相关工具,包括JDK、Eclipse等。 3. 学习用友NC架:深入学习用友NC架,了解其模块化设计和常用发接口,掌握发的基本原理和方法。 4. 实践发项目:通过实际发项目,锻炼自己的发能力和解决问题的能力,掌握用友NC发技术和实践经验。 5. 持续学习和提升:用友NC发属于持续学习的过程,需要不断更新知识和技能,关注用友NC的新功能和技术,与同行交流经验和分享成果。 总之,用友NC发是一项具有挑战性的任务,但是通过学习和实践,可以掌握其发技术和方法,为企业定制和扩展用友NC,提高企业管理效率和精确度。
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值