<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/kmt.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>

<script type="text/javascript" src="https://t.sharingschool.com/dcui/tools/ueditor/kityformula-plugin/addKityFormulaDialog.js"></script>
<script type="text/javascript" src="https://t.sharingschool.com/dcui/tools/ueditor/kityformula-plugin/getKfContent.js"></script>
<script type="text/javascript" src="https://t.sharingschool.com/dcui/tools/ueditor/kityformula-plugin/defaultFilterFix.js"></script>


	<style>
		body {
			min-width: 180px;
		}

		.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;
		}

		.btn {
			width: 100px;
		}

		label.control-label-error {
			color: Red;
		}

		.forminfo li label {
			width: 85px;
			line-height: 34px;
			display: block;
			float: left;
		}
	</style>
</head>

<body>
<div class="formbody">
	<form id="submitFrom"   method="post" class="form-horizontal form-validate">
		     <input type="hidden" name="howId" id="howId" th:value="${how.howId}"/>
		     <input type="hidden" name="howDetailsId" id="howDetailsId" th:value="${how.howDetailsId}"/>
		     <input type="hidden" name="id" id="id" th:if="${how.id}"  th:value="${how.id}"/>
		      <input type="hidden" name="courseName" id="coursename"  th:value="${param.courseName}"/>
		     
		<ul class="forminfo">
			 <li class="clearfix">
				<label>内容:<b>*</b></label>
				
				<textarea rows="5" id="name" name="name" class="textinput"
				
				 style="width: 346px;    height: 112px;" cols="5">[[${how.name}]]</textarea>
				 
			 </li>
			  <li>
				<label>排序:<b>*</b></label>
				<input type="number" id="num" class="dfinput fl" name="num"  th:value="${how.num}"/>
			 </li>
			  <li>
				<label title="换行#N，相隔#&">要点梳理:<b>*</b></label>
				<textarea rows="5" id="ydsl" hidden="hidden" name="ydsl" class="textinput"
				placeholder="换行#N，相隔#&"
				 style="width: 346px;    height: 112px;" cols="5"></textarea>
				  <script id="ydslueditor"    type="text/plain" style=" margin-left:110px ;width: 600px;    height: 112px;"></script>
				 
			  </li>
			  <li>
			    <input type="hidden" name="img" id="img" th:value="${how.img}"/>
				<label class="upload-file">要点梳理图片<b>*</b></label>
				<img id="imgImg" th:src=" ${how.img} !=null  ? (${how.img} !='' ? ${imgUrl}+''+${how.img}+'?x-oss-process=image/resize,m_lfit,h_100,w_120' : '' ) :'' "  style="width:200px;height:140px; margin-left: 109px;" />
				<input type="file" id="upfile">
			</li>
			 <li>
				<label >标签:<b>*</b></label>
				<textarea rows="5" id="label" name="label" class="textinput"
				 style="width: 346px;    height: 112px;" cols="5">[[${how.label}]]</textarea>
			  </li>
			  <li>
				<label class="fl">级别<b>*</b></label>
				<div class="vocation" style="margin-right: 5px;">
					  <label class="fl" th:each="item : ${kd_level}" 
					  th:for="${item.code}" >
					  <input type="checkbox" th:id="${item.code}"  name="level" 
					  th:checked="${#lists.contains(#strings.listSplit( (how.level ne null ? how.level :'' ),','), item.aliases)}"
					  th:value="${item.aliases}"/>[[${item.name}]]
					  </label>
				</div>	  
			  </li>
			  
			  <li th:if="${#strings.isEmpty(how.id)}" id="vocation_version">
				<label>版本:<b>*</b></label>
				<div class="vocation_version" style="margin-right: 5px; width: 446px">
				
				    <label th:each="version:${versions['数学'] }" class="other"   th:style="${param.courseName!=null && param.courseName eq '数学' ? '' : 'display: none'}"><input type="checkbox" class="version" name="version"  th:value="${version.versionType }" />[[${version.versionName}]]</label>
			 	 	<label th:each="version:${versions['语文'] }" class="chinese" th:style="${param.courseName!=null && param.courseName eq '语文' ? '' : 'display: none'}"><input type="checkbox" class="version" name="version"  th:value="${version.versionType }" />[[${version.versionName}]]</label>
			 		<label th:each="version:${versions['英语'] }" class="english" th:style="${param.courseName!=null && param.courseName eq '英语' ? '' : 'display: none'}"><input type="checkbox" class="version" name="version"  th:value="${version.versionType }" />[[${version.versionName}]]</label>
			
				
