1.查找节点对应的xml文件
1.1其中xml文件中的model和edit要和文件中的引用保持一致
1.2<bean id="addFrom4CAction" class="nc.ui.ic.m4a.action.SalesOutOfStockAction">
其中bean中id自己填写,class的类是你自己写的要执行的类,但是继承拉单的自制按钮的父类
1.3<property name="editorModel" ref="icBizEditorModel" />
<property name="model" ref="icBizModel" />
<property name="transferViewProcessor" ref="transferViewProcessor" />
这些都是你代码中要用到的值,记得写get/set方法,如果父类有,就不需要添加。name的值和SalesOutOfStockAction类中的名字一致,ref的值要和xml文件的内容一致
1.4xml的java类要重新生成一次
选中xml右击 -》Springxml to java,如果执行没有效果,将property的内容全部删除再生成java类,然后自己手动添加property的内容,内容信息参照xml的java类其他一样地方
2.SalesOutOfStockAction类代码:
package nc.ui.ic.m4a.action;
import java.awt.event.ActionEvent;
import nc.ui.ic.general.action.GeneralAddAction;
import nc.ui.querytemplate.QueryConditionDLG;
import nc.ui.trade.business.HYPubBO_Client;
import nc.vo.uif2.LoginContext;
import java.awt.Container;
import nc.vo.ic.m4a.entity.GeneralInBodyVO;
import nc.vo.ic.m4a.entity.GeneralInHeadVO;
import nc.vo.ic.m4a.entity.GeneralInVO;
import nc.vo.ic.m4c.entity.SaleOutBodyVO;
import nc.vo.ic.m4c.entity.SaleOutHeadVO;
import nc.vo.ic.m4c.entity.SaleOutVO;
import nc.vo.querytemplate.TemplateInfo;
import nc.ui.pub.beans.UIDialog;
import nc.ui.pubapp.billref.dest.TransferViewProcessor;
import nc.ui.am.util.AMOrgUtils;
public class SalesOutOfStockAction extends GeneralAddAction {
private TransferViewProcessor transferViewProcessor;
public TransferViewProcessor getTransferViewProcessor() {
return transferViewProcessor;
}
public void setTransferViewProcessor(TransferViewProcessor transferViewProcessor) {
this.transferViewProcessor = transferViewProcessor;
}
public SalesOutOfStockAction() {
super();
super.setBtnName("销售出库单");
super.setCode("SalesOutOfStock");
}
@Override
public void doAction(ActionEvent e) throws Exception {
//super.doAction(e);
LoginContext context = this.getEditorModel().getContext().getLoginContext();
String pk_org = AMOrgUtils.getDefaultOrgId(context);
String pk_group = context.getPk_group();
// 调用查询模板
Container container = context.getEntranceUI();
TemplateInfo ti = new TemplateInfo();
String id = (String) HYPubBO_Client.findColValue("pub_query_templet",
"id", " node_code='40080802' ");
ti.setTemplateId(id);
ti.setPk_Org(context.getPk_group());
ti.setUserid(context.getPk_loginUser());
ti.setCurrentCorpPk(context.getPk_group());
ti.setFunNode("40080802");
ti.setNodekey("");
QueryConditionDLG qcDLG = new QueryConditionDLG(container, ti);
qcDLG.setVisibleNormalPanel(false);
if (qcDLG.showModal() == UIDialog.ID_OK) {
// 打开拉单界面
SourceRefDialog dialog = new SourceRefDialog(
container, qcDLG.getWhereSQL(), pk_org);
if (dialog.showModal() == UIDialog.ID_OK) {
// 返回数据
SaleOutVO billVO = dialog.getAggSaleOutVO();
SaleOutHeadVO saleHead = (SaleOutHeadVO) billVO.getParentVO();
SaleOutBodyVO[] saleBody = (SaleOutBodyVO[]) billVO.getChildrenVO();
GeneralInVO aggGeneralInVO =new GeneralInVO();
GeneralInHeadVO headVO = new GeneralInHeadVO();
GeneralInBodyVO[] bodyVOs = new GeneralInBodyVO[saleBody.length];
//设置表体头字段
if(saleHead != null){
//库存组织
headVO.setPk_org(saleHead.getPk_org());
headVO.setPk_org_v(saleHead.getPk_org_v());
//集团
headVO.setPk_group(saleHead.getPk_group());
//仓库
headVO.setCwarehouseid(saleHead.getCwarehouseid());
//入库类型
String billType = (String) HYPubBO_Client.findColValue("bd_billtype",
"pk_billtypeid", "billtypename='其它入库'");
//headVO.setCtrantypeid(billType);
//headVO.setCtrantypeid(saleHead.getCtrantypeid());
//库管员
headVO.setCwhsmanagerid(saleHead.getCwhsmanagerid());
//部门
headVO.setCdptid(saleHead.getCdptid());
headVO.setCdptvid(saleHead.getCdptvid());
//备注
headVO.setVnote(saleHead.getVnote());
}
//设置表体字段
if(saleBody != null && saleBody.length > 0){
for(int i=0;i<saleBody.length;i++){
GeneralInBodyVO bodyVO = new GeneralInBodyVO();
//行号
bodyVO.setCrowno(saleBody[i].getCrowno());
//物料
bodyVO.setCmaterialoid(saleBody[i].getCmaterialoid());
bodyVO.setCmaterialvid(saleBody[i].getCmaterialvid());
//主单位
bodyVO.setCunitid(saleBody[i].getCunitid());
//单位
bodyVO.setCastunitid(saleBody[i].getCastunitid());
//质检批次
//bodyVO.setVbatchcode(saleBody[i].getVbatchcode());
//实收数量
bodyVO.setNassistnum(saleBody[i].getNassistnum());
//实收主数量
bodyVO.setNnum(saleBody[i].getNnum());
//入库日期
bodyVO.setDbizdate(saleBody[i].getDbizdate());
//库存状态
bodyVO.setCstateid(saleBody[i].getCstateid());
//行备注
bodyVO.setVnotebody(saleBody[i].getVnotebody());
//生产日期
bodyVO.setDproducedate(saleBody[i].getDproducedate());
//失效日期
bodyVO.setDvalidate(saleBody[i].getDvalidate());
//换算率
bodyVO.setVchangerate(saleBody[i].getVchangerate());
bodyVOs[i] = bodyVO;
}
}
aggGeneralInVO.setParentVO(headVO);
aggGeneralInVO.setChildrenVO(bodyVOs);
//调用父类方法跳转卡片画面
super.doAction(e);
//设置卡片画面内容
this.transferViewProcessor.getBillForm().setValue(aggGeneralInVO);
//显示卡片画面
this.transferViewProcessor.getBillForm().showMeUp();
}
}
}
}
3.查询中转界面SourceRefDialog类:
package nc.ui.ic.m4a.action;
import java.awt.BorderLayout;
import java.awt.Container;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.Font;
import java.awt.Toolkit;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.List;
import javax.swing.JPanel;
import nc.bs.framework.common.NCLocator;
import nc.itf.uap.IUAPQueryBS;
import nc.jdbc.framework.processor.BeanListProcessor;
import nc.ui.pub.beans.MessageDialog;
import nc.ui.pub.beans.UIButton;
import nc.ui.pub.beans.UIDialog;
import nc.ui.pub.bill.BillEditEvent;
import nc.ui.pub.bill.BillEditListener;
import nc.ui.pub.bill.BillListPanel;
import nc.ui.trade.business.HYPubBO_Client;
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;
public class SourceRefDialog extends UIDialog implements ActionListener {
private static final long serialVersionUID = 7444507682861271658L;
private JPanel contentPanel;
private JPanel southPanel;
private JPanel centerPanel;
private BillListPanel billListPanel;
private UIButton btn_ok;
private UIButton btn_cl;
private SaleOutVO aggSaleOutVO;
private String whereSql = null;
private String pk_org = null;
private String bill_templet = null;
private String cgeneralhid = null;
SaleOutBodyVO[] bodyObj =null;
public SourceRefDialog(Container parent, String strWhere,
String pk_org) throws Exception {
super(parent);
this.whereSql = strWhere;
this.pk_org = pk_org;
initialize();
}
/**
* 初始化
* @throws Exception
*/
private void initialize() throws Exception {
setName("SourceRefDialog");
setDefaultCloseOperation(2);
setSize(1200, 600);
setTitle("销售出库单 ");
bill_templet = (String) HYPubBO_Client.findColValue("pub_billtemplet",
"pk_billtemplet", "bill_templetname='销售出库单'");
setContentPane(getContentPanel());
getBtnOk().addActionListener(this);
getBtnCl().addActionListener(this);
setDlgPosition();
queryData();
}
/**
* 居中显示
*/
private void setDlgPosition() {
int x = (int) (Toolkit.getDefaultToolkit().getScreenSize().getWidth() - (double) getWidth()) / 2;
int y = (int) (Toolkit.getDefaultToolkit().getScreenSize().getHeight() - (double) getHeight()) / 2;
if (x < 0)
x = 0;
if (y < 0)
y = 0;
setLocation(x, y);
}
private BillListPanel getBillListPanel(){
if (billListPanel == null) {
billListPanel = new BillListPanel();
billListPanel.loadTemplet(bill_templet);
billListPanel.setMultiSelect(false);
//显示表体内容
billListPanel.addHeadEditListener(new QueryProgressEditListener());
}
return billListPanel;
}
/**
* 拉单加载上游单据页面数据
*/
@SuppressWarnings("unchecked")
private void queryData() {
try {
IUAPQueryBS query = NCLocator.getInstance().lookup(
IUAPQueryBS.class);
String sql = "select * from ic_saleout_h where nvl(dr,0)=0 and nvl(vdef20,'N')='Y'";
if (whereSql != null && !"".equals(whereSql)) {
sql += " and " + whereSql;
}
if(null!=pk_org&&!"".equals(pk_org)){
sql+=" and pk_org='"+pk_org+"'";
}
// 表头
List<SaleOutHeadVO> saleOutHead = (List<SaleOutHeadVO>) query
.executeQuery(sql, new BeanListProcessor(
SaleOutHeadVO.class));
if (saleOutHead != null && saleOutHead.size() > 0) {
getBillListPanel().getHeadBillModel().setBodyDataVO(
saleOutHead.toArray(new SaleOutHeadVO[0]));
getBillListPanel().getHeadBillModel()
.loadLoadRelationItemValue();
}
} catch (Exception e) {
e.printStackTrace();
}
}
private class QueryProgressEditListener implements BillEditListener {
@Override
public void afterEdit(BillEditEvent e) {}
@SuppressWarnings("unchecked")
@Override
public void bodyRowChange(BillEditEvent e) {
// 选择的表头的主键
cgeneralhid = (String) getBillListPanel()
.getHeadBillModel().getValueAt(e.getRow(), "cgeneralhid");
// 获取表体数据
IUAPQueryBS query = NCLocator.getInstance().lookup(
IUAPQueryBS.class);
String sql = "select * from ic_saleout_b where nvl(dr,0)=0 and cgeneralhid='"+cgeneralhid+"' ";
List<SaleOutBodyVO> saleOutBodyList =null;
try {
saleOutBodyList = (List<SaleOutBodyVO>) query
.executeQuery(sql, new BeanListProcessor(SaleOutBodyVO.class));
} catch (BusinessException e1) {
// TODO 自动生成的 catch 块
e1.printStackTrace();
}
bodyObj = saleOutBodyList.toArray(new SaleOutBodyVO[saleOutBodyList.size()]);
getBillListPanel().getBodyBillModel().setBodyDataVO(bodyObj);
getBillListPanel().getBodyBillModel().loadLoadRelationItemValue();
}
}
private JPanel getSouthPanel() {
if (southPanel == null) {
southPanel = new JPanel();
southPanel.setName("NorthPane");
southPanel.setLayout(new FlowLayout());
southPanel.add(getBtnOk());
southPanel.add(getBtnCl());
}
return southPanel;
}
private JPanel getCenterPanel() {
if (centerPanel == null) {
centerPanel = new JPanel();
centerPanel.setName("CenterPane");
centerPanel.setLayout(new BorderLayout());
centerPanel.add(getBillListPanel());
}
return centerPanel;
}
private JPanel getContentPanel() {
if (contentPanel == null) {
contentPanel = new JPanel();
contentPanel.setName("AdconfirmPane");
contentPanel.setLayout(new BorderLayout());
contentPanel.add(getCenterPanel(), BorderLayout.CENTER);
contentPanel.add(getSouthPanel(), BorderLayout.SOUTH);
}
return contentPanel;
}
private UIButton getBtnOk() {
if (btn_ok == null) {
btn_ok = new UIButton();
btn_ok.setName("BtnOk");
btn_ok.setText("确定");
btn_ok.setPreferredSize(new Dimension(80, 22));
btn_ok.setFont(new Font("dialog", 0, 12));
}
return btn_ok;
}
private UIButton getBtnCl() {
if (btn_cl == null) {
btn_cl = new UIButton();
btn_cl.setName("BtnCl");
btn_cl.setText("取消");
btn_cl.setPreferredSize(new Dimension(80, 22));
btn_cl.setFont(new Font("dialog", 0, 12));
}
return btn_cl;
}
/**
* 拉单返回数据
*
* @return AggPatentAccNoticeVO
*/
public SaleOutVO getAggSaleOutVO() {
return aggSaleOutVO;
}
/**
* 设置拉单返回数据
*
* @throws BusinessException
*/
@SuppressWarnings("unchecked")
public boolean setAggSaleOutVO() {
if (cgeneralhid == null || "".equals(cgeneralhid)) {
MessageDialog.showHintDlg(this, null, "请选择一条记录");
return false;
}
aggSaleOutVO = new SaleOutVO();
// 获取选中表头数据
IUAPQueryBS query = NCLocator.getInstance().lookup(
IUAPQueryBS.class);
String sql = "select * from ic_saleout_h where nvl(dr,0)=0 and cgeneralhid='"+cgeneralhid+"' ";
List<SaleOutHeadVO> saleOutHead = null;
try {
saleOutHead = (List<SaleOutHeadVO>) query.executeQuery(sql,
new BeanListProcessor(SaleOutHeadVO.class));
} catch (BusinessException e) {
// TODO 自动生成的 catch 块
e.printStackTrace();
}
aggSaleOutVO.setParentVO(saleOutHead.get(0));
aggSaleOutVO.setChildrenVO(bodyObj);
return true;
}
public void actionPerformed(ActionEvent e) {
if (e.getSource() == getBtnOk()) {
if (setAggSaleOutVO()) {
closeOK();
}
} else if (e.getSource() == getBtnCl()) {
closeCancel();
}
}
}