<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%>
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<meta name="renderer" content="webkit|ie-comp|ie-stand">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,member-scalable=no" />
<meta http-equiv="Cache-Control" content="no-siteapp" />
<!--[if lt IE 9]>
<script type="text/javascript" src="${pageContext.request.contextPath }/common/admin/lib/html5.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath }/common/admin/lib/respond.min.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath }/common/admin/lib/PIE_IE678.js"></script>
<![endif]-->
<link href="${pageContext.request.contextPath }/common/admin/css/H-ui.min.css" rel="stylesheet" type="text/css" />
<link href="${pageContext.request.contextPath }/common/admin/css/H-ui.admin.css" rel="stylesheet" type="text/css" />
<link href="${pageContext.request.contextPath }/common/admin/lib/Hui-iconfont/1.0.1/iconfont.css" rel="stylesheet" type="text/css" />
<!--[if IE 6]>
<script type="text/javascript" src="http://lib.h-ui.net/DD_belatedPNG_0.0.8a-min.js" ></script>
<script>DD_belatedPNG.fix('*');</script>
<![endif]-->
<title>题目管理</title>
</head>
<body>
<nav class="breadcrumb"><i class="Hui-iconfont">&#xe67f;</i> 首页 <span class="c-gray en">&gt;</span> 题目管理 <span class="c-gray en">&gt;</span> 题目列表 <a class="btn btn-success radius r mr-20" style="line-height:1.6em;margin-top:3px" href="javascript:location.replace(location.href);" title="刷新" ><i class="Hui-iconfont">&#xe68f;</i></a></nav>
<div class="pd-20">
	<div class="text-c">
	<form action="${pageContext.request.contextPath }/admin/answer/getAllProblem" method="post" id="searchForm">
		<input type="hidden" name="orderStatus" value="${orderStatusStr }" />
			<input type="text" name="text" id="text" value="${text }" placeholder="题目名称" style="width: 300px" class="input-text">
			
			<select id="IsAllocated" name="IsAllocated" style="width:100px" size="1" class="select">
					<option value="" >是否分配</option>
					<option value="1" <c:if test="${IsAllocated == 1}">selected</c:if>>已分配</option>
					<option value="2" <c:if test="${IsAllocated == 2}">selected</c:if>>未分配</option>
			</select>
			<%-- 截止日期： 
			<input type="text" readonly="readonly" onfocus="WdatePicker({maxDate:'2050-10-01', dateFmt:'yyyy-MM-dd HH:mm:ss'})" id="beginDate" value="${beginDate }" name="beginDate" class="input-text Wdate" style="width: 120px;"> --%>
			<button name="" id="submitBtn" class="btn btn-success" type="submit">
				<i class="Hui-iconfont">&#xe665;</i> 搜索
			</button>
				&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
				<button name="" id="addQuestion" onclick="toaddQuestion('新增题目','${pageContext.request.contextPath }/admin/answer/toAddInsertQuestion','','700');" class="btn btn-success" type="button">
				<i class="Hui-iconfont">&#xe665;</i> 添加题目
			</button>
		<div class="mt-20">
			<table class="table table-border table-bordered table-hover table-bg">
				<thead>
					<tr class="text-c">
						<th width="50">题目id</th>
						<th width="120">题目名称</th>
						<th width="100">题目状态</th>
						<th width="50">分数计算方式</th>
						<th width="40">题目图标</th>
						<th width="40">题目类型</th>
						<th width="140">操作</th>
					</tr>
				</thead>
				
				<tbody>
					<c:if test="${!empty questionList }">
						<c:forEach items="${questionList }" var="question">
						<tr class="text-c">
							<td>${question.questionId }</td>
							<td>${question.questionName }</td>
							<td>
								<c:if test="${question.questionStatu == 1}">正常使用</c:if>
								<c:if test="${question.questionStatu == 2}">停止使用</c:if>
							</td>
							<td>
								<c:if test="${question.questionCalculation == 1}">累积</c:if>
								<c:if test="${question.questionCalculation == 2}">最高分</c:if>
							</td>
							<td>
								<c:if test="${question.questionType == 1}">营养</c:if>
								<c:if test="${question.questionType == 2}">发育</c:if>
								<c:if test="${question.questionType == 3}">健康</c:if>
							</td>
							<td><img src="${question.questionPic }" width="50" height="50"></img></td>
							<td class="td-manage">
							<input id="selectOption" class="btn btn-primary radius upload-btn" onclick="selectoption('查看题目选项','${pageContext.request.contextPath }/option/selectOptionById?questionId=${question.questionId }','','700');" type="button" value="选项" />&nbsp;
									<input id="through" class="btn btn-primary radius upload-btn" onclick="updateQuestion('修改题目状态','${pageContext.request.contextPath }/admin/answer/toAddUpdateQuestion?questionId=${question.questionId }','','700');" type="button" value="修改" />&nbsp;
									<input id="deleteQuestion" class="btn btn-primary radius upload-btn" onclick="deleteProblem(this,${question.questionId });" type="button" value="删除" />&nbsp;
							</td>
						</tr>
						</c:forEach>
					</c:if>
					<c:if test="${empty questionList }">
						<tr class="text-c">
							<td colspan="9">没有查询到数据</td>
						</tr>
					</c:if>
				</tbody>
			</table>
		</div>
	</form>
	</div>
