<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/webpage/include/taglib.jsp"%>
<html>
<head>
	<title>用户管理</title>
	<meta name="decorator" content="default"/>
	<style type="text/css">
		img {
			max-width: 30px;
			max-height: 30px;
		}
	</style>
	<script type="text/javascript">
		$(document).ready(function() {
		//搜索框收放
            $('#moresee').click(function(){
                if($('#moresees').is(':visible'))
                {
                    $('#moresees').slideUp(0,resizeListWindow3);
                    $('#moresee i').removeClass("glyphicon glyphicon-menu-up").addClass("glyphicon glyphicon-menu-down");
                }else{
                    $('#moresees').slideDown(0,resizeListWindow3);
                    $('#moresee i').removeClass("glyphicon glyphicon-menu-down").addClass("glyphicon glyphicon-menu-up");
                }
            });
		});
	</script>
	<style>
		body{
			background-color:transparent;
			filter:progid:DXImageTransform.Microsoft.gradient(startColorstr=#26FFFFFF, endColorstr=#26FFFFFF);
			color:#ffffff;
			background-color:rgba(255,255,255,0);
			height:100%;
		}
	</style>
</head>
<body>
<div class="wrapper wrapper-content">
	<sys:message content="${message}"/>
	<div class="layui-row">
		<div class="full-width fl">
			<div class="contentShadow shadowB layui-row" id="queryDiv">

				<form:form id="searchForm" modelAttribute="user" action="${ctx}/sys/user/list" method="post" class="form-inline">
					<input id="pageNo" name="pageNo" type="hidden" value="${page.pageNo}"/>
					<input id="pageSize" name="pageSize" type="hidden" value="${page.pageSize}"/>
					<input id="company" name="user.company.id" type="hidden" value="${page.pageSize}"/>
					<table:sortColumn id="orderBy" name="orderBy" value="${page.orderBy}" callback="sortOrRefresh();"/><!-- 支持排序 -->

					<div class="commonQuery">
						<%--<div class="layui-item query athird">
							<label class="layui-form-label">归属分公司：</label>
							<div class="layui-input-block with-icon">
								<sys:treeselect id="branchOffice" name="branchOffice.id" value="${user.branchOffice.id}" labelName="branchOffice.name" labelValue="${user.branchOffice.name}"
												title="公司" url="/sys/office/treeDataCompany?type=2" cssClass=" form-control layui-input" allowClear="true"/>
							</div>
						</div>
						<div class="layui-item query athird">
							<label class="layui-form-label">归属部门：</label>
							<div class="layui-input-block with-icon">
								<sys:treeselect id="office" name="office.id" value="${user.office.id}" labelName="office.name" labelValue="${user.office.name}"
												title="部门" url="/sys/office/treeData?type=2" cssClass=" form-control layui-input" allowClear="true" notAllowSelectParent="true"/>
							</div>
						</div>--%>
						<div class="layui-item query athird">
							<label class="layui-form-label">姓  名：</label>
							<div class="layui-input-block">
								<form:input path="name" htmlEscape="false" maxlength="50" class=" form-control layui-input"/>
							</div>
						</div>
						<div class="layui-item query athird">
							<label class="layui-form-label">手  机：</label>
							<div class="layui-input-block">
								<form:input path="mobile" htmlEscape="false" maxlength="50" class=" form-control layui-input"/>
							</div>
						</div>

						<div class="layui-item athird">
							<div class="input-group">
								<a href="#" id="moresee"><i class="glyphicon glyphicon-menu-down"></i></a>
								<button id="searchReset" class="fixed-btn searchReset fr" onclick="resetSearch()">重置</button>
								<button id="searchQuery" class="fixed-btn searchQuery fr" onclick="search()">查询</button>
							</div>
						</div>
						<div id="moresees" style="clear:both;display:none;">
							<div class="layui-item query athird">
								<label class="layui-form-label">登录名：</label>
								<div class="layui-input-block">
									<form:input path="loginName" htmlEscape="false" maxlength="50" class=" form-control layui-input"/>
								</div>
							</div>
						</div>
						<div style="    clear:both;"></div>
					</div>
				</form:form>
			</div>
		</div>

		<div class="contentShadow shadowT full-width fl">
			<div class="layui-form contentDetails">
				<div class="nav-btns">
					<shiro:hasPermission name="sys:user:add">
						<table:addRow url="${ctx}/sys/user/form?office.id=${user.office.id}&office.name=${user.office.name}&office.type=${user.office.type}" title="用户" target=""></table:addRow><!-- 增加按钮 -->
					</shiro:hasPermission>
					<%--<shiro:hasPermission name="sys:user:del">
                        <table:delRow url="${ctx}/sys/user/deleteAll" id="contentTable"></table:delRow><!-- 删除按钮 -->
                    </shiro:hasPermission>--%>
					<%--<shiro:hasPermission name="sys:user:import">
						<table:importExcel url="${ctx}/sys/user/import"></table:importExcel><!-- 导入按钮 -->
					</shiro:hasPermission>
					<shiro:hasPermission name="sys:user:export">
						<table:exportExcel url="${ctx}/sys/user/export"></table:exportExcel><!-- 导出按钮 -->
					</shiro:hasPermission>
					&lt;%&ndash;<shiro:hasPermission name="importInfo:importInfo:importInfoErr">
                    </shiro:hasPermission>&ndash;%&gt;
					<table:importInfoErr url="${ctx}/sys/user/importInfoErr" title="导入日志"></table:importInfoErr><!-- 导出按钮 -->--%>
					<c:if test="${manager}">
						<a href="javascript:void(0)" onclick="openDialog('邀请加入企业', '${ctx}/sys/company/addUserInfo','75%','400px;')" class="nav-btn nav-btn-add" ><i class="fa fa-edit"></i> 邀请</a>
					</c:if>
					<button class="nav-btn nav-btn-refresh" data-toggle="tooltip" data-placement="left" onclick="sortOrRefresh()" title="刷新"><i class="glyphicon glyphicon-repeat"></i>&nbsp;刷新</button>
					<div style="clear: both;"></div>
				</div>
				<table class="oa-table layui-table" id="contentTable"></table>

				<!-- 分页代码 -->
				<table:page page="${page}"></table:page>
				<div style="clear: both"></div>
            </div>
		</div>
	</div>
	<div id="changewidth"></div>
</div>
<script src="${ctxStatic}/layer-v2.3/layui/layui.all.js" charset="utf-8"></script>
<script>
    layui.use('table', function(){
        layui.table.render({
            limit:${ page.pageSize }
            ,elem: '#contentTable'
            ,page: false
            ,cols: [[
                // {checkbox: true, fixed: true},
                // {checkbox: true, fixed: true},
                {field:'index',align:'center',  width:40,title: '序号'}
                ,{field:'loginName',align:'center', title: '登录名', minWidth:80,templet:function(d){
                        var xml = "<a class=\"attention-info\" href=\"javascript:void(0)\" onclick=\"openDialogView('查看用户', '${ctx}/sys/user/form?id=" + d.id + "&dialog=view','95%','95%')\">" +
                            "<span title=" + d.loginName + ">" + d.loginName + "</span></a>";
                        return xml;
                    }}
                ,{field:'name',align:'center', title: '姓名', minWidth:120,templet:function(d){
                        return "<span title='"+ d.name +"'>" + d.name + "</span>";
                    }}
                ,{field:'mobile', align:'center',title: '手机', minWidth:120,templet:function(d){
                        return "<span title='"+ d.mobile +"'>" + d.mobile + "</span>";
                    }}
                ,{field:'email', align:'center',title: '邮箱', width:200,templet:function(d){
                        return "<span title='"+ d.email +"'>" + d.email + "</span>";
                    }}
                ,{align:'center', title: '头像', width:80,templet:function(d){
                        var xml="";
                        if(d.photo != undefined)
                            xml = "<img src=\"" + d.photo + "?x-oss-process=image/resize,w_50,limit_0\" onclick=\"openDialogView('预览','${ctx}/sys/picturepreview/picturePreview?url=" + d.photo + "','95%','95%')\"/>";
                        return xml;
                    }}
                ,{field:'op',align:'center',title:"操作",minWidth:160,templet:function(d){
                        ////对操作进行初始化
                        var xml = "";
                        /*if(d.candelete1 != undefined && d.candelete1 == "1")
                            xml +="<a href=\"javascript:void(0)\" onclick=\"openDialog('修改用户', '${ctx}/sys/user/form?id="+ d.id + "','95%','95%')\" class=\"op-btn op-btn-edit\" ><i class=\"fa fa-edit\"></i> 修改</a>";
						*/
						if(d.candelete2 != undefined && d.candelete2 == "1")
                            xml +="<a href=\"${ctx}/sys/user/delete?id=" + d.id + "\" onclick=\"return confirmx('确认要移除该用户吗？', this.href)\"   class=\"op-btn op-btn-delete\"><i class=\"fa fa-trash\"></i> 移除</a>";
						return xml;
                    }}
            ]]
            ,data: [
                <c:if test="${ not empty page.list}">
                <c:forEach items="${page.list}" var="user" varStatus="index">
                <c:if test="${index.index != 0}">,</c:if>
                {
                    "index":"${index.index+1}"
                    ,"id":"${user.id}"
                    ,"loginName":"${user.loginName}"
                    ,"name":"${user.name}"
                    ,"mobile":"${user.mobile}"
                    ,"email":"${user.email}"
                    ,"photo":"${user.photo}"
                    <shiro:hasPermission name="sys:user:edit">
                    ,"candelete1":"1"
                    </shiro:hasPermission>
                    <shiro:hasPermission name="sys:user:del">
					<c:if test="${fns:getUser().comId ne '1'}">
                    ,"candelete2":"1"
                    </c:if>
                    </shiro:hasPermission>
                }
                </c:forEach>
                </c:if>
            ]
            // ,even: true
            // ,height: 315
        });
    })
    resizeListTable();
</script>
<script>
    $("a").on("click",addLinkVisied);

    resizeListWindow1();
    $(window).resize(function(){
        resizeListWindow1();
    });
</script>
</body>
</html>