<title>个人统计</title>

<div class="layui-card layadmin-header">
	<div class="layui-breadcrumb" lay-filter="breadcrumb">
		<a lay-href="">统计</a>
		<a><cite>个人统计</cite></a>
	</div>
</div>

<div class="layui-fluid">
	<div class="layui-card">
		<div class="layui-form layui-card-header layuiadmin-card-header-auto" lay-filter="layadmin-userfront-formlist">
			<div class="layui-form-item">
				<div class="layui-inline">
					<div class="layui-input-inline">
						<div class="layui-input-inline">
							<input type="text" name="create_day" class="layui-input" placeholder="订单创建时间" id="create" autocomplete="off">
						</div>
					</div>
				</div>
				<div class="layui-inline">
					<script type="text/html" template lay-url="{{ layui.setter.apidomain }}yyds/user/index" lay-done="layui.data.done(d);">
					<select name="uid">
						<option value="">录单人</option>
						{{# layui.each(d.data, function(index, item){ }}
						<option value="{{item.id}}">{{item.username}}</option>
						{{# }) }}
					</select>
					</script>
				</div>
				<div class="layui-inline">
					<button class="layui-btn layuiadmin-btn-useradmin" lay-submit lay-filter="LAY-user-front-search">
						<i class="layui-icon layui-icon-search layuiadmin-button-btn"></i>
					</button>
				</div>
			</div>
		</div>

		<div class="layui-card-body">
			<table id="LAY-data-person" lay-filter="LAY-data-person"></table>
		</div>
	</div>
</div>

<script>
	layui.data.done = function(d){
		classifyData = d.data;
		layui.use('form', function(){
			var form = layui.form;
			form.render('select');
		});
	};
	layui.use(['table', 'laydate'], function() {
		var $ = layui.$,
			admin = layui.admin,
			setter = layui.setter,
			view = layui.view,
			table = layui.table,
			laydate = layui.laydate,
			form = layui.form;

		//监听搜索
		form.on('submit(LAY-user-front-search)', function(data) {
			var field = data.field;
			//执行重载
			table.reload('LAY-data-person', {
				where: field
			});
		});

		laydate.render({
			elem: '#create',
			range: true
		});

		$('.layui-btn.layuiadmin-btn-useradmin').on('click', function() {
			var type = $(this).data('type');
			active[type] ? active[type].call(this) : '';
		});
		var rr = setter.request.tokenName,
			tt = setter.tableName;
		//订单列表
		table.render({
			elem: '#LAY-data-person',
			url: setter.apidomain + 'yyds/order/person',
			headers: {
				jtoken: layui.data(tt)[rr]
			},
			cols: [
				[{
					field: 'create_day',
					title: '日期',
					sort: true
				}, {
					field: 'nums',
					title: '订单数',
					sort: true
				}, {
					field: 'aprice',
					title: '订单总金额',
					sort: true
				}, {
					field: 'dprice',
					title: '剩余尾款总金额',
					sort: true
				}]
			],
			page: true,
			limit: 20,
			limits: [20, 50, 100, 1000],
			toolbar: true
		});
	});
</script>
