EAS BOS 分录 F7 过滤 动态 级联 详细使用

之前写了一篇 EAS BOS F7 过滤 动态 级联 详细使用 现在再介绍一下分录 F7的动态使用;

1、新建一张业务单据,存在两个F7控件,基本库位属于仓库,只有选择了仓库才,能确定库位。发布业务单元,如下:

2、打开JAVA视图,找到EDITUI JAVA文件,新增方法

  a)首先为仓库添加过滤,prmtwarehouse为仓库F7,并添加监听事件。分录与表头还是有区别的,但代码大同小异;

  区别在于分录的F7并不像表头一样是个单独的控件,而是属于表格的一列。所以先拿到设置一个F7然后,将F7绑定到指定列就可以了。

	private void initF7() {
		final KDBizPromptBox kdtEntrys_warehouse_PromptBox = new KDBizPromptBox();
		kdtEntrys_warehouse_PromptBox
				.setQueryInfo("com.kingdee.eas.basedata.scm.im.inv.app.F7AllWarehouseQuery");
		kdtEntrys_warehouse_PromptBox.setVisible(true);
		kdtEntrys_warehouse_PromptBox.setEditable(true);
		kdtEntrys_warehouse_PromptBox.setDisplayFormat("$number$");
		kdtEntrys_warehouse_PromptBox.setEditFormat("$number$");
		kdtEntrys_warehouse_PromptBox.setCommitFormat("$number$");

		EntityViewInfo entityView = new EntityViewInfo();
		FilterInfo filter = new FilterInfo();
		filter.getFilterItems().add(
				new FilterItemInfo("storageOrg.id", "FQgAAAAABmLM567U",
						CompareType.EQUALS));
		entityView.setFilter(filter);
		kdtEntrys_warehouse_PromptBox.setEntityViewInfo(entityView);

		KDTDefaultCellEditor kdtEntrys_warehouse_CellEditor = new KDTDefaultCellEditor(
				kdtEntrys_warehouse_PromptBox);
		this.kdtEntrys.getColumn("warehouse").setEditor(
				kdtEntrys_warehouse_CellEditor);
		ObjectValueRender kdtEntrys_warehouse_OVR = new ObjectValueRender();
		kdtEntrys_warehouse_OVR.setFormat(new BizDataFormat("$name$"));
		this.kdtEntrys.getColumn("warehouse").setRenderer(
				kdtEntrys_warehouse_OVR);

		kdtEntrys.addKDTEditListener(new KDTEditAdapter() {
			public void editStopped(KDTEditEvent e) {
				try {
					kdtEntrys_Changed(e.getRowIndex(), e.getColIndex());
				} catch (Exception exc) {
					handUIException(exc);
				}
			}
		});
		
	}

  

  b)为库位添加过滤,prmtlocationhouse为库位F7;当前添加的F7过滤,与仓库并无太大相关,只是在新打开单据时做的F7初始化。这是一个表格列级的初始化。

private void locationhouseF7(String warehouseid) {
		final KDBizPromptBox kdtEntrys_locationhouse_PromptBox = new KDBizPromptBox();
		kdtEntrys_locationhouse_PromptBox
				.setQueryInfo("com.kingdee.eas.basedata.scm.im.inv.app.F7LocationQuery");
		kdtEntrys_locationhouse_PromptBox.setVisible(true);
		kdtEntrys_locationhouse_PromptBox.setEditable(true);
		kdtEntrys_locationhouse_PromptBox.setDisplayFormat("$number$");
		kdtEntrys_locationhouse_PromptBox.setEditFormat("$number$");
		kdtEntrys_locationhouse_PromptBox.setCommitFormat("$number$");

		EntityViewInfo entityView = new EntityViewInfo();
		FilterInfo filter = new FilterInfo();
		filter.getFilterItems().add(
				new FilterItemInfo("WAREHOUSE.id", warehouseid,
						CompareType.EQUALS));
		entityView.setFilter(filter);
		kdtEntrys_locationhouse_PromptBox.setEntityViewInfo(entityView);

		KDTDefaultCellEditor kdtEntrys_locationhouse_CellEditor = new KDTDefaultCellEditor(
				kdtEntrys_locationhouse_PromptBox);
		this.kdtEntrys.getColumn("locationhouse").setEditor(
				kdtEntrys_locationhouse_CellEditor);
		ObjectValueRender kdtEntrys_locationhouse_OVR = new ObjectValueRender();
		kdtEntrys_locationhouse_OVR.setFormat(new BizDataFormat("$name$"));
		this.kdtEntrys.getColumn("locationhouse").setRenderer(
				kdtEntrys_locationhouse_OVR);

	}

  c)新增仓库F7更新事件方法,并为库位添加单元格级F7过滤

