<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: 70px;
	}
	.date_width{
	     width: 100px;
	}
</style>
<body>
<div class="place">
	<span>位置：</span>
	<ul class="placeul">
		<li><a href="#">运营管理</a></li>
		<li><a th:href="@{/sys/story/storyList.html}">故事列表</a></li>
	</ul>
</div>
<div class="rightinfo">
	<form id="seachform" th:action="@{/sys/story/storyList.html}" method="post">
	<ul class="seachform">
		<li>
			<label>标题</label>
			<input name="LIKE_title" type="text" class="scinput" th:value="${search.get('LIKE_title')}"/>
		</li>
		<li>
			<label>&nbsp;</label>
			<input type="button" class="scbtn" value="查询" />
		</li>
		<li>
				<ul class="toolbar">
					<a th:href="@{/sys/story/storyAdd.html}"><li class="click"><span><img th:src="@{/static/sys/images/t01.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>
		    </tr>
		</thead>
		<tbody>
			<tr th:each="item:${list}" >
				<td th:text="${itemStat.count}" ></td>
					<td th:title="${item.title}" th:text="${item.title} ? (${#strings.length(item.title)} &gt; 30 ? ${#strings.substring(item.title,0,30)} :${item.title} ) :'' ">
					</td>
					<td  class="imgtd">
							<img  th:if="${item.titleImg}!=null" th:src="${imgUrl}+''+${item.titleImg}" style="width: 50px;height: 50px;" />
					</td>
					<td th:text="${#calendars.format(item.startTime,'yyyy-MM-dd')}" ></td>
					<td th:text="${item.daysNum}" ></td>
					<td th:switch="${item.type}" >
					    <span th:case="1"  th:onclick="'showIndex(\''+${item.id}+'\',\''+2+'\');'" >不置顶</span>
					    <span th:case="2" style="color: red;" th:onclick="'showIndex(\''+${item.id}+'\',\''+1+'\');'" >置顶</span>
				   </td>
					<td th:text="${#calendars.format(item.createTime,'yyyy-MM-dd HH:mm:ss')}" ></td>
					<td>
						<a th:href="@{/sys/story/storyTaskList.html(EQ_storyId=${item.id})}" class="tablelink" >每天故事列表</a>
						<a th:href="@{/sys/story/storyAdd.html(id=${item.id})}" class="tablelink" >修改</a>
						<a th:href="@{/sys/story/cardJS_{id}.html(id=${item.id})}" target="_blank" class="tablelink" >预览</a>
						<a href="javascript:;" 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 showIndex(id,  isShow){
		var content;
			if(isShow == 2){
				content = "您确定要置顶该打卡吗？"
			}else {
				content = "您确定要取消置顶该打卡吗？"
			}
		
		parent.layer.confirm(content, {
			icon: 4, btn: ['确定','关闭'] //按钮
		}, function(){
			$.ajax({
				url: '[[${sysUrl}]]/sys/story/showIndex',
				type : "post",
				data : {
					'id' : id,
					'type' : isShow
				},
				dataType : "json",
				success : function(data) {
					
					if(data.meta.success){
						parent.layer.alert('操作成功',{icon: 1});
						location.reload();
					}else{
						parent.layer.alert(data.msg,{icon: 9})
					}
					
				}
			});
		});
	}
 
 function deleteById(id){
		parent.layer.confirm("确定删除吗？",
				{icon: 4, btn: ['确定','取消']
		}, function(){
			$.ajax({
				url: '[[${sysUrl}]]/sys/story/storyDelete',
				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});
						}
				}
			});
		});
	} 
</script> 
</html>