<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> 
<script src="sys/js/My97DatePicker/WdatePicker.js" th:src="@{/static/sys/js/My97DatePicker/WdatePicker.js}"></script>
</head>
<style>
	.tablelink{margin-right:10px;}
	.stylecss{
	      color: red;
	}
	.select_width{
	     width: 220px;
	}
	.date_width{
	     width: 83px;
	}
</style>
<body>
<div class="place">
	<span>位置：</span>
	<ul class="placeul">
		<li><a href="#">首页</a></li>
		<li><a href="#">答案列表</a></li>
	</ul>
</div>
<div class="rightinfo">
	<form id="seachform" th:action="@{/sys/ydz/articeMatterSolutionlist.html}" method="post">
	<input name="matter_id" type="hidden"  th:value="${search.get('matter_id')} == null  ? '': ${search.get('matter_id')}"/>
	<input name="artice_id" type="hidden"  th:value="${search.get('artice_id')} == null  ? '': ${search.get('artice_id')}"/>
	<ul class="seachform">
	<li>
			<label>答案</label>
			<input name="solution" type="text" class="scinput" th:value="${search.get('solution')}"/>
		</li>
		<li>
			<input type="button" class="scbtn" value="查询" />
		</li>
	<li>
				<ul class="toolbar">
		<a th:href="@{/sys/ydz/addarticeMatterSolution.html(matter_id=${search.get('matter_id')},artice_id=${search.get('artice_id')})}"><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/ydz/articeMatterlist.html(artice_id=${search.get('artice_id')})}"><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="tablelist">
		<thead>
		    <tr>
		        <th style="width: 50px;">序号</th>
		        <th>答案</th>
		        <th>GR值</th>
		        <th>是否正确答案</th>
		        <th style="color: red;text-align: center;">排序</th>
		        <th>创建时间
		        </th>
		        <th>操作</th>
		    </tr>
		</thead>
		<tbody>
			<tr th:each="itemlist:${list}" >
				<td th:text="${itemlistStat.count}" ></td>
				<td th:title="${itemlist.get('solution')}" th:text="${itemlist.get('solution')} ? (${#strings.length(itemlist.get('solution'))} &gt; 35 ? ${#strings.substring(itemlist.get('solution'),0,35)} :${itemlist.get('solution')} ) :'' ">
				</td>
				<td th:text="${itemlist.get('gr_worth')}"></td>
				<td th:switch="${itemlist.get('type')}" >
				    <span th:case="1">是</span>
				    <span th:case="2">否</span>
				</td>
				<td style="text-align: center;" >
				<input type="number" th:value="${itemlist.sequence}" th:onBlur="'updatenum(\''+${itemlist.id}+'\',\''+${itemlist.sequence}+'\',this)'"  class="dfinput" style="width: 60px; height: 30px;color: red;"  >
				</td>
				<td th:text="${#calendars.format(itemlist.get('create_time'),'yyyy-MM-dd HH:mm:ss')}" ></td>
				<td>
					<a th:href="@{/sys/ydz/addarticeMatterSolution.html(id=${itemlist.get('id')},artice_id=${search.get('artice_id')})}" class="tablelink" >修改</a>
				    <a href="javascript:;" th:onclick="'deleteById(\''+${itemlist.get('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>
<script type="text/javascript">
function updatenum(id,oldPrice,_this){
	var price = $(_this).val();
	if(price == oldPrice){
		return false;
	}
	if(price ==''|| price ==null){
		return false;
	}
	$(_this).removeAttr("onBlur");
	$.ajax({
		url : "[[${sysUrl}]]/sys/ydz/upprice",
		type : "post",
		data : {
			id : id,
			price : price
		},
		dataType : "json",
		success : function(data) {
			if(data.meta.success){
				 parent.layer.msg('操作成功',{icon:1});
				 $(_this).attr("onBlur","updatePrice("+id+","+price+",this)");
			}else{
				parent.layer.msg('操作失败',{icon: 9})
				$(_this).attr("onBlur","updatePrice("+id+","+oldPrice+",this)");
			}
		}
	});
}
function deleteById(id){
	parent.layer.confirm("确定删除该问题？",
			{icon: 4, btn: ['确定','取消']
	}, function(){
		$.ajax({
			url: '[[${sysUrl}]]/sys/ydz/articeMatterSolutionDelete',
			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>