EAS BOS F7 過濾 動態 級聯 詳細使用

文經過幾個小例子來說解金蝶EAS BOS 開發F7控件的過濾使用;java

一、新建一張業務單據,存在兩個F7控件,基本庫位屬於倉庫,只有選擇了倉庫才,能肯定庫位。發佈業務單元,以下:app

二、打開JAVA視圖,找到EDITUI JAVA文件,新增方法ide

  a)首先爲倉庫添加過濾,prmtwarehouse爲倉庫F7,並添加監聽事件。ui

 
private void initF7() {
		EntityViewInfo entityView = new EntityViewInfo();
		FilterInfo filter = new FilterInfo();
		 filter.getFilterItems().add(new
		 FilterItemInfo("number","A2%",CompareType.LIKE));
		entityView.setFilter(filter);
		prmtwarehouse.setEntityViewInfo(entityView);
		prmtwarehouse.addDataChangeListener(new DataChangeListener() {
			public void dataChanged(DataChangeEvent e) {
				datachangeAction_dataChanged(e);
			}
		});
	}

  b)爲庫位添加過濾,prmtlocationhouse爲庫位F7;並根據F7是否存在可選項,進行必輸、默認值設置;this

private void locationhouseF7(String warehouseid) {
		EntityViewInfo entityView = locationhouseF7Judge(warehouseid);
		prmtlocationhouse.setEntityViewInfo(entityView);
		try {
			LocationCollection local = LocationFactory.getRemoteInstance()
					.getLocationCollection(entityView);

			if (local.size() > 0) {
				prmtlocationhouse.setRequired(true);
				prmtlocationhouse.setValue(local.get(0));
			} else {
				prmtlocationhouse.setRequired(false);
			}
		} catch (BOSException e1) {
			e1.printStackTrace();
		}
	}
	private EntityViewInfo locationhouseF7Judge(String warehouseid) {
		EntityViewInfo entityView = new EntityViewInfo();
		FilterInfo filter = new FilterInfo();
		filter.getFilterItems().add(
				new FilterItemInfo("WAREHOUSE.id", warehouseid,
						CompareType.EQUALS));
		entityView.setFilter(filter);
		return entityView;
	}

  c)新增倉庫F7更新事件方法code

public void datachangeAction_dataChanged(DataChangeEvent e) {
		try {
			Object source = e.getSource();

			if ((e.getOldValue() != null)
					&& (e.getOldValue().equals(e.getNewValue()))) {
				return;
			}
			if (this.prmtwarehouse.equals(source)) {
				if (e.getNewValue() == null) {
					prmtlocationhouse.setValue(null);
					locationhouseF7(null);
				} else {
					String warehouseid = ((WarehouseInfo) e.getNewValue())
							.getId().toString();
					prmtlocationhouse.setValue(null);
					locationhouseF7(warehouseid);
				}

			}
		} catch (Exception exc) {
			handUIException(exc);
		}
	}

  d)重寫verifyInput(ActionEvent e)方法進行必輸項驗證blog

@Override
	protected void verifyInput(ActionEvent e) throws Exception {
		EntityViewInfo entityView;
		if(com.kingdee.bos.ui.face.UIRuleUtil.isNull(editData
				.getWarehouse())){
			entityView = locationhouseF7Judge(null);
		}else{
			entityView = locationhouseF7Judge(editData
					.getWarehouse().getId().toString());
		}
		
		try {
			LocationCollection local = LocationFactory.getRemoteInstance()
					.getLocationCollection(entityView);
			if (local.size() > 0) {
				if (com.kingdee.bos.ui.face.UIRuleUtil.isNull(editData
						.getLocationhouse())) {
					throw new com.kingdee.eas.common.EASBizException(
							com.kingdee.eas.common.EASBizException.CHECKBLANK,
							new Object[] { "庫位" });

				}
			}
		} catch (BOSException e1) {
			e1.printStackTrace();
		}
	}

  e)在EDITUI構造方法中調用建立的方法事件

  

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

 三、完成後,刷新啓動服務,便可實現F7動態級聯,並實現動態改必輸校驗。開發

 -----------------------------------------get

附加一個自定義Query小知識:只須要將須要從新綁定的Query,從新set一下就能夠了。

private void initF7() {
		this.prmtwarehouse.setQueryInfo("com.kingdee.eas.demo.f7.app.warehouseUserDefine");		
     。。。。。。      
}

 PS:自定義Query的一個注意事項,不能設置id不可見,否則選擇時,會提示報錯。

相關文章
相關標籤/搜索