<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<head>
	<title>评卷员管理</title>
	<meta name="decorator" content="default"/>
	<%@include file="/WEB-INF/views/include/head.jsp" %>
	<style type="text/css">.sort{color:#0663A2;cursor:pointer;}</style>
</head>
<body>
	<ul class="nav nav-tabs">
		<li class="active"><a href="${ctx}/admin/exam-param/marker">评卷员列表</a></li>
		<li><a href="${ctx}/admin/exam-param/marker/batch-create">批量创建</a></li>
		<li><a href="${ctx}/admin/exam-param/marker/subjectViewer">科组长列表</a></li>
	</ul>
	<form id="searchForm"  action="${ctx}/admin/exam-param/marker" method="post" class="breadcrumb form-search">
		<input type="hidden" id="pageNumber" name="pageNumber" value="${query.pageNumber}"/>
		<input type="hidden" id="pageSize" name="pageSize" value="${query.pageSize}"/>
		<div>
			<label>科目：</label>
			<select id="subject-select" name="subjectCode">
				<option value="">请选择</option>
				<c:forEach items="${subjectList}" var="subject">
				<option value="${subject.code}" <c:if test="${subject.code==query.subjectCode}">selected</c:if>>${subject.code}-${subject.name}</option>
				</c:forEach>
			</select>
			<label>登录名</label>
			<input type="text" name="loginName" value="${query.loginName }"  maxlength="20" class="input-small"/>
			
			&nbsp;
			<input id="btnSubmit" class="btn btn-primary" type="button" value="查询" onclick="goSearch()"/>
			&nbsp;
			<input id="btnExport" class="btn" type="button" value="导出"/>
			&nbsp;
			<a href="${ctx}/admin/exam-param/marker/progress" class="btn">评卷进度</a>
		</div>
	</form>
	<tags:message content="${message}"/>
	<table id="contentTable" class="table table-striped table-bordered table-condensed">
		<thead>
			<tr>
				<th>科目</th>
				<th>登录名</th>
				<th>姓名</th>
				<th>密码</th>
				<th>状态</th>
				<th>操作</th>
			</tr>
		</thead>
		<tbody>
		<c:forEach items="${query.result}" var="marker">
			<tr>
				<td>
				<c:if test="${marker.subject!=null}">
				${marker.subject.code}-${marker.subject.name}
				</c:if>
				<c:if test="${marker.subject==null}">
				不限
				</c:if>
				</td>
				<td>${marker.loginName}</td>
				<td>${marker.name}</td>
				<td>${marker.password}</td>
				<td>${marker.enable eq true ? "启用" : "禁用"}</td>
				<td>
					<a href="javascript:void(0)" class="delete-button" data-id="${marker.id}">删除</a>
					<c:if test="${marker.enable==true}">
					<a href="javascript:void(0)" class="toggle-button" data-id="${marker.id}" data-value="false">禁用</a>
					</c:if>
					<c:if test="${marker.enable==false}">
					<a href="javascript:void(0)" class="toggle-button" data-id="${marker.id}" data-value="true">启用</a>
					</c:if>
				</td>
			</tr>
		</c:forEach>
		</tbody>
	</table>
	<div class="pagination">${query}</div>
<script type="text/javascript">
$("#btnExport").click(function(){
	top.$.jBox.confirm("确认要导出评卷员数据吗？","系统提示",function(v,h,f){
		if(v=="ok"){
			$("#searchForm").attr("action","/admin/exam-param/marker/export");
			$("#searchForm").submit();
		}
	},{buttonsFocus:1});
	top.$('.jbox-body .jbox-icon').css('top','55px');
});
$("#clear-button").click(function(){
	if(confirm('确定要删除当前的所有评卷员?')){
		$("#searchForm").attr("action","${ctx}/admin/exam-param/marker/clear");
		$("#searchForm").submit();
	}
});
$('.delete-button').click(function(){
	var id = $(this).attr('data-id');
	$.post('${ctx}/admin/exam-param/marker/delete', {id: id}, function(result){
		if(result.success==true){
			alert('删除成功');
			$("#searchForm").submit();
		}else{
			alert(result.message);
		}
	});
});
$('.toggle-button').click(function(){
	var id = $(this).attr('data-id');
	var enable = $(this).attr('data-value');
	$.post('${ctx}/admin/exam-param/marker/toggle', {id: id, enable: enable}, function(result){
		if(result.success==true){
			alert('修改成功');
			$("#searchForm").submit();
		}else{
			alert(result.message);
		}
	});
});
function page(n,s){
	$("#pageNumber").val(n);
	$("#pageSize").val(s);
	$("#searchForm").attr("action","${ctx}/admin/exam-param/marker");
	$("#searchForm").submit();
	return false;
}
function goSearch(){
	$("#pageNumber").val(1);
	$("#pageSize").val('${query.pageSize}');
	$("#searchForm").attr("action","${ctx}/admin/exam-param/marker");
	$("#searchForm").submit();
	return false;
}
</script>	
</body>
</html>