
// 跳转到详情页面
function updateInsurance(id){
	$(".yk_rightcontent").load('/creditInsurance/corp/update?id='+id)
}

//跳转到查看页面
function viewInsurance(id){
	window.open('/creditInsurance/corp/view?id='+id)
}

$(function(){
	function loadSendData(){
		$('#insuranceList').setGridParam({
			mtype:'GET',
			url : '/creditInsurance/corp/doList',
			datatype : 'json',
			postData: {},
			page : 1
		});
		$('#insuranceList').trigger('reloadGrid');
	};
	
	function operateInsurance(cellValue,options,rowObject){
		var btnstr = '';
		btnstr += '<p><span>查看</span><i class="operateIconfont operateIcon-chakan" onclick="viewInsurance('+rowObject.id+')"></i></p>';
		if( $('#updateInsuranceCorp').length>0 ){
			btnstr += '<p><span>修改</span><i class="operateIconfont operateIcon-bianji" onclick="updateInsurance('+rowObject.id+')"></i></p>';
		};
		return '<div class="operateIcon noHover">'+btnstr+'</div>';
	};
	
	sxUtil.jqGrid('#insuranceList',{
		colNames:['ID','序号','保险公司名称','操作'],
		colModel:[
			{name: 'id', label: 'ID', hidedlg:true, hidden:true,sortable:false,title:false},
			{name: 'orderNumber', label: '序号',sortable:false,width:150,align:'center',title:false},
            {name: 'name', label: '保险公司名称',sortable:false,align:'left',width:450,title:false},
            {name: 'remark', label: '操作',sortable:false,align:'left',width:200,title:false,formatter:operateInsurance}
		], 
		height:'auto',
		mtype:'GET',
		url : '/creditInsurance/corp/doList',
		pager : "#insuranceListPage",
		multiselect: false,
		rownumbers:false,
		postData : {},
		page:mylistpage,
		loadError:function(){
			new $.zui.Messager('保险公司列表加载失败', {
			    type: 'warning'
			}).show();
		}
	},true);
	
	//刷新
	$('#refresh').click(function(){
		loadSendData()
	});
	
	// 进入新增页面
	$("#addInsurance").click(function(){
		mylistpage = $('#insuranceList').getGridParam('page');
		$(".yk_rightcontent").load('/creditInsurance/corp/add')
	});

})