$(function() {
	$.ajaxSetup({
	  async: false
	});
	var ERROK = 200;
	var contextPath = $("#contextPath").val()
	var table;
	var _dataArr = []; //当前数据集合
	var _jiduArr = []; //当前数据集合


	var initObj = {
		init: function() {
			this.rendertable();
		},
		rendertable: function() {
			layui.use('table', function() {
				table = layui.table;
				//方法级渲染
				table.render({
					elem: '#LAY_table_user',
					url: $("#contextPath").val() + "/admin/virtual/getVirtualArchAgent",
					where: {},
					method: "post",
					skin: 'nob', //行边框风格
					even: true,//开启隔行背景
					size: 'lg', //小尺寸的表格
					cols: [
						[{
							field: 'index',
							title: '序号',
							width: '80',
							fixed: 'left',
							templet: '#indexTpl'
						},{
							field: 'name',
							title: '企业名称',
							minWidth: 200
						},{
							field: 'room_area',
							title: '代理面积',
							minWidth: 150,
						},{
							field: 'range_name',
							title: '代理区域',
							minWidth: 150,
						},{
							field: 'relation_count',
							title: '关联企业数',
							minWidth: 150
						},{
							field: 'relation_name',
							title: '关联企业',
							minWidth: 150
						}]
					],
					id: 'testReload',
					page: true,
					response: {
						statusName: 'code' //数据状态的字段名称，默认：code
							,
						statusCode: 200 //成功的状态码，默认：0
							,
						countName: "count" //数据总数的字段名称，默认：count
							,
						dataName: "data" //数据列表的字段名称，默认：data
					},
					request: {
						pageName: 'pageNo' //页码的参数名称，默认：page
							,
						limitName: 'pageSize' //每页数据量的参数名，默认：limit
					},
					done: function(res, curr, count) {
						$('.optionSelect').val('')
						if(res && res.code==200 && res.data){
							var itemArr = []
							var orgNameArr = []
							var length = res.data.length
							var page_length = $('.layui-laypage-limits select').eq(0).val()
							for (var i = (page_length - length) - 1; i >= 0; i--) {
								res.data.push({})
							}
							_dataArr = res.data
							res.data.forEach(function(item,index,arr){
								itemArr.push(item.sumVirCount || '0')
								orgNameArr.push(item.orgName || '')
							})
						}
					}
				});
			});
		},
	};
	initObj.init();
})