<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/jquery.validate.min.js" th:src="@{/static/sys/js/jquery.validate.min.js}"></script>
<script src="sys/js/jquery-validation/messages_zh.js" th:src="@{/static/sys/js/jquery-validation/messages_zh.js}"></script>
<script src="sys/js/My97DatePicker/WdatePicker.js" th:src="@{/static/sys/js/My97DatePicker/WdatePicker.js}"></script>


 <style>
    	.clearfix:after {
			visibility: hidden;
			display: block;
			font-size: 0;
			content: " ";
			clear: both;
			height: 0;
		}
		.clearfix { display: inline-table; }
		* html .clearfix { height: 1%; }
		.clearfix { display: block; }
		.fl{display:inline;float:left}
		clearfix >control-label-error{display:inline;float:left;marign-left:10px}
		 label.control-label-error {
  				color: Red;
             }
          .lispan {line-height: 34px;}   
          
          .select1{
   		    width:100%;
		    height: 32px;
		    line-height: 32px;
		    border-top: solid 1px #a7b5bc;
		    border-left: solid 1px #a7b5bc;
		    border-right: solid 1px #ced9df;
		    border-bottom: solid 1px #ced9df;
		    opacity:1;
	        margin-bottom: 10px;
    	}
    	
    	textarea{
    	width: 382px;
    	}
    </style>
</head>

<body>
<div class="place">
    <span>位置：</span>
    <ul class="placeul">
		<li><a href="#">运营管理</a></li>
		<li><a th:href="@{/sys/story/storyList.html}">打卡列表</a></li>
	</ul>
</div>
<div class="formbody">
	<div class="formtitle"><span th:text="${ws.id} ? '修改题目' :'新增题目'">新增故事</span></div>
	<form id="submitFrom"   method="post" class="form-horizontal form-validate">
		     <input type="hidden" name="id" th:if="${ws.id}" th:value="${ws.id}"/>
		       <input type="hidden" name="storyId" id="storyId" th:value="${ws.storyId}"/>
		     <input type="hidden" name="storyTaskId" th:if="${ws.storyTaskId}" th:value="${ws.storyTaskId}"/>
		<ul class="forminfo">
			<li class="clearfix">
				<label>题目内容:</label>
				<textarea rows="10" id="name" name="name"    class="textinput" cols="10">[[${ws.name}]]</textarea>
			</li>
			<li class="clearfix">
				<label>选项:</label>
				<textarea rows="10" id="opt" name="opt"  class="textinput" cols="10">[[${ws.opt}]]</textarea>
			</li>
			<li class="clearfix">
				<label>答案:</label>
				<textarea rows="10" id="answer" name="answer" class="textinput" cols="10">[[${ws.answer}]]</textarea>
			</li>
			<li class="clearfix">
				<label>解析:</label>
				<textarea rows="10" id="resolve" name="resolve" class="textinput" cols="10">[[${ws.resolve}]]</textarea>
			</li>
			  <li class="clearfix" id="clearfix">
				    <label>题目标签：<b>*</b></label>
					<div class="vocation" style="margin-right: 5px; width: 300px">
						<select class="select1" name="type">
						   		 <option   value="1" th:selected="${ ws.type eq 1 }" >记忆</option>
						   		 <option   value="2" th:selected="${ ws.type eq 2 }" >文字</option>
						   		 <option   value="3" th:selected="${ ws.type eq 3 }" >鉴赏</option>
						   		 <option   value="4" th:selected="${ ws.type eq 4 }" >运用</option>
						</select>
					</div>
			   </li>
			<li>
				<label>&nbsp;</label>
				<button type="submit" class="btn">保存</button>
				<button type="button" class="btn" onclick="window.history.go(-1);">取消</button>
			</li>
		</ul>
	</form>
</div>
</body>
<script type="text/javascript">

$(function(){
	$("#submitFrom").validate({
		ignore:"",
		rules : {
			
			name : {
				required : true
			}
		},
		messages: {
			name : {
				required : "不能为空"
			}
			
		},
		errorPlacement : function(error, element) {
				error.appendTo(element.parent()); 
		},
		submitHandler : function(form) {
			roleFrom();
		}
	});
	
});
function roleFrom(){
	var url="[[${sysUrl}]]/sys/story/storyTaskTopicSave";
	var params = $("#submitFrom").serialize();
	$.post(url,params,function(data){
		if(data != null){
				if(data.meta.success){
					parent.layer.msg("操作成功!",{icon:1});
			    	setTimeout(function(){
			    		window.location.href ='[[${sysUrl}]]/sys/story/storyTaskList.html?EQ_storyId=[[${ws.storyId}]]';
					},1000);
				}else{
					parent.layer.msg(data.meta.message,{icon:11});
				}
		}
		
	});
}


</script>
</html>