<div class="layui-fluid">
	<div class="layui-card">
		<div class="layui-form layui-form-pane layui-card-header layuiadmin-card-header-auto" lay-filter="LAY-broker-cashlist-search">
			<div class="layui-form-item">
				<div class="layui-inline">
					<label class="layui-form-label">状态</label>
					<div class="layui-input-block">
						<select name="status">
							<option value="">全部状态</option>
							<option value="1">待处理</option>
							<option value="2">已成功</option>
							<option value="3">已拒绝</option>
						</select>
					</div>
				</div>
				<div class="layui-inline">
					<button class="layui-btn" lay-submit lay-filter="LAY-broker-cashlist-btn">
						<i class="layui-icon layui-icon-search layuiadmin-button-btn"></i>
					</button>
				</div>
			</div>
		</div>

		<div class="layui-card-body">

			<table id="LAY-broker-cashlist-table" lay-filter="LAY-broker-cashlist-table"></table>
			<script type="text/html" id="brokerTpl">
				{{d.broker.title}} - {{d.broker.mobile}}
			</script>
			<script type="text/html" id="setTpl">
				{{#  if(d.status == 1){ }}
					<a class="layui-btn layui-btn-normal layui-btn-xs" lay-event="examine"><i class="layui-icon layui-icon-edit"></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-broker-cashlist-table',
			url: setter.baseAdminUrl + 'broker/listCash',
			cols: [
				[
					{ field: 'id', width: 80, title: '表ID', sort: true },
					{ field: 'broker', title: '经纪人', templet: '#brokerTpl', minWidth: 200, align: 'left' },
					{ field: 'title', title: '标题', width: 150, align: 'center' },
					{ field: 'value', title: '金额', width: 100, align: 'center' },
					{ field: 'status_text', title: '状态', width: 100, align: 'center' },
					{ field: 'remark', title: '备注', align: 'center' },
					{ field: 'createtime', title: '创建时间', width: 170 },
					{ title: '操作', width: 100, align: 'center', fixed: 'right', toolbar: '#setTpl' }
				]
			],
			page: true,
			limit: 50,
			cellMinWidth: 150,
			text: '对不起，加载出现异常！'
		});

		form.on('submit(LAY-broker-cashlist-btn)', function(data) {
			table.reload('LAY-broker-cashlist-table', {
				where: data.field,
				page: {
					curr: 1
				}
			});
		});

		table.on('tool(LAY-broker-cashlist-table)', function(obj) {
			var data = obj.data;
			if (obj.event === 'examine') {
				var index = layer.open({
					type: 2,
					title: '审核',
					content: 'examineCash.html?id=' + data.id,
					maxmin: true,
					area: ['750px', '380px']
				});
			}
		});

	});
</script>
