<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>
 <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 th:href="@{/sys/problem/weikeStoryList.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}"/>
		<ul class="forminfo">
			<li class="clearfix">
				<label>名称:<b>*</b></label>
				<input type="text" id="name" class="dfinput fl" name="name"  th:value="${ws.name}"/>
			</li>
			<li class="clearfix">
				<label>旁听数:<b>*</b></label>
				<input type="text" id="listen" class="dfinput fl" name="listen"  th:value="${ws.listen}"/>
			</li>
			
			<li class="clearfix">
			    <input type="hidden" name="audioUrl" id="audioUrl" th:value="${ws.audioUrl}"/>
				<label class="upload-file">音频<b>*</b></label>
				 <audio style="margin-left: 108px; margin-bottom: 20px;" id="fileUrlAudio" controls="controls" th:if="${ws.audioUrl}" th:src="${imgUrl}+''+${ws.audioUrl}" ></audio>
				<input type="file" id="upfile">
			</li>
			
			<li class="clearfix">
			    <input type="hidden" name="imgUrl" id="imgUrl" th:value="${ws.imgUrl}"/>
				<label class="upload-file">照片<b>*</b></label>
				<img id="imgUrlImg" th:src=" ${ws.imgUrl} !=null  ? (${ws.imgUrl} !='' ? ${imgUrl}+''+${ws.imgUrl}+'?x-oss-process=image/resize,m_lfit,h_100,w_120' : '' ) :'' "  style="width:200px;height:140px; margin-left: 109px;" />
				<input type="file" id="imgfile">
			</li>
			<li class="clearfix" >
			    <label>时间：<b>*</b></label>
				<input type="text" id="createTime" class="dfinput fl" name="createTime" 
				th:value="${#calendars.format(ws.createTime,'yyyy-MM-dd HH:mm:ss')}"
				onfocus="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss'})" />
					        	
		   </li>
		   
		    <li>
				<label>详情:<b>*</b></label>
				 <textarea rows="3" style="width: 382px;" id="details" name="details" class="textinput"  cols="5">[[${ws.details}]]</textarea>
			</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 th:include="sys/common/fileUpload" th:remove="tag"></script> 
<script type="text/javascript">

$(function(){
	$("#submitFrom").validate({
		rules : {
			
			name : {
				required : true,
				maxlength: 300
			}
		},
		messages: {
			name : {
				required : "不能为空",
				maxlength : "最多300个字符",
			}
			
		},
		errorPlacement : function(error, element) {
				error.appendTo(element.parent()); 
		},
		submitHandler : function(form) {
			roleFrom();
		}
	});
	
});
function roleFrom(){
	var url="[[${sysUrl}]]/sys/problem/saveWeikeStory";
	var params = $("#submitFrom").serialize();
	$.post(url,params,function(data){
		if(data != null){
				if(data.meta.success){
					layer.msg("操作成功!",{icon:1});
			    	setTimeout(function(){
			    		window.location.href ='[[${sysUrl}]]/sys/problem/weikeStoryList.html';
					},1000);
				}else{
					layer.msg(data.meta.message,{icon:11});
				}
		}
		
	});
}

$(function(){
	initUpload(uploadAudio("upfile","上传音频"),"audioUrl","fileUrlAudio");
	initUpload(uploadOptions("imgfile","上传图片"),"imgUrl","imgUrlImg");
});

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

</script>
</html>