<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>
<body>
	<div class="rightinfo">
		<form id="seachform" th:action="@{/sys/kmtExampaper/list.html}" method="post">
		       <input type="hidden" name="EQ_pId" th:value="${search.get('EQ_pId')}" />
		       <input type="hidden" name="areaId" th:value="${search.get('areaId')}" />
				<ul class="seachform">
					<li>
						<label>名称</label>
						<input name="LIKE_name" type="text" class="scinput" th:value="${search.get('LIKE_name')}"/>
					</li>
					<li>
						<label>&nbsp;</label>
						<input type="button" class="scbtn" value="查询" />
					</li>
					<li>
							<ul class="toolbar">
							<a href="javascript:void(0);"  th:onclick="'openEdit(-2,\''+${search.get('EQ_pId')}+'\',1,\''+${search.get('areaId')}+'\')'"  ><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/kmtExampaper/exampaperList.html}" target="mainFrame"><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="imgtable">
	        <thead>
	            <tr>
	                <th style="width: 50px;">序号</th>
	                <th>名称</th>
	                <th>分值</th>
	                <th style="text-align: center;">排序</th>
	                <th>操作</th>
	            </tr>
	        </thead>
            <tbody>
				
				<tr th:each="item:${list}" >
					<td th:text="${itemStat.count}" ></td>
					<td>[[${item.name}]]<p th:text="'创建时间：'+${#calendars.format(item.createTime,'yyyy-MM-dd HH:mm:ss')}"></p></td>
				    <td th:text="${item.code}" ></td>
					<td style="text-align: center;" >
					 <input type="number" th:value="${item.sortNo}" th:onBlur="'updateSort(\''+${item.id}+'\',\''+${item.sortNo}+'\',this)'"  class="dfinput" style="width: 60px; height: 30px;"  >
					</td>
					<td>
						<a href="javascript:;" th:onclick="'deleteById(\''+${item.id}+'\' ,\''+${item.pId}+'\',\''+${item.name}+'\')'"  class="tablelink" >删除</a>
						<a href="javascript:void(0);"  th:onclick="'openEdit(\''+${item.id}+'\',\''+${search.get('EQ_pId')}+'\',2,\''+${search.get('areaId')}+'\')'" 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>
	
<script type="text/javascript">

function openEdit(id,pId,title,areaId){
	parent.layer.open({
		type: 2,
		title: title ==1 ? '新增' :'修改',
		shadeClose: false,
		shade: 0.8,
		offset: '60px',
		area: ['670px', '520px'],
		content: '[[${sysUrl}]]/sys/kmtExampaper/edit.html?id='+id+'&pId='+pId+'&areaId='+areaId
	});
}


//修改排序号
function updateSort(id,oldSortNo,_this){
	var sortNo = $(_this).val();
	if(sortNo == oldSortNo){
		return false;
	}
	if(sortNo ==''|| sortNo ==null){
		return false;
	}
	$(_this).removeAttr("onBlur");
	$.ajax({
		url : "[[${sysUrl}]]/sys/kmtExampaper/updateSortNo",
		type : "post",
		data : {
			id : id,
			sortNo : sortNo
		},
		dataType : "json",
		success : function(data) {
			if(data.meta.success){
				 parent.layer.msg('操作成功',{icon:1});
				 $(_this).attr("onBlur","updateSort(\""+id+"\",\""+sortNo+"\",this)");
			}else{
				parent.layer.msg('操作失败',{icon: 9})
				
			}
		}
	});
}
//删除
function deleteById(id, pid, name){
	parent.layer.confirm("您确定要删除"+name+"吗？", {
		icon: 4, btn: ['确定','取消'] //按钮
	}, function(){
		$.ajax({
			url: '[[${sysUrl}]]/sys/kmtExampaper/delete',
			type : "post",
			data:{
				'id': id,
				'pId':pid
			},
			dataType : "json",
			success : function(data) {
				if(data.meta.success){
					parent.layer.msg("删除成功",{icon:1});
					parent.refreshNode(id, pid , name, "delete");
					setTimeout(function() {
						location.reload()
					}, 1000);
				}else{
					parent.layer.msg(data.meta.message,{icon:11});
				}
			}
		});
	});
}

</script>
</body>
</html>