货架控件根据选择的区域来决定是否格式化显示

1、FreeTextBox定义2个控件txt_LocBothFrom 和 txt_LocBothTo

txt_LocBothFrom 


txt_LocBothTo

货架控件根据选择的区域来决定是否格式化显示_第1张图片


2、jsp页面添加js控制

<script language="javascript" type="text/javascript">
<!--
function locationFocusFrom(){
	document.getElementById('txt_LocationFrom').maxLength=8;
	formatTextBoxOnfocus('txt_LocationFrom');
	return true;
}

function locationBlurFrom(){
	var areaNoValue=getSelectedArea();
	var valueArray = areaNoValue.split("_")
	if(valueArray[0] == "1"){
		document.getElementById('txt_LocationFrom').maxLength=10; 
		if(!formatTextBoxCheck('txt_LocationFrom',valueArray[1],'请以正确格式进行输入')){
			return false;
		}
		document.all('txt_LocationFrom').value = getFormat(document.all('txt_LocationFrom').value, valueArray[1], '-' ); 
	}
	return true;
}

function locationFocusTo(){
	document.getElementById('txt_LocationTo').maxLength=8;
	formatTextBoxOnfocus('txt_LocationTo');
	return true;
}

function locationBlurTo(){
	var areaNoValue=getSelectedArea();
	var valueArray = areaNoValue.split("_")
	if(valueArray[0] == "1"){
		document.getElementById('txt_LocationTo').maxLength=10; 
		if(!formatTextBoxCheck('txt_LocationTo',valueArray[1],'请以正确格式进行输入')){
			return false;
		}
		document.all('txt_LocationTo').value = getFormat(document.all('txt_LocationTo').value, valueArray[1], '-' ); 
	}
	return true;
}

function getSelectedArea(){
	var areaNoValue="";
	var oListbox = document.getElementById("pul_PickArea")
    for (var i=0; i < oListbox.options.length; i++) {
        if (oListbox.options[i].selected) {
        	areaNoValue = oListbox.options[i].value;
        }
    }
	
	return areaNoValue;
}
//-->
</script>

3、区域的下拉框的值格式({areatype}_{location_style}_{areano})

/***
 * 盘点区域PullDownModel
 * @author GongQiang
 *
 */
public class OrionSYPickAreaPullDownModel extends PullDownModel {

	public OrionSYPickAreaPullDownModel(PullDownBehavior pdown,
			Locale locale, DfkUserInfo ui) {
		super(pdown, locale, ui);
	}

	/***
	 * params[0]:99显示[全部]
	 * params[1]:location_type的值(0,4)
	 */
	@Override
	public void init(Connection conn, Object... params) throws CommonException {
		if( params == null || params.length <2 ){
			throw new IllegalArgumentException( "params error." );
		}
		
		String value = "";
		PullDownItem item = new PullDownItem();
        if(ParameterDefine.SEARCH_ALL.equals(params[0])){
            // CMB-W0023=全区域
        	value = WmsParam.ALL_AREA_NO+"_"+WmsParam.ALL_AREA_NO+"_"+WmsParam.ALL_AREA_NO;
            item.setValue(value);
            item.setText(WmsParam.ALL_AREA_NO + ":" + DisplayText.getText("CMB-W0023"));
            ((PullDown)getPullDown()).addItem(item);
        }
        
        Area[] areas = getArea(conn, (String)params[1]);
        for(Area ar:areas){
        	item = new PullDownItem();
        	value = ar.getAreaType() + "_" + ar.getLocationStyle() + "_" + ar.getAreaNo();
        	item.setValue( value );
        	item.setText( ar.getAreaNo() + ":" + ar.getAreaName() );
        	((PullDown)getPullDown()).addItem(item);
        }
        
        getPullDown().setSelectedIndex(0);
	}

	private Area[] getArea(Connection conn, String locationType ) throws ReadWriteException{
		AreaHandler handler = new AreaHandler(conn);
		AreaSearchKey key = new AreaSearchKey();
		if( SystemDefine.LOCATION_TYPE_NEW.equals(locationType) ){
			//立体库一定是有托盘管理的
			key.setLocationType( new String[]{SystemDefine.LOCATION_TYPE_MASTER,SystemDefine.LOCATION_TYPE_NEW} );
		}
		else{
			key.setLocationType( locationType );
		}
		key.setIsEnable( ParameterDefine.YES );
		key.setAreaNoOrder( true );
		
		return (Area[]) handler.find(key);
	}
}
4、页面效果

货架控件根据选择的区域来决定是否格式化显示_第2张图片




你可能感兴趣的:(货架控件根据选择的区域来决定是否格式化显示)