NC65客开增加自定义弹窗参照

NC65客开增加自定义弹窗参照

本篇主要介绍当标准功能单据参照有局限性的时候,进行客开按钮并且客开自定义的查询弹窗以及单据展现弹窗

步骤如下:

  1. 增加按钮
    NC65客开自定义按钮
  2. 创建单据的查询模板和单据模板
    这个可以选择UAP开发,生成查询模板和单据模板
  3. 自定义两个弹窗分别引用两个模板
查询弹窗
IUAPQueryBS bsDao = (IUAPQueryBS) NCLocator.getInstance().lookup(
				IUAPQueryBS.class.getName());
		// model_code模板编码
//		String sql = "select id from pub_query_templet where node_code ='TR100101'";
		String sql = "select id from pub_query_templet where  model_code='CS100101'";
		
		// 查询模板的id -> TemplateId
		String TemplateId = (String) bsDao.executeQuery(sql,
				new ColumnProcessor());
		//查询模板节点
		tempinfo.setFunNode("CS100101");
		tempinfo.setTemplateId(TemplateId);
		// editor=单据UI类
		//import nc.ui.querytemplate.QueryConditionDLG;该类全路径
		QueryConditionDLG qcDlg = new QueryConditionDLG(editor, tempinfo);
		int showModal = qcDlg.showModal();
		//如果showModal为1说明用户选中完查询条件以后点击了确定
		if (showModal == 1) {
			//该方法可以获取用户选中的查询条件
			String whereSQL = qcDlg.getWhereSQL();
		}

模板弹窗

下面代码为模板弹窗和查询弹窗结合版,所以客开的时候直接使用下面代码就可以实现参照的查询和模板弹窗

package nc.ui.brmm.dlg;
import java.awt.Container;
import java.util.ArrayList;

import nc.bs.framework.common.InvocationInfoProxy;
import nc.bs.framework.common.NCLocator;
import nc.hr.utils.PubEnv;
import nc.itf.uap.IUAPQueryBS;
import nc.jdbc.framework.processor.BeanListProcessor;
import nc.jdbc.framework.processor.ColumnProcessor;
import nc.ui.hr.frame.persistence.PersitenceDelegator;
import nc.ui.pub.beans.MessageDialog;
 
import nc.ui.pub.bill.BillCardPanel;
import nc.ui.pub.bill.BillItem;
import nc.ui.pub.bill.BillListPanel;
 
import nc.ui.pub.bill.BillModel;
 
import nc.ui.pub.pf.BillSourceDLG;
import nc.ui.pub.pf.BillSourceVar;
import nc.ui.querytemplate.QueryConditionDLG;
 
import nc.vo.fc.firststzj.FirstBVO;
import nc.vo.fc.firststzj.FirstHVO;
import nc.vo.pub.AggregatedValueObject;
import nc.vo.pub.BusinessException;
import nc.ui.pubapp.uif2app.view.BillForm;
import nc.vo.querytemplate.TemplateInfo;
 
 
 
public class DzzCanZhaoDLG extends BillSourceDLG
 
{
	private int nMeasDecimal = 2;
	private int nAssistUnitDecimal = 2;
	private int nConvertDecimal = 2;
	private int nPriceDecimal = 2;
	private int nNmoneyDecimal = 2;
	private  BillForm uiContainer;
	private Boolean state = Boolean.valueOf(true);
	private String m_pkCorp = null;
	private String m_where = null;
	private BillSourceVar billSourceVar;
	public Boolean getState() {
		return this.state;
	}
	public void setState(Boolean state) {
		this.state = state;
	}
	BillListPanel m_arrListPanel = null;
	 
