<html xmlns:th="http://www.thymeleaf.org">
<head>
<title>私塾家</title>
<script th:include="sys/common/metaCSS" th:remove="tag"></script> 
<script th:include="sys/common/metaJS" th:remove="tag"></script> 
</head>
<style>
	.tablelink{margin-right:10px;}
	.stylecss{
	      color: red;
	}
	.stylecss2{
		  color:blue;
	}
	.select_width{
	     width: 80px;
	}
	.date_width{
	     width: 100px;
	}
	.stylecss{
	      color: red;
	}
</style>
<body>
<div class="place">
	<span>位置：</span>
	<ul class="placeul">
		<li><a href="#">图书馆管理</a></li>
		<li><a th:href="@{/sys/lib/libJoinList.html}">图书馆</a></li>
	</ul>
</div>
<div class="rightinfo">
	<form id="seachform" th:action="@{/sys/lib/libManagerList.html}" method="post">
	<input type="hidden" name="libId" th:value="${search.get('libId')}">
	<ul class="seachform">
		<li>
			<label>昵称</label>
			<input name="wx_name" type="text" class="scinput" th:value="${search.get('wx_name')} == null  ? '': ${search.get('wx_name')}"/>
		</li>
		<li>
			<label>&nbsp;</label>
			<input type="button" class="scbtn" value="查询" />
		</li>
		<li th:if="${search.get('libtype') eq '1'}">
				<ul class="toolbar">
					<a href="javascript:;"  th:onclick="'addAdmin(\''+${search.get('libId')}+'\',1)'" >
					<li class="click"><span><img th:src="@{/static/sys/images/t01.png}" /></span>新增图书馆管理员</li></a>
				</ul>
		</li>
		<li th:if="${search.get('libtype') ne '1'}">
				<ul class="toolbar">
					<a href="javascript:;"  th:onclick="'addAdmin(\''+${search.get('libId')}+'\',1)'" >
					<li class="click"><span><img th:src="@{/static/sys/images/t01.png}" /></span>新增馆长助理</li></a>
				</ul>
		</li>
		<li>
				<ul class="toolbar">
					<a href="javascript:;"  th:onclick="'addAdmin(\''+${search.get('libId')}+'\',2)'" >
					<li class="click"><span><img th:src="@{/static/sys/images/t01.png}" /></span>新增学习导师</li></a>
				</ul>
		</li>
		<li th:if="${search.get('libtype') eq '1'}">
				<ul class="toolbar">
					<a href="javascript:;"  th:onclick="'addAdmin(\''+${search.get('libId')}+'\',3)'" >
					<li class="click"><span><img th:src="@{/static/sys/images/t01.png}" /></span>新增阅读顾问</li></a>
				</ul>
		</li>
		<li>
				<ul class="toolbar">
					<a href="javascript:;"  th:onclick="'addAdmin(\''+${search.get('libId')}+'\',0)'" >
					<li class="click"><span><img th:src="@{/static/sys/images/t01.png}" /></span>新增馆长</li></a>
				</ul>
		</li>
		<li th:if="${search.get('libtype') ne '1'}">
				<ul class="toolbar">
					<a href="javascript:;"  th:onclick="'addAdmin(\''+${search.get('libId')}+'\',5)'" >
					<li class="click"><span><img th:src="@{/static/sys/images/t01.png}" /></span>新增管理合伙人</li></a>
				</ul>
		</li>
		<li >
				<ul class="toolbar">
					<a href="javascript:;"  th:onclick="'addAdmin(\''+${search.get('libId')}+'\',4)'" >
					<li class="click"><span><img th:src="@{/static/sys/images/t01.png}" /></span>新增校长</li></a>
				</ul>
		</li>
		<li>
				<ul class="toolbar">
					<a th:href="@{/sys/lib/libJoinList.html}"><li class="click"><span><img style="width: 24px;height: 24px" th:src="@{/static/sys/images/goto.png}" /></span>返回</li></a>
				</ul>
		</li>
	</ul>
	</form>
	<table class="tablelist">
		<thead>
		    <tr>
		        <th style="width: 50px;">序号</th>
		        <th>昵称</th>
		        <th>类型</th>
		        <th>头像</th>
		        <th>添加时间</th>
		        <th>操作</th>
		    </tr>
		</thead>
		<tbody>
			<tr th:each="item:${list}" >
				<td th:text="${itemStat.count}" ></td>
					<td th:title="${item.get('wx_name')}" th:text="${item.get('wx_name')} ? (${#strings.length(item.get('wx_name'))} &gt; 40 ? ${#strings.substring(item.get('wx_name'),0,40)} :${item.get('wx_name')} ) :'' ">
					</td>
					<td th:switch="${item.get('type')}" >
				    <a href="javascript:;" th:case="1" th:if="${item.get('libtype') ne '2'}" class="stylecss" th:text="${item.get('libtype')} eq '2' ?'馆长助理':'图书馆管理员'">图书馆管理员</a>
				    <a href="javascript:;" th:case="2" class="stylecss2">学习导师</a>
				    <a href="javascript:;" th:case="3" >阅读顾问</a>
				    <a href="javascript:;" th:case="4" >校长</a>
				    <a href="javascript:;" th:case="5" >管理合伙人</a>
				    <a href="javascript:;" th:case="0" >馆长</a>
					</td>
					<td  class="imgtd">
							<img  th:if="${item.get('photo')}!=null" th:src="${imgUrl}+''+${item.get('photo')}" style="width: 50px;height: 50px;" />
					</td>
					<td  th:text="${#calendars.format(item.get('create_time'),'yyyy-MM-dd HH:mm:ss')}" ></td>
					<td>
						<a href="javascript:;" th:onclick="'deleteById(\''+${item.id}+'\')'" th:if="${item.get('type') ne '6'}"  class="tablelink" >删除</a>
						<a  href="javascript:;"   th:onclick="'updateById(\''+${item.id}+'\')'"   class="tablelink">修改</a>
				    </td>
				
			</tr>
		</tbody>
	</table>
	<!-- 分页 -->
	<div class="pagin">
    	<div class="message">共<i class="blue">[[${page.rowCnt}]]</i>条记录，当前显示第&nbsp;<i class="blue">[[${page.pageNo }]]&nbsp;</i>页</div>
    	<div th:utext='${listNavigatHtml}' th:remove="tag" ></div>
   	</div>
