<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 th:href="@{/sys/ydz/articelist.html}">文章列表管理</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="${artice.id}" th:value="${artice.id}" name="id">
		<ul class="forminfo">
			<li class="clearfix">
				<label class="fl">标题<b>*</b></label>
				  <input  type="text" id="headline"  th:value="${artice.headline}" class="dfinput fl"  name="headline">
			</li>
			<li class="clearfix">
				<label>内容:<b>*</b></label>
				<input type="hidden" name="content" id="content" class="dfinput fl" th:value="${artice.content}"/>
				<script id="editor" type="text/plain"   style="line-height: 20px; overflow: hidden;width:80%;height:200px"></script>
			</li>
			<li class="clearfix" id="clearfix">
				    <label>年级：<b>*</b></label>
					<div class="vocation" style="margin-right: 5px; width: 300px">
						<select class="select1" name="grade">
						   		<option value="学前">学前</option>
                                 <option value="一年级">一年级</option>
						   		 <option value="二年级">二年级</option>
						   		 <option value="一二年级">一二年级</option>
						   		 <option value="三年级">三年级</option>
						   		 <option value="四年级">四年级</option>
						   		 <option value="三四年级">三四年级</option>
						   		 <option value="五年级">五年级</option>
						   		 <option value="六年级">六年级</option>
						   		 <option value="五六年级">五六年级</option>
						   		 <option value="七年级">七年级</option>
						   		 <option value="八年级">八年级</option>
						   		 <option value="九年级">九年级</option>
						</select>
					</div>
			   </li>
			<li class="clearfix">
			    <label>版本：<b>*</b></label>
				<div class="vocation" style="margin-right: 5px; width: 179px">
					<select class="select1" name="version">
					   		 <option  value="1"  th:selected="${artice.version==1}" >第一套</option>
					   		 <option  value="2"  th:selected="${artice.version==2}" >第二套</option>
					   		 <option  value="3"  th:selected="${artice.version==3}" >第三套</option>
					</select>
				</div>
		   </li>
		   <li class="clearfix">
				<label class="fl">排序<b>*</b></label>
				  <input  type="text" id="number"  th:value="${artice.number}" class="dfinput fl"  name="number">
			</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 : {
			grade : {
				required : true
			 }
			},
		messages: {
			grade : {
				required : "请选择年级"
			 }
		   },
		errorPlacement : function(error, element) {
				error.appendTo(element.parent()); 
		},
		submitHandler : function(form) {
			roleFrom();
		}
	});
	
});
function roleFrom(){
	var url="[[${sysUrl}]]/sys/ydz/saveArtice";
	var contents = UE.getEditor('editor').getContent();
	$('#content').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/ydz/articelist.html';
					},1000);
				}else{
					layer.msg(data.meta.message,{icon:11});
				}
		}
		
	});
}

          
var tool = 
	[
		"fullscreen", "undo", "redo", "|",
		"bold", "italic", "underline", "fontborder", "strikethrough", "superscript", "subscript", "removeformat", "formatmatch", "autotypeset", "blockquote", "pasteplain", "|", "forecolor", "backcolor", "insertorderedlist", "insertunorderedlist", "selectall", "cleardoc", "|",
		"rowspacingtop", "rowspacingbottom", "lineheight", "|",
		"customstyle", "paragraph", "fontfamily", "fontsize", "|",
		"directionalityltr", "directionalityrtl", "indent", "|",
		"justifyleft", "justifycenter", "justifyright", "justifyjustify", "|", "touppercase", "tolowercase", "|",
		"imagenone", "imageleft", "imageright", "imagecenter", "|",
		"emotion","pagebreak", "template", "|",
		"horizontal", "date", "time", "spechars",  "|",
		"inserttable", "deletetable", "insertparagraphbeforetable", "insertrow", "deleterow", "insertcol", "deletecol", "mergecells", "mergeright", "mergedown", "splittocells", "splittorows", "splittocols", "charts", "|",
		"preview", "searchreplace","drafts" 
		];
          
var editor = new baidu.editor.ui.Editor({
	//toolbars: [tool],
	elementPathEnabled : false
    ,wordCount:false         //是否开启字数统计
    ,maximumWords:1000       //允许的最大字符数
    ,wordCountMsg:'当前已输入 {#count} 个字符，您还可以输入{#leave} 个字符'
    //超出字数限制提示  留空支持多语言自动切换，否则按此配置显示
    ,wordOverFlowMsg:'<span style="color:red;">你输入的字符个数已经超出最大允许值！</span>' 
});

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