<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 type="text/javascript" src="https://t.sharingschool.com/dcui/tools/ueditor/ueditor.config.js?version=1811271348"></script>
<script type="text/javascript" src="https://t.sharingschool.com/dcui/tools/ueditor/ueditor.all.min.js?version=1812061808"></script>
<script type="text/javascript" src="https://t.sharingschool.com/dcui/tools/ueditor/lang/zh-cn/zh-cn.js?version=1811271348"></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;
    	}
    </style>
</head>

<body>
<div class="place">
    <span>位置：</span>
    <ul class="placeul">
    	<li><a href="#">热门问题管理</a></li>
    	<li><a href="#">热门问题设置</a></li>
    </ul>
</div>
<div class="formbody">
	<div class="formtitle"><span>热门问题信息</span></div>
	<form id="roleFrom"   method="post" class="form-horizontal form-validate">
		<input  type="hidden" id="id" th:if="${problem.id}" th:value="${problem.id}" name="id">
		<ul class="forminfo">
			<li class="clearfix">
				<label class="fl">标题<b>*</b></label>
				  <input  type="text" id="title"  th:value="${problem.title}" class="dfinput fl"  name="title">
			</li>
			<li class="clearfix" >
				<label class="fl">链接<b>*</b></label>
				  <input  type="url" id="link"  th:value="${problem.link}" class="dfinput fl"  name="link">
			</li>
			<li>
			    <label>问题类型：<b>*</b></label>
				<div class="vocation" style="margin-right: 5px; width: 179px">
					<select class="select1" name="type">
					   		 <option  value="1"  th:selected="${problem.type==1}" >外借书及阅读指导</option>
					   		 <option  value="2" th:selected="${problem.type==2}" >同伴作业督导</option>
					   		 <option  value="3" th:selected="${problem.type==3}" >阅读评测</option>
					   		 <option  value="4" th:selected="${problem.type==4}" >关于私塾家</option>
					</select>
				</div>
		   </li>
		   <li>
			    <label>端别：<b>*</b></label>
				<div class="vocation" style="margin-right: 5px; width: 179px">
					<select class="select1" name="stat">
					   		 <option  value="1"  th:selected="${problem.stat ==1}" >馆长端</option>
					   		 <option  value="2" th:selected="${problem.stat==2}" >家长端</option>
					   		 <option  value="3" th:selected="${problem.stat==3}" >馆长助理端</option>
					   		 <option  value="4" th:selected="${problem.stat==4}" >老师端</option>
					   		 <option  value="5" th:selected="${problem.stat==5}" >校长端</option>
					</select>
				</div>
		   </li>
		   <li class="clearfix">
				<label class="fl">排序<b>*</b></label>
				  <input  type="text" id="num"  th:value="${problem.num}" class="dfinput fl"  name="num">
			</li>
			<li class="clearfix">
				<label>内容:<b>*</b></label>
				 <input type="hidden" name="name" id="name" th:value="${problem.name}"/>
				 <script id="editor" type="text/plain"   style="line-height: 20px; overflow: hidden;width:80%;height:300px"></script>
			</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(){
	$("#roleFrom").validate({
		rules : {
			title : {
				required : true
			 },
	         type : {
			    required : true
		     },
		     end : {
				required : true
			 }
			},
		messages: {
			title : {
				required : "请输入标题"
			 },
	         type : {
			    required : "请输入类别"
		     },
		     end : {
				required : "请输入端别"
			 }
		   },
		errorPlacement : function(error, element) {
				error.appendTo(element.parent()); 
		},
		submitHandler : function(form) {
			roleFrom();
		}
	});
	
});
function roleFrom(){
	var url="[[${sysUrl}]]/sys/problem/saveProblem";
	var contents = UE.getEditor('editor').getContent();
	$('#name').val(contents);
	var params = $("#roleFrom").serialize();
	$.post(url,params,function(data){
		if(data != null){
			if(data.code=="999"){
					layer.msg("操作成功!",{icon:1});
			    	setTimeout(function(){
			    		window.location.href ='[[${sysUrl}]]/sys/problem/problemlist.html';
					},1000);
				}else{
					layer.msg(data.meta.message,{icon:11});
				}
		}
		
	});
}


</script>

<script type="text/javascript">
          
var editor = new baidu.editor.ui.Editor({
	elementPathEnabled : false
    ,wordCount:false         //是否开启字数统计
    ,maximumWords:1000       //允许的最大字符数
    ,wordCountMsg:'当前已输入 {#count} 个字符，您还可以输入{#leave} 个字符'
    //超出字数限制提示  留空支持多语言自动切换，否则按此配置显示
    ,wordOverFlowMsg:'<span style="color:red;">你输入的字符个数已经超出最大允许值！</span>' 
});

$(function(){
	editor.render('editor');
	editor.ready( function () { 
		 editor.setContent($('#name').val()); 
	 });  
	
});
</script>
</html>