<div class="layui-fluid">
	<div class="layui-card">
		<div class="layui-card-header">结算批次</div>
		<div class="layui-card-body">
			<table id="LAY-settle-catelist-table" lay-filter="LAY-settle-catelist-table"></table>
			<script type="text/html" id="agentcountTpl">
				{{d.settle_agent_count}}
					</script>
			<script type="text/html" id="agentsumTpl">
				{{d.settle_agent_sum==null ? '0.00' : d.settle_agent_sum}}
					</script>
			<script type="text/html" id="setTpl">
				<a class="layui-btn layui-btn-normal layui-btn-xs" lay-event="agent"><i class="layui-icon layui-icon-log"></i>名单</a>
					</script>
		</div>
	</div>
</div>

<script>
	layui.config({
		base: '/static/echoui/' //静态资源所在路径
	}).extend({
		index: 'lib/index' //主入口模块
	}).use(['index', 'form', 'set', 'table'], function() {
		var $ = layui.$,
			setter = layui.setter,
			admin = layui.admin,
			form = layui.form,
			table = layui.table;
		form.render();

		table.render({
			elem: '#LAY-settle-catelist-table',
			url: setter.baseAgentUrl + 'settle/listcate',
			cols: [
				[
					{ field: 'id', width: 80, title: '表ID', sort: true },
					{ field: 'title', title: '批次名称' },
					{ field: 'agentcount', title: '名单数量', templet: '#agentcountTpl', width: 150, align: 'center' },
					{ field: 'agentsum', title: '实结金额', templet: '#agentsumTpl', width: 150, align: 'right' },
					{ field: 'remark', title: '备注信息' },
					{ title: '操作', width: 100, align: 'center', fixed: 'right', toolbar: '#setTpl' }
				]
			],
			page: true,
			limit: 50,
			cellMinWidth: 200,
			text: '对不起，加载出现异常！'
		});

		//监听工具条
		table.on('tool(LAY-settle-catelist-table)', function(obj) {
			var data = obj.data;
			if (obj.event === 'agent') {
				var index = layer.open({
					type: 2,
					title: '批次名单',
					content: 'agentlist.html?cateid=' + data.id,
					maxmin: true,
					area: ['550px', '550px']
				});
				layer.full(index);
			}
		});

		$('.layui-btn.layuiadmin-btn').on('click', function() {
			var type = $(this).data('type');
			active[type] ? active[type].call(this) : '';
		});
	});
</script>