<!-- 				     <label class="other" ><input type="checkbox" class="version" name="version"  value="1" />北师大</label> -->
<!-- 					<label class="other" ><input type="checkbox" class="version" name="version"  value="2" />人教版</label> -->
<!-- 					<label class="other" ><input type="checkbox" class="version" name="version"  value="5" />江苏版</label> -->
<!-- 					<label class="other"><input type="checkbox" class="version" name="version"  value="6" />思维拓展</label> -->
					
<!-- 					<label class="chinese" style="display: none"><input type="checkbox" class="version" name="version"  value="2" />人教(部编)</label> -->
			
					
<!-- 					<label class="english" ><input type="checkbox" class="version"  name="version"  value="2" />教科版</label> -->
<!-- 					<label class="english" ><input type="checkbox" class="version"   name="version"  value="3" />沪教版（新）</label> -->
<!-- 					<label class="english" ><input type="checkbox" class="version"   name="version"  value="7" />朗文版</label> -->
<!-- 					<label class="english" ><input type="checkbox" class="version"   name="version"  value="8" />人教版（PEP）</label> -->
<!-- 					<label class="english" ><input type="checkbox" class="version"   name="version"  value="9" />牛津版</label> -->
				</div>
			 </li>
			  <li class="clearfix schoolgrade" th:if="${#strings.isEmpty(how.id)}" style="display: none ">
				    <label>年级：<b>*</b></label>
					<div class="vocation" style="margin-right: 5px; width: 300px">
						<select class="select1" name="gradeNum">
						   		 <option th:value="${list.aliases}" th:selected="${ how.gradeNum+'' eq list.aliases }" 
						   		  th:if="${list.aliases ne '0'}"
						   		  th:each="list:${grade}" th:text="${list.name}">学前</option>
						</select>
					</div>
			   </li>
			  <li th:if="${#strings.isEmpty(how.id)}" class="schoolgrade" style="display: none ">
				    <label>学期：<b>*</b></label>
					<div class="vocation" style="margin-right: 5px; width: 346px">
					    <label><input type="radio" class="isZt" name="semester"  value="1" />上学期</label>
						<label><input type="radio" class="isZt" name="semester"  value="2" />下学期</label>
				    </div>
			   </li>
			   
				<li>
					<label>&nbsp;</label>
					<button type="submit" class="btn">保存</button>
					<button type="button" class="btn" onclick="closeWin();">取消</button>
				</li>
		</ul>
	</form>
</div>
</body>
<div style="display: none" id="ydsltemp" th:utext="${how.ydsl}"></div>
<script th:include="sys/common/fileUpload" th:remove="tag"></script> 
<script type="text/javascript">
var ydslueditor =null;
$(function(){
	
	if($("#coursename").val()=='英语'){
		$(".english").show();
		$(".other").hide();
		$(".chinese").hide();
	}else if($("#coursename").val()=='语文'){
		$(".chinese").show();
		$(".english").hide();
		$(".other").hide();
	}else{
		$(".chinese").hide();
		$(".english").hide();
		$(".other").show();
	}

	$(".version").on("click",function(){
		if($('.version').is(':checked')){
			$('.schoolgrade').show();
		}else{
			$('.schoolgrade').hide();
		}
	});
	ydslueditor = UE.getEditor('ydslueditor');
	ydslueditor.addListener("ready", function () {
		ydslueditor.execCommand('insertHtml',$("#ydsltemp").html() );
	 });
	$("#submitFrom").validate({
		rules : {
			
			name : {
				required : true
			}
		},
		messages: {
			name : {
				required : "考点内容不能为空"
			}
			
		},
		errorPlacement : function(error, element) {
				error.appendTo(element.parent()); 
		},
		submitHandler : function(form) {
			roleFrom();
		}
	});
	
	
});
function roleFrom(){
	ydslueditor.getKfContent(function (content) { 
		$("#ydsl").val(content.replace(/&amp;/g, "&"));
		var url="[[${sysUrl}]]/sys/zuoyb/knowHowDetailKdSave";
		var params = $("#submitFrom").serialize();
		$.post(url,params,function(data){
			if(data != null){
					if(data.meta.success){
						parent.layer.msg("新增成功",{icon:1});
						closeWin();
					}else{
						parent.layer.msg(data.meta.message,{icon:11});
						closeWin();
					}
			}
			
		});
	});
}
function closeWin(){
	parent.location.reload();
	parent.layer.close(parent.layer.getFrameIndex(window.name));
}
$(function(){
	initUpload(uploadOptions("upfile","上传图片"),"img","imgImg");
});

//附件上传
function uploadFile(){
	$("#upfile").uploadify("upload", "*");
}


</script>
</html>