<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
    <%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>数据列表</title>
 <%@include file="/views/common.jsp"%>
<style type="text/css">
	.layui-table-cell{
		height:32px;
		line-height:32px;
	}
	.layui-table td, .layui-table th,.layui-table-header, .layui-table-page,.layui-table-tool, .layui-table-total, .layui-table-view{
		border-color:#6666;
		font-size:16px;
	}
    .edge .layui-edge{
		right:35px;
	}
	.layui-input-inline,.layui-form-label{
		margin-top:10px;
	}
	/* 表格内数据超出换行 */
	.layui-table-cell {
	    height:auto;
	    overflow:visible;
	    text-overflow:inherit;
	    white-space:normal;
	    word-break: break-all;
	}
</style> 
</head>

<script type="text/html" id="toolbarDemo">
  <div class="layui-btn-container demoTable">
    <button class="layui-btn layui-btn-sm" lay-event="add"><i class="layui-icon layui-icon-add-circle-fine" style="font-size:20px;font-weight:bold"></i>新增数据</button>
  </div>
</script>
<script type="text/html" id="barDemo">
	<!-- 只有自己新增的数据才允许编辑删除 -->
  	<a class="layui-btn layui-btn-xs" lay-event="edit"><i class="layui-icon layui-icon-edit"style="color:white;font-size:20px"></i>编辑</a>
	<a class="layui-btn layui-btn-xs layui-btn-danger"" lay-event="del"><i class="layui-icon layui-icon-delete" ></i>删除</a>
</script>
<script type="text/html" id="isBuyTpl">
  <input type="checkbox" name="isBuy" value="{{d.id}}+{{d.username}}+{{d.isBuy}}" lay-skin="switch" lay-text="已成交|未成交" lay-filter="isBuyDemo" {{ d.isBuy == '1'? 'checked' : '' }}>
</script>
<body>
	<form class="layui-form" action="">
		<div class="layui-inline">
			<label class="layui-form-label">真实姓名</label>
			<div class="layui-input-inline">
				<input type="text" id="realname" name="realname" placeholder="请输入真实姓名"
					autocomplete="off" class="layui-input">
			</div>
		</div>
		<div class="layui-inline">
			<label class="layui-form-label">客户旺旺</label>
			<div class="layui-input-inline">
				<input type="text" id="wangwang" name="wangwang" placeholder="请输入客户旺旺"
					autocomplete="off" class="layui-input">
			</div>
		</div>
		<div class="layui-inline">
			<label class="layui-form-label">是否成交</label>
			<div class="layui-input-inline edge">
				<select name="isBuy" id="isBuy">
					<option value=""></option>
					<option value="0">未成交</option>
					<option value="1">已成交</option>
				</select>
			</div>
		</div>
		<div class="layui-inline">
			<label class="layui-form-label">录入时间</label>
			<div class="layui-input-inline edge">
                <select name="type" id="selectedOption" lay-filter="college">
                    <option value="day" selected="selected">按日统计</option>
                    <option value="dayRound">按日期范围统计</option>
                    <option value="week">按周统计</option>
                    <option value="month">按月统计</option>
                    <option value="quarter">按季度统计</option>
                    <option value="year">按年统计</option>
                </select>
            </div>
            <div class="layui-input-inline">
	            <label class="layui-inline" id="worldlable" style="width: 200px;">
	                <input id="worldId" type="text" class="layui-input laydate-test" data-type="date" autocomplete="off">
	            </label>
            </div>
        </div>
		<div class="layui-inline">
			<label class="layui-form-label">所属店铺</label>
			<div class="layui-input-inline edge">
				<select name="roleSearch" id="roleSearch" lay-search></select>
			</div>
			<input type="hidden" id="role" name="role" value="${sessionScope.USER_SESSION.role}" >
		</div>
		<div class="layui-inline">
			<div class="layui-input-inline">
				<button class="layui-btn" id="searchBtn" lay-submit
					lay-filter="formDemo" style="margin-left: 15px">
					<i class="layui-icon layui-icon-search"></i> 查询
				</button>
				<button type="reset" class="layui-btn layui-btn-primary">重置</button>
			</div>
		</div>
	</form>
	<table class="layui-hide" id="dataTable"lay-data="dataTable" lay-filter="dataTable"></table>
<script type="text/javascript">
	//全局定义一次, 加载xm-select
	layui.config({
	    base: '${path}/static/js/' //js文件的路径
	}).extend({
		xmSelect: 'xm-select'
	});
	
	//角色名称转换(放在layui.use里面js页面读取不到)
	var roleData = {};
	$.ajax({
		url : '${path}/changeRoleName',
		dataType : 'json',
		data : {
		}, 
		type : 'post',
		success : function(data) {
			roleData = data;
		}
	});
	
	// 下拉框第一列添加空的option
	$('#roleSearch').append(new Option("",""));
	layui.use([ 'form', 'layer','xmSelect' ],function() {
		var $ = layui.$,
		form = layui.form, 
		layer = layui.layer, 
		xmSelect = layui.xmSelect;
		
		//获取用户的角色
		$.ajax({
			url : '${path}/getUserRoles',
			dataType : 'json',
			data : {
				flag:"customerData"
			}, 
			type : 'get',
			success : function(data) {
				var datas = data.data.userRoleList
				$.each(datas, function(index, item) {
					$('#roleSearch').append(
							new Option(item.roleName, item.roleId));// 下拉菜单里添加元素
					});
				form.render("select");
			}
		});
	})	
	
	
	// 获取登录用户的用户名，带到js中判断
	var username;
	$(document).ready(function() {
		$.ajax({
			url : "${path}/loginAttribute",
			type : "get",
			success : function(obj) {
				username = obj.data.user.username;
			}
		})
	})
</script>
<script src="${path}/static/js/dateUtil.js" charset="utf-8"></script>
<script src="${path}/js/customerData.js" charset="utf-8"></script>

</body>
</html>