
function viewImg(deploymentId,resourceName){
    window.open('/flowable/processDefinition/viewImg?deploymentId='+deploymentId+'&resourceName='+resourceName,"_blank")
}
function viewFlowActDef(id){
	$(".yk_rightcontent").load('/flowable/processDefinition/viewFlowActDef?procDefId='+id)
}
$(function(){
	function loadData(){
		$('#processList').setGridParam({
            mtype:'GET',
			url : '/flowable/processDefinition/doList',
			datatype : 'json',
			postData: {},
			page : 1
		});
		$('#processList').trigger('reloadGrid');
	}
	function operationFmatter(cellvalue, options, rowObject){
		return '<div class="operateIcon noHover">'+
					'<p><span style="display: none;">查看流程图</span><i class="operateIconfont operateIcon-chakan" onclick="viewImg('+rowObject.deploymentId+',\''+rowObject.diagramResourceName+'\')"></i></p>'+
					'<p><span style="display: none;">流程节点</span><i class="operateIconfont operateIcon-liucheng" onclick="viewFlowActDef(\''+rowObject.id+'\')"></i></p>'+
				'</div>';
	};
	
	sxUtil.jqGrid('#processList',{
		colNames:['主键ID','序号','部署ID','部署资源图片名称','流程定义名称','版本','操作'],
		colModel:[
			{name: 'id', label: '主键ID', hidedlg:true, hidden:true,sortable:false,title:false},
			{name: 'orderNumber', label: '序号', width:70,sortable:false,title:false},
			{name: 'deploymentId',label: '部署ID', hidedlg:true, hidden:true,sortable:false,title:false },
			{name: 'diagramResourceName',label: '部署资源图片名称', hidedlg:true, hidden:true,sortable:false,title:false },
			{name: 'name', label: '流程定义名称',sortable:false,align:'left',title:false},
            {name: 'version', label: '版本',sortable:false,align:'center',width:70,title:false},
            {name: 'enabledDisplayNames', label: '操作',formatter:operationFmatter,sortable:false,align:'center',width:150,title:false}
		],
		height:'auto',
        mtype:'GET',
		url : '/flowable/processDefinition/doList',
		pager : '#processListPage',
		multiselect: false,
		rownumbers:false,
		postData : {},
		page:mylistpage,
		loadError:function(){
			new $.zui.Messager('列表加载失败', {
			    type: 'warning',
			    time:1500
			}).show();
		},
		onPaging:function(pgButton){
			console.log(pgButton)
		}
	},true);
	
	//刷新
	$('#refresh').click(function(){
		$('#processList').jqGrid('setGridParam',{ 
            mtype:'GET',
            url : '/flowable/processDefinition/doList',
            postData: {},
            page:1 
        }).trigger('reloadGrid'); //重新载入

	});
	/* 新增按钮点击 */
	$('#processAddBtn').click(function(){
        mylistpage = $('#processList').getGridParam('page');
		 $(".processDialog").load('/flowable/processDefinition/deploy',function(){
			 $("#myModal-addprocessInfor").modal("show");
		 }); 
	})
})
	