 /**  
 * @fileOverview "processUse"
 * @author tan
 * @version 1.0  
 */  
 /**  
 * @author tan  
 * @constructor processUse
 * @description "processUse"
 * @date 2010-11-17
 * @since version 1.0 
 */
var processUse=function(){
		
	/**
	 * @description 流程下拉选择
	 */
	this.getProcess=function(select){

		$('#'+select).html('');
		$('<option value="">--'+i18n['pleaseSelect']+'--</option>').appendTo('#'+select);
		$.post('upload!findProcessDefinitions.action',function(process){
			if(process.processPageDto!=null){
				if(process.processPageDto.data.length>0){
					for(var i=0;i<process.processPageDto.data.length;i++){
						if(process.processPageDto.data[i].name.lastIndexOf('request')>=0 || process.processPageDto.data[i].name.lastIndexOf('Request')>=0)
							$('<option value="'+process.processPageDto.data[i].key+'">'+process.processPageDto.data[i].name+'</option>').appendTo('#'+select);
					}
				}
			}
		});
	}
	
	/**
	 * @description 保存设置
	 */
	this.processUseSet=function(form){
		var frm = $('#'+form+' form').serialize();
		$.post('upload!pricessUseSet.action',frm,function(){
			
			msgShow(i18n['saveSuccess'],'show');
		});
	}
	
	this.processUseBy=function(id,select){
		$.post('upload!pricessUseById.action','processUseDTO.processUseNo='+id,function(data){
			$('#'+select).val(data.processKey);
		})
	}
	
	
	
	//载入
	return {
		init: function() 
		{	
			$("#processUse_loading").hide();
			$("#processUse_content").show();
			getProcess("processKey");
			
			setTimeout(function(){
				processUseBy(1,"processKey");
			},500);
			
		}
	}
}();

$(document).ready(processUse.init);