private void locationhouseCellF7(int rowIndex, Object object) {
		String warehouseid = null;
		if (object != null) {
			warehouseid = ((WarehouseInfo) object).getId().toString();
		}
		final KDBizPromptBox kdtEntrys_locationhouse_PromptBox = new KDBizPromptBox();
		kdtEntrys_locationhouse_PromptBox
				.setQueryInfo("com.kingdee.eas.basedata.scm.im.inv.app.F7LocationQuery");
		kdtEntrys_locationhouse_PromptBox.setVisible(true);
		kdtEntrys_locationhouse_PromptBox.setEditable(true);
		kdtEntrys_locationhouse_PromptBox.setDisplayFormat("$number$");
		kdtEntrys_locationhouse_PromptBox.setEditFormat("$number$");
		kdtEntrys_locationhouse_PromptBox.setCommitFormat("$number$");

		EntityViewInfo entityView = new EntityViewInfo();
		FilterInfo filter = new FilterInfo();
		filter.getFilterItems().add(
				new FilterItemInfo("WAREHOUSE.id", warehouseid,
						CompareType.EQUALS));
		entityView.setFilter(filter);
		kdtEntrys_locationhouse_PromptBox.setEntityViewInfo(entityView);
		try {
			LocationCollection local = LocationFactory.getRemoteInstance()
					.getLocationCollection(entityView);

			if (local.size() > 0) {
				// kdtEntrys_locationhouse_PromptBox.setRequired(true);
				this.kdtEntrys.getCell(rowIndex, "locationhouse").setValue(
						local.get(0));
				this.kdtEntrys.getCell(rowIndex, "locationhouse")
						.getFormattedStyleAttributes().setBackground(
								new Color(252, 251, 223));
			} else {
				// kdtEntrys_locationhouse_PromptBox.setRequired(false);
				this.kdtEntrys.getCell(rowIndex, "locationhouse")
						.getFormattedStyleAttributes().setBackground(
								new Color(252, 255, 255));
			}
		} catch (BOSException e1) {
			e1.printStackTrace();
		}

		KDTDefaultCellEditor kdtEntrys_locationhouse_CellEditor = new KDTDefaultCellEditor(
				kdtEntrys_locationhouse_PromptBox);
		this.kdtEntrys.getCell(rowIndex, "locationhouse").setEditor(
				kdtEntrys_locationhouse_CellEditor);

	}

//更新事件
public void kdtEntrys_Changed(int rowIndex, int colIndex) throws Exception {
		if ("warehouse"
				.equalsIgnoreCase(kdtEntrys.getColumn(colIndex).getKey())) {
			locationhouseCellF7(rowIndex, this.kdtEntrys.getCell(rowIndex,
					colIndex).getValue());
		}
	}

  d)重写beforeStoreFields(ActionEvent e)方法进行必输项验证 ,同样也可以使用重写verifyInput(ActionEvent e)的方法;

/**
	 * 分录必输项检查
	 */
	@Override
	protected void beforeStoreFields(ActionEvent arg0) throws Exception {
		for (int i = 0, n = kdtEntrys.getRowCount(); i < n; i++) {
			if (kdtEntrys.getCell(i, "locationhouse").getStyleAttributes()
					.getBackground().equals(new Color(252, 251, 223))
					&& com.kingdee.bos.ui.face.UIRuleUtil.isNull(kdtEntrys
							.getCell(i, "locationhouse").getValue())) {
				throw new com.kingdee.eas.common.EASBizException(
						com.kingdee.eas.common.EASBizException.CHECKBLANK,
						new Object[] { "库位" });
			}
		}
		super.beforeStoreFields(arg0);
	}

  e)分录单元格级的F7并不会在打开单据时触发。这样会影响我们的级联,所以要想办法让它执行,如下:

  在loadFields()方法中,执行一下单元格级F7。loadFields()在执行将数据加载到界面UI控件。load是用来加载界面信息,只执行一次。在执行保存时,不会再次触发。所以使用loadFields();

public void loadFields() {
		super.loadFields();
		for (int i = 0, n = kdtEntrys.getRowCount(); i < n; i++) {
			locationhouseCellF7(i, this.kdtEntrys.getCell(i, "warehouse")
					.getValue());
		}
	}

  f)在构造方法中调用我们写的方法

public F7EntryFilterEditUI() throws Exception {
		super();
		initF7();
                locationhouseF7(null);          
	}

 3、完成后,刷新启动服务,即可实现F7动态级联,并实现动态改必输校验。

PS:以上功能有个难点未实现,就是分录单元格设置必输项。如果是表头设置 .setRequired(true) 就可以了,但如果是分录,并没有这个方法,研究多时,不得法;

本实例,只是为单元格添加了一个底色。如有同行知道如何设置,请评论,感激不尽。

转载于:https://www.cnblogs.com/simple-point/p/9310053.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值