<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/wx/messsageReply.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="mediaId"  th:value="${ws.mediaId}"/>
		     <input type="hidden" name="created"  th:value="${ws.created}"/>
			 <input type="hidden" name="type"  th:value="normal"/>
		<ul class="forminfo">
			<li class="clearfix">
				<label>关键词：<b>*</b></label>
				<input type="text" id="keyword" name="keyword" class="dfinput fl" th:value="${ws.keyword}">
			</li>
			<li class="clearfix">
				<label>文字：</label>
				<textarea rows="10" id="text" name="text" class="textinput" cols="10">[[${ws.text}]]</textarea>
			</li>
			<li class="clearfix">
				<input type="hidden" name="imgUrl" id="imgUrl" th:value="${ws.imgUrl}"/>
				<label class="upload-file">图片：</label>
				<img id="imgImg" 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="upfile">
			</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({
		ignore:"",
		rules : {
			keyword : {
				required : true,
				maxlength: 100
			}
		},
		messages: {
            keyword : {
				required : "关键词不能为空",
				maxlength : "最多100个字符"
			}
		},
		errorPlacement : function(error, element) {
				error.appendTo(element.parent()); 
		},
		submitHandler : function(form) {
			roleFrom();
		}
	});
	
});
function roleFrom(){
	var url="[[${sysUrl}]]/sys/wx/messageSave";
	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/wx/messageReply.html';
					},1000);
				}else{
					parent.layer.msg(data.meta.message,{icon:11});
				}
		}
		
	});
}

$(function(){
	initUpload(uploadOptions("upfile","上传图片"),"imgUrl","imgImg");
});

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

</script>
</html>