<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;
	}
	.select_width{
	     width: 80px;
	}
	.date_width{
	     width: 100px;
	}
</style>
<body>
<div class="place">
	<span>位置：</span>
	<ul class="placeul">
		<li><a href="#">图书馆管理</a></li>
		<li><a th:href="@{/sys/lib/libBookInfoList.html}">图书列表</a></li>
	</ul>
</div>
<div class="rightinfo">
	<form id="seachform" th:action="@{/sys/lib/bookDetailList.html}" method="post">
	<input type="hidden" name="libId" th:value="${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>
				<ul class="toolbar">
					<a href="javascript:;"  th:onclick="'addAdmin(\''+${libId}+'\')'" >
					<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/libBookInfoList.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>
		        <th>借书人</th>
		        <th>借书人头像</th>
		        <th>借书时间</th>
		        <th>操作</th>
		    </tr>
		</thead>
		<tbody>
			<tr th:each="item:${list}" >
				<td th:text="${itemStat.count}" ></td>
					
					<td th:switch="${item.get('type')}" >
					    <span th:case="1" >未借出</span>
					    <span th:case="2" >借出中</span>
				   </td>
					<td th:switch="${item.get('stat')}" >
					    <span th:case="1" >未下载二维码</span>
					    <span th:case="2" >已下载二维码</span>
				   </td>
				   <td style="width: 141px;" th:text="${#calendars.format(item.get('create_time'),'yyyy-MM-dd HH:mm:ss')}" ></td>
				   <td>
						<img  th:if="${item.get('qr_url')}!=null" th:src="${imgUrl}+''+${item.get('qr_url')}" style="width: 50px;height: 50px;" />
					</td>
					<td style="width: 141px;" th:text="${item.get('bookcase')}" ></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  class="imgtd">
							<img  th:if="${item.get('photo')}!=null" th:src="${imgUrl}+''+${item.get('photo')}" style="width: 50px;height: 50px;" />
					</td>
					 <td style="width: 141px;" th:text="${#calendars.format(item.get('borrowed_time'),'yyyy-MM-dd HH:mm:ss')}" ></td>
					<td th:switch="${item.get('stat')}">
						<a href="javascript:;" th:case="1" th:onclick="'deleteById(\''+${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 print(id){
	var desc="确定打印吗？";
	layer.confirm(desc,
			{icon: 4, btn: ['确定','取消']
	}, function(){
		$.ajax({
			url: '[[${sysUrl}]]/sys/lib/printBookImg',
			type: "post",
			data:{
				'id': id
			},
			dataType: "json",
			success:function(data){
					
					if(data.meta.success){
						parent.layer.msg("操作成功",{icon:1});
				    	setTimeout(function(){
				    		location.reload();
						},1000);
					}else{
						parent.layer.msg(data.meta.message,{icon:11});
					}
			}
		});
	});
}
function deleteById(id){
	layer.confirm("确定删除该图书吗？",
			{icon: 4, btn: ['确定','取消']
	}, function(){
		$.ajax({
			url: '[[${sysUrl}]]/sys/lib/bookDetailDelete',
			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 addAdmin(id){
	layer.open({
	    type: 2,
	    title: "新增书本数量",
	    closeBtn: 1, //不显示关闭按钮
	    shift: 0.8,
	    //offset: '100px',
	    area: ['40%', '50%'],
	    content: '[[${sysUrl}]]/sys/lib/bookDetailAdd.html?infoId='+id
	});
}
</script>
</html>