</div>
<div align="right">
	<%@include file="/common/other/paper/pager.jsp"%>
</div>
<script type="text/javascript" src="${pageContext.request.contextPath }/common/admin/lib/jquery/1.9.1/jquery.min.js"></script> 
<script type="text/javascript" src="${pageContext.request.contextPath }/common/admin/lib/layer/1.9.3/layer.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath }/common/admin/lib/laypage/1.2/laypage.js"></script> 
<script type="text/javascript" src="${pageContext.request.contextPath }/common/admin/lib/My97DatePicker/WdatePicker.js"></script> 
<script type="text/javascript" src="${pageContext.request.contextPath }/common/admin/lib/datatables/1.10.0/jquery.dataTables.min.js"></script> 
<script type="text/javascript" src="${pageContext.request.contextPath }/common/admin/js/H-ui.js"></script> 
<script type="text/javascript" src="${pageContext.request.contextPath }/common/admin/js/H-ui.admin.js"></script> 
<script type="text/javascript">
$(function() {
	$("#searchButton").click(function() {
		var action = $("#searchForm").attr("action");
		$("#searchForm").attr("action", action).submit();
	});
})
/*题目-编辑*/
function updateQuestion(title,url,id,w,h){
	layer_show(title,url,w,h);
}
/*题目选项查看*/
function selectoption(title,url,id,w,h){
	layer_show(title,url,w,h);
}


/*题目-删除*/
function deleteProblem(obj,id){
	layer.confirm('确认要删除吗？',function(){
		$.ajax({
			url: '${pageContext.request.contextPath }/admin/answer/deleteQuestion',
			data:{ "questionId":id },
			dataType:'json',//服务器返回json格式数据
			type:'post',	//HTTP请求类型
			error:function(data){
				//alert("-----error:function----->>" + data);
	      	  	layer.msg("删除失败!",{icon: 5,time:2000});  
	        },
	        success:  function(data){
	        	//alert("----success------>>" + data);
	      	  	//layer.msg(data.status,{icon: 1,time:2000});
	      	  	if(data.status){
					$(obj).parents("tr").remove();
					layer.msg('已删除!',{icon:1,time:3000});
	      	  	}else{
	      	  		layer.msg(data.message,{icon:1,time:3000});
	      	  	}
	        }
		});
	});
}
/*题目-添加*/
function toaddQuestion(title,url,id,w,h){
	layer_show(title,url,w,h);
}
</script> 
</body>
</html>