<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/articeMatterlist.html}" method="post">
	<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="matter" type="text" class="scinput" th:value="${search.get('matter')}"/>
		</li>
		<li>
			<input type="button" class="scbtn" value="查询" />
		</li>
	<li>
				<ul class="toolbar">
		<a th:href="@{/sys/ydz/addarticeMatter.html(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/articelist.html}"><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>问题类型</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('matter')}" th:text="${itemlist.get('matter')} ? (${#strings.length(itemlist.get('matter'))} &gt; 35 ? ${#strings.substring(itemlist.get('matter'),0,35)} :${itemlist.get('matter')} ) :'' ">
				</td>
				<td th:switch="${itemlist.get('stat')}" >
				    <span th:case="1">信息提取能力</span>
				    <span th:case="2">推断理解能力</span>
				    <span th:case="3">整体感知能力</span>
				    <span th:case="4">评价鉴赏能力</span>
				    <span th:case="5">联结运用能力</span>
				    <span th:case="0">阅读积累测试</span>
				</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.count}" th:onBlur="'updatenum(\''+${itemlist.id}+'\',\''+${itemlist.count}+'\',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/addarticeMatter.html(id=${itemlist.get('id')})}" class="tablelink" >修改</a>
				    <a href="javascript:;" th:onclick="'deleteById(\''+${itemlist.get('id')}+'\')'"  class="tablelink" >删除</a>
				    <a th:href="@{/sys/ydz/articeMatterSolutionlist.html(matter_id=${itemlist.get('id')},artice_id=${search.get('artice_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/upnum",
		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/articeMatterDelete',
			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>