<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-report-orderlist-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="factoryid" lay-search>
							<option value="">全部招聘工厂（可搜索）</option>
							{volist name="factorylist" id="vo"}
							<option value="{$vo['id']}">{$vo['title']}</option>
							{/volist}
						</select>
					</div>
				</div>
				<div class="layui-inline">
					<label class="layui-form-label">返费模式</label>
					<div class="layui-input-block">
						<select name="reftype">
							<option value="">全部模式</option>
							<option value="1">小时工</option>
							<option value="2">一次性</option>
							<option value="3">管理费</option>
						</select>
					</div>
				</div>
				<div class="layui-inline">
					<label class="layui-form-label">状态</label>
					<div class="layui-input-block">
						<select name="status">
							<option value="">全部状态</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-report-orderlist-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-report-orderlist-table" lay-filter="LAY-report-orderlist-table"></table>
			<script type="text/html" id="factorytitleTpl">
				{{d.factoryid==0 ? '' : d.reportFactory.title}}
					</script>
			<script type="text/html" id="logrefpolicyTpl">
				{{d.reportOrderlog[0].refpolicy}}
					</script>
			<script type="text/html" id="logcreatetimeTpl">
				{{d.reportOrderlog[0].createtime}}
					</script>
			<script type="text/html" id="setTpl">
				<a class="layui-btn layui-btn-normal layui-btn-xs" lay-event="edit"><i class="layui-icon layui-icon-edit"></i>详情</a>
					</script>
		</div>

	</div>
</div>

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

		table.render({
			elem: '#LAY-report-orderlist-table',
			url: setter.baseAgentUrl + 'report/listorder',
			cols: [
				[
					{ field: 'id', width: 80, title: '表ID', sort: true },
					{ field: 'title', minWidth: 200, title: '发单标题' },
					{ field: 'factorytitle', minWidth: 200, title: '招聘工厂', templet: '#factorytitleTpl' },
					{ field: 'startdate', width: 170, title: '招聘日期' },
					{ field: 'reftype_text', title: '返费模式', width: 100, align: 'center' },
					{ field: 'status_text', title: '状态', width: 80, align: 'center' },
					// {field: 'logrefpolicy', title: '当前返费政策', templet: '#logrefpolicyTpl', width: 200},
					// {field: 'logcreatetime', title: '最近更新时间', templet: '#logcreatetimeTpl', width: 170, sort: true},
					{ title: '操作', width: 100, align: 'center', fixed: 'right', toolbar: '#setTpl' }
				]
			],
			page: true,
			limit: 50,
			toolbar: true,
			defaultToolbar: ['filter', 'print'],
			cellMinWidth: 150,
			text: '对不起，加载出现异常！'
		});

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

		table.on('tool(LAY-report-orderlist-table)', function(obj) {
			var data = obj.data;
			if (obj.event === 'edit') {
				var index = layer.open({
					type: 2,
					title: data.title,
					content: 'orderdetails.html?id=' + 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>
