<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-out-resumelist-search">
			<div class="layui-form-item">
				<div class="layui-inline">
					<label class="layui-form-label">标题</label>
					<div class="layui-input-block">
						<input type="text" name="keywords" placeholder="请输入姓名或电话" autocomplete="off" class="layui-input">
					</div>
				</div>
				<div class="layui-inline">
					<label class="layui-form-label">状态</label>
					<div class="layui-input-block">
						<select name="confirm_status">
							<option value="">全部状态</option>
							{volist name="statuslist" id="vo"}
							<option value="{$key}">{$vo}</option>
							{/volist}
						</select>
					</div>
				</div>
				<div class="layui-inline">
					<button class="layui-btn" lay-submit lay-filter="LAY-out-resumelist-search-btn">
						<i class="layui-icon layui-icon-search layuiadmin-button-btn"></i>
					</button>
				</div>
			</div>
		</div>

		<div class="layui-card-body">
			<table id="LAY-out-resumelist-table" lay-filter="LAY-out-resumelist-table"></table>
			<script type="text/html" id="broker">
				{{d.broker.title}}（{{d.broker.mobile}}）
			</script>
			<script type="text/html" id="setTpl">
				{{#  if(d.confirm_status == 1){ }}
					<a class="layui-btn layui-btn-normal layui-btn-xs" lay-event="pass"><i class="layui-icon layui-icon-edit"></i>通过</a>
					<a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="reject"><i class="layui-icon layui-icon-delete"></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-out-resumelist-table',
			url: setter.baseAgentUrl + 'out/listResume',
			cols: [
				[
					{ title: '经纪人', align: 'center', toolbar: '#broker' },
					{ field: 'name', title: '姓名', width: 100},
					{ field: 'mobile', title: '联系方式', width: 160 },
					{ field: 'idcard', title: '身份证号', width: 220 },
					{ field: 'gender_text', title: '性别', width: 60 },
					{ field: 'confirm_status_text', title: '状态', width: 100, align: 'center' },
					{ field: 'jobintention', title: '求职意向', width: 200, align: 'center' },
					{ field: 'address', title: '现居住地', width: 200, align: 'center' },
					{ field: 'education', title: '学历', width: 100, align: 'center' },
					{ title: '操作', width: 150, align: 'center', fixed: 'right', toolbar: '#setTpl' }
				]
			],
			page: true,
			limit: 50,
			cellMinWidth: 150,
			text: '对不起，加载出现异常！'
		});

		//监听搜索
		form.on('submit(LAY-out-resumelist-search-btn)', function(data) {
			table.reload('LAY-out-resumelist-table', {
				where: data.field,
				page: {
					curr: 1
				}
			});
		});

		//监听工具条
		table.on('tool(LAY-out-resumelist-table)', function(obj) {
			var data = obj.data;
			if (obj.event === 'pass') {
				layer.confirm('通过核验，佣金将自动分配，确定通过吗？', function(index) {
					admin.req({
						url: setter.baseAgentUrl + 'out/statusresume',
						data: {
							id: data.id,
							status: 2,
						},
						done: function(res) {
							table.reload('LAY-out-resumelist-table');
							layer.msg('处理完成');
						}
					});
					layer.close(index);
				});
			} else if (obj.event === 'reject') {
				layer.confirm('核验失败，经纪人无法获得佣金，确定拒绝吗？', function(index) {
					admin.req({
						url: setter.baseAgentUrl + 'out/statusresume',
						data: {
							id: data.id,
							status: 3,
						},
						done: function(res) {
							table.reload('LAY-out-resumelist-table');
							layer.msg('处理完成');
						}
					});
					layer.close(index);
				});
			}
		});
	});
</script>