	public DzzCanZhaoDLG(BillForm parent,BillSourceVar billSourceVar) throws BusinessException {
		
		super(parent, billSourceVar);
		this.uiContainer=parent;
		//该代码为查询弹窗上面已经介绍过了
		QueryConditionDLG showQuery = showQuery(parent,"CS100101","CS100101");
		int showModal = showQuery.showModal();
		if (showModal != 1) {
			this.state = Boolean.valueOf(false);
			return;
		}
		this.m_where = showQuery.getWhereSQL();
		this.billSourceVar=billSourceVar;
		loadHeadData();
		addBillUI();
	}
	//必须重写该方法不然就会出现流程配置的问题
	public void getBillVO()
    {  
    }
    //该方法当用户选中了参照的数据,点击确定就会走该方法,我们可以在该方法里面对单据进行赋值等操作
	public void onOk() {
		if (getbillListPanel().getHeadBillModel().getRowCount() > 0) {
			//获取选中的表头数据
			FirstHVO[] firstHVOs =(FirstHVO[])getbillListPanel().getHeadBillModel().getBodySelectedVOs("nc.vo.fc.firststzj.FirstHVO");
			int length = firstHVOs.length;
			BillCardPanel billCardPanel = uiContainer.getBillCardPanel();
			
			BillItem[] headItems = billCardPanel.getHeadItems();
			AggregatedValueObject billValueVO = billCardPanel.getBillValueVO("nc.vo.so.m30.entity.SaleOrderVO", "nc.vo.so.m30.entity.SaleOrderHVO", "nc.vo.so.m30.entity.SaleOrderBVO");
			if(length>0){
				billCardPanel.setHeadItem("vnote", firstHVOs[0].getVbillcode());
			}
			this.close();
			MessageDialog.showHintDlg(uiContainer, "提示", "参照成功");
			closeOK();
			 
		}
		closeOK();
		 
	}
	 
	 
	 
	 
	 //当用户选中表头某一条数据,带出该数据对应表体数据就是走该方法
	 @Override
	public void loadBodyData(int row) {
		 
		try {
			getbillListPanel().getHeadTable().clearSelection();
			String id = getbillListPanel().getHeadBillModel().getValueAt(row, billSourceVar.getPkField()).toString();
			IUAPQueryBS service = NCLocator.getInstance()
					.lookup(IUAPQueryBS.class);
			String queryBvoSql="select pk_recitem as pk_first_b,purchaseorder as fb_cs from ar_recitem where pk_recbill='"+id+"'";
			ArrayList<FirstBVO> bvoList=null;
			try {
				bvoList = (ArrayList<FirstBVO>) service.executeQuery(queryBvoSql, new BeanListProcessor(FirstBVO.class));
			} catch (BusinessException e) {
				return;
			}

			//将查询出来的数据赋值给表体
			getbillListPanel().getBodyBillModel().setBodyDataVO(bvoList.toArray(new FirstBVO[0]));
			//如果是多表体的情况使用下面方式赋值tablename为该表体对应数据库表名
			getbillListPanel().setBodyValueVO("tablename", bvoList.toArray(new FirstBVO[0]));
    
			getbillListPanel().getBodyBillModel().execLoadFormula();
		} catch (Exception e) {
			return;
		}
		 
	}
	 
	 
	 
	 
	//加载单据的时候对表头进行赋值 
	public void loadHeadData() {
		IUAPQueryBS service = NCLocator.getInstance()
				.lookup(IUAPQueryBS.class);
		ArrayList<FirstHVO> hvoList=null;
		String queryHvoSql="select DISTINCT pk_recbill as pk_first_h,local_money as fc_h,pk_group,pk_org,billno as vbillcode, billstatus as vbillstatus from ar_recbill where  ar_recbill.pk_org = '0001A31000000000KBZ2' AND ( ar_recbill.billdate >= '2023-04-16 00:00:00' and ar_recbill.billdate <= '2024-04-26 23:59:59' )   AND ar_recbill.pk_group = '0001A3100000000002PS'";
		try {
			hvoList = (ArrayList<FirstHVO>) service.executeQuery(queryHvoSql, new BeanListProcessor(FirstHVO.class));
		} catch (BusinessException e) {
			// TODO 自动生成的 catch 块
			e.printStackTrace();
		}
		
		
			 
			if (hvoList.size() == 0) {
				MessageDialog.showWarningDlg(null, "数据查询", "未查询到相符数据");
				this.state = Boolean.valueOf(false);
				return;
			}
			BillListPanel listpanelon = getbillListPanel();
			listpanelon.getHeadBillModel().setBodyDataVO(hvoList.toArray(new FirstHVO[0]));
			listpanelon.getHeadTable().clearSelection();
		
	}
	 
	//点击查询按钮的时候走的方法
	public void onQuery() {
		QueryConditionDLG showQuery;
		try {
			showQuery = showQuery(uiContainer,"CS100101","CS100101");
		} catch (BusinessException e) {
			// TODO 自动生成的 catch 块
			return;
		}
		int showModal = showQuery.showModal();
		if (showModal != 1) {
			return;
		}
		this.m_where = showQuery.getWhereSQL();
		loadHeadData();
	}
	//当前UI、查询模板code、查询模板分配的节点
	public QueryConditionDLG showQuery(Container editor,String modelCode,String funNode) throws BusinessException {
		// 调用模板所需要的信息->TemplateInfo
				TemplateInfo tempinfo = new TemplateInfo();
				InvocationInfoProxy instance = InvocationInfoProxy.getInstance();

				String groupId = instance.getGroupId();
				String userId = instance.getUserId();
				tempinfo.setPk_Org(groupId);
				// tempinfo.setCurrentCorpPk(PubEnv.getPk_corp());
				tempinfo.setUserid(userId);
				tempinfo.setNodekey(null);
				// 业务类型
				// tempinfo.setBusiType(AgVatPFConfig.BILLTYPE);
				IUAPQueryBS bsDao = (IUAPQueryBS) NCLocator.getInstance().lookup(
						IUAPQueryBS.class.getName());
				// model_code模板编码
//				String sql = "select id from pub_query_templet where node_code ='TR100101'";
				String sql = "select id from pub_query_templet where  model_code='"+modelCode+"'";
				
				// 查询模板的id -> TemplateId
				String TemplateId = (String) bsDao.executeQuery(sql,
						new ColumnProcessor());
				// ??????查询模板节点
				tempinfo.setFunNode(funNode);
				tempinfo.setTemplateId(TemplateId);
				// parent=单据UI类????????????
				//
				QueryConditionDLG qcDlg = new QueryConditionDLG(editor, tempinfo);
				return qcDlg;
		 
	}
	 
}

调用
		BillSourceVar billSourceVar = new BillSourceVar();
		//单据主表PK字段名
		billSourceVar.setPkField("pk_first_h");
		//单据模板类型
		billSourceVar.setBillType("CS100101");
		billSourceVar.setWhereStr("1=1");
		DzzCanZhaoDLG dzzCanZhaoDLG = new DzzCanZhaoDLG(editor,billSourceVar);
		Boolean state = dzzCanZhaoDLG.getState();
		if(state.booleanValue()){
			int show = dzzCanZhaoDLG.showModal();
		}
实现效果

在这里插入图片描述

查询模板

在这里插入图片描述

  1. loadHeadData()
  2. loadBodyData()
  3. onOk()
  4. onQuery()
  • 15
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值