</div>
</body>
<script type="text/javascript">
function deleteById(id){
	layer.confirm("确定删除该管理员？",
			{icon: 4, btn: ['确定','取消']
	}, function(){
		$.ajax({
			url: '[[${sysUrl}]]/sys/lib/libManagerDelete',
			type: "post",
			data:{
				'id': id
			},
			dataType: "json",
			success:function(data){
					
					if(data.meta.success){
						layer.msg("删除成功",{icon:1});
				    	setTimeout(function(){
				    		location.reload();
						},1000);
					}else{
						layer.msg(data.meta.message,{icon:11});
					}
			}
		});
	});
}

function updateById(id){
	layer.open({
		type: 2,
		title: "修改姓名",
		closeBtn: 1, //不显示关闭按钮
		shift: 0.8,
		//offset: '100px',
		area: ['55%', '55%'],
		content: "[[${sysUrl}]]/sys/lib/libManagerEdit.html?id="+id
	});
}

function addAdmin(id,type){
	var   title ='添加图书馆管理员';
	if(type == 2 ){
		title ='添加作业吧管理员';
	}else if(type == 3){
		title = '添加学霸老师';
	}else if(type==4){
		title="添加校长";
	}else if(type==5){
		title="添加合伙人";
	}else if(type==0){
		title="添加馆长";
	}
	var content;
	if(type==4){
		content = '[[${sysUrl}]]/sys/lib/libManagerAdd4.html?libId='+id;
	}else{
		content= '[[${sysUrl}]]/sys/lib/selectUserList.html?libId='+id+'&type='+type;
	}
	layer.open({
	    type: 2,
	    title: title,
	    closeBtn: 1, //不显示关闭按钮
	    shift: 0.8,
	    //offset: '100px',
	    area: ['80%', '80%'],
	    content:content
	});
}
</script>
</html>