<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
	<th:block th:include="include :: header('用户列表')" />
	<th:block th:include="include :: layout-latest-css" />
	<th:block th:include="include :: ztree-css" />
</head>
<body class="gray-bg">
	<div class="ui-layout-center">
		<div class="container-div">
			<div class="row">
				<div class="col-sm-12 search-collapse">
					<form id="user-form">
						<input type="hidden" id="deptId" name="deptId">
		                <input type="hidden" id="parentId" name="parentId">
						<div class="select-list">
							<ul>
								<li>
									登录名称：<input type="text" name="loginName"/>
								</li>
								<li>
									用户名称：<input type="text" name="userName"/>
								</li>
								<li>
									手机号码：<input type="text" name="phonenumber"/>
								</li>
								<li>
									组织名称：<input type="text" name="sysUserExt.orgName"/>
								</li>
								<li>
									用户状态：<select name="status" th:with="type=${@dict.getType('sys_normal_disable')}">
										<option value="">所有</option>
										<option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
									</select>
								</li>
                                <li>
                                    用户级别：<select name="sysUserExt.salesLevel" th:with="type=${@dict.getType('sales_level')}">
                                    <option value="">所有</option>
                                    <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                                </select>
                                </li>
								<li class="select-time">
									<label>创建时间： </label>
									<input type="text" class="time-input" id="startTime" placeholder="开始时间" name="params[beginTime]"/>
									<span>-</span>
									<input type="text" class="time-input" id="endTime" placeholder="结束时间" name="params[endTime]"/>
								</li>
								<li>
									<a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
								    <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
								</li>
							</ul>
						</div>
					</form>
				</div>
		        
		        <div class="col-sm-12 select-table table-striped">
				    <table id="bootstrap-table"></table>
				</div>

				<input id="selectUserId" type="hidden">
			</div>
		</div>
	</div>
	
	<th:block th:include="include :: footer" />
	<th:block th:include="include :: layout-latest-js" />
	<th:block th:include="include :: ztree-js" />

	<script th:inline="javascript">

        var salesLevelDict = [[${@dict.getType('sales_level')}]];//销售人员等级
        var datas = [[${@dict.getType('sys_yes_no')}]];
		var prefix = ctx + "system/user";

		$(function() {
		    queryUserList();

		});

		function queryUserList() {
		    var options = {
		        url: prefix + "/list",
		        sortName: "createTime",
		        sortOrder: "desc",
		        modalName: "用户",
                clickToSelect: true,
                singleSelect:true,
                onClickRow:function (row,$element) {
                    $("#selectUserId").val(row.userId);
                    $('.info').removeClass('info');
                    $($element).addClass('info')
                },
		        columns: [{
		            checkbox: false
		        },
				{
					field: 'userId',
					visible:false,
				},
		        {
		            field: 'loginName',
		            title: '登录名称',
		            sortable: true
		        },
		        {
		            field: 'userName',
		            title: '用户名称'
		        },
		        {
		            field: 'dept.deptName',
		            title: '部门'
		        },
		        {
		            field: 'email',
		            title: '邮箱',
		            visible: false
		        },
		       /* {
		            field: 'phonenumber',
		            title: '手机'
		        },*/
					{
						field: 'quit',
						width: 90,
						title: '是否离职',
						align: 'center',
						formatter: function(value, row, index) {
							if (value==2){
								return '是';
							}else{
								return '否';
							}
						}
					},
		         {
		             field: 'sysUserExt.salesLevel',
		             title: '销售人员等级',
                     formatter: function(value, row, index) {
                         return $.table.selectDictLabel(salesLevelDict, value);
                     }
		         },
                {
                    field: 'sysUserExt.orgName',
                    title: '组织名称'
                },
                {
                    field: 'sysUserExt.orgCode',
                    title: '组织code'
                },
                    {
                        field: 'sysUserExt.isCustomerManager',
                        title: '是否是负责人',
                        formatter: function(value, row, index) {
                            if (value==1){
                                return "是";
							} else if (value==0){
                                return "否";
							} else {
                                return "-";
							}
                        }
                    }]
		    };
		    $.table.init(options);
		}



	</script>
</body>

</html>