<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;
	}
</style>
<body>
<div class="rightinfo">
	<form id="seachform" th:action="@{/sys/zuoyb/selectContentList.html}" method="post">
	<input type="hidden" id="EQ_libId" name="EQ_libId" th:value="${search.get('EQ_libId')}">
	<input type="hidden" id="zybCourseId" name="zybCourseId" th:value="${search.get('zybCourseId')}">
	<ul class="seachform">
		<li>
			<label>标签内容</label>
			<input name="LIKE_content" type="text" class="scinput" th:value="${search.get('LIKE_content')}"/>
		</li>
		<li>
			<label>&nbsp;</label>
			<input type="button" class="scbtn" value="查询" />
		</li>
		<li>
				<ul class="toolbar">
					<li class="click"><span><img style="width: 24px;height: 24px" th:src="@{/static/sys/images/select.png}" /></span>选择</li>
				</ul>
		</li>
		
	</ul>
	</form>
	<table class="tablelist">
		<thead>
		    <tr>
		        <th><input type="checkbox" onchange="selectAll()"></th>
		        <th style="width: 50px;">序号</th>
		        <th>内容</th>
		        <th>排序</th>
		        <th>数据类型</th>
		        <th>添加时间</th>
		    </tr>
		</thead>
		<tbody>
			<tr th:each="item:${list}" >
				    <td><input name="selectlist" type="checkbox" th:data-id="${item.id}" /></td>
				    <td th:text="${itemStat.count}" ></td>
				    <td th:text="${item.content}" ></td>
					<td th:text="${item.num}" ></td>
					<td  th:switch="${item.type}">
					   <span th:case="1" style="color: red">原始数据</span>
					   <span th:case="*">自有数据</span>
					</td>
					<td  th:text="${#calendars.format(item.createTime,'yyyy-MM-dd HH:mm:ss')}" ></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(){
	$('ul.toolbar li.click').click(function () {
	    var selectIds=[];
		 $('[name=selectlist]:checkbox:checked').each(function() {
				 var id = $(this).attr('data-id');
				 selectIds.push(id);
		 });
		 if(selectIds.length>0){
			 showIndex(selectIds);
	   	 }else{
	   		closeWin();
	   	 }
		 
	 });
	$('[name=selectlist]:checkbox').change(function () {
		$(this).checked = !$(this).checked;
	 });
	
})
function selectAll() {
	$('[name=selectlist]:checkbox').each(function() {
		this.checked = !this.checked;
    });
}
function showIndex(selectIds){
	var content ="您确定要添加数据吗?";
	parent.layer.confirm(content, {
		icon: 4, btn: ['确定','关闭'] //按钮
	}, function(){
		var url="[[${sysUrl}]]/sys/zuoyb/selectContentSave";
		var libId= $("#EQ_libId").val();
		var zybCourseId= $("#zybCourseId").val();
		 var params ={
		            'libId' : libId,
		            'ids' : selectIds,
		            'zybCourseId' : zybCourseId
		        };
		$.post(url,params,function(data){
			if(data.meta.success){
				parent.layer.msg("添加成功",{icon:1});
				setTimeout(function(){
				   closeWin();
				},1000);
			}else{
				parent.layer.msg(data.meta.message,{icon:11});
				setTimeout(function(){
					   closeWin();
					},1000);
			}
		});
	});
}
function closeWin(){
	parent.location.reload();
	parent.layer.close(parent.layer.getFrameIndex(window.name));
}
</script>
</html>