$("#addPloy").click(function(){
		layer.open({
		  type: 2,
		  title: '新增模板',
		  shadeClose: true,
		  shade: 0.3,
		  area: ['650px', '500px'],
		  maxmin : false,
		  content: 'addploy', 
		  scrollbar: false,
		  end:function(){
			  queryPloy();
		  }
		});
	});

$(document).ready(function(){
	queryPloy();
});

function queryPloy(){
	jQuery.ajax({
		type : 'POST',
		dataType : "json",
		url : '/pqs9200/report/queryPloy',
		data : {},
		beforeSend: function () {  
            i = ityzl_SHOW_LOAD_LAYER();  
        },
		async:false,
		success : function(data) {
				var oTable=$('#example').DataTable({
					scrollX : true,
					lengthChange : false,
					bDestroy : true,
					ordering : false,
					columnDefs : [ {
						targets : [ ],
						visible : false
					} ],
					data : data.body,
					destroy : true,
					lengthMenu : [ 12 ],
					language : {
						url:'/pqs9200/json/chine.json'
					},
					'fnDrawCallback': function(oTable) {    
					    $("#example_paginate").append("<div style='float:right;padding-top:4px;padding-left:10px'>到第 <input type='text' id='changePage' class='input-text' style='width:50px;height:28px;'> 页  <button class='btn btn-primary' id='dataTable-btn'>确定</button></div>");    
					    var table = $("#vdlist").dataTable();    
					    $('#dataTable-btn').click(function(e) {
					        if($("#changePage").val() && $("#changePage").val() > 0) {    
					            var redirectpage = $("#changePage").val() - 1;    
					        } else {    
					            var redirectpage = 0;    
					        }    
					        table.fnPageChange(redirectpage);
					    });    
					}
				});
				
			//***********关闭loading
        	ityzl_CLOSE_LOAD_LAYER(i); 
			}
		})
}


function updateRpPloy(index){
	layer.open({
		  type: 2,
		  title: '修改模板信息',
		  shadeClose: true,
		  area : ['650px', '500px'],
          offset: '0px',
		  maxmin : false,
		  content: 'modrpploy?rpIndex='+index, 
		  scrollbar: false,
		  end:function(){
			  var tmp = 0;
			  queryPloy(tmp);
		  }
	});
}

function deleteRpPloy(index){
	layer.confirm('是否确认？',function(){
		$.ajax({
			method : "post",
			url : "/pqs9200/report/delRdPloy",
			data : {
				rpIndex:index
			},
			async:false,
			success : function(data) {
				if(data.code==200){
					layer.msg('删除成功!',{icon:1,time:1000});
					var tmp = 0;
					queryPloy(tmp);
				}else{
					layer.msg('删除失败！',{icon:2,time:1000});
				}
			}
		})
	})
}