<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>

 <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/appinfo/appinfoList.html}">版本信息添加</a></li>
	</ul>
</div>
<div class="formbody">
	<div class="formtitle"><span th:text="${entity.id} ? '修改发版信息' :'新增发版信息'">发版信息</span></div>
	<form id="submitFrom"   method="post" class="form-horizontal form-validate">
		<input type="hidden" name="id" th:if="${entity.id}" th:value="${entity.id}"/>
		<input type="hidden" name="versionType" th:value="RELEASE"/>
		<input type="hidden" name="issueNum" th:value="1"/>
		<input type="hidden" name="isDelete" th:value="0"/>
		<ul class="forminfo">
			<li class="clearfix">
				<label>版本号：<b>*</b></label>
				<input type="text" id="version" name="version" class="dfinput fl" th:value="${entity.version}">
			</li>
			<li class="clearfix">
				<input type="hidden" name="fileKey" id="fileKey" th:value="${entity.fileKey}"/>
				<label class="upload-file">上传发版包：</label>
				<input type="file" id="upfile">
				<!--<a id="uploadApk" th:if="${entity.fileKey}" th:src=" ${entity.fileKey} !=null  ? (${entity.fileKey} !='' ? ${imgUrl}+''+${entity.fileKey} : '' ) :'' " style="width:200px;height:140px; margin-left: 109px;">apk</a>-->
			</li>
			<li class="clearfix">
				<label>发版端：<b>*</b></label>
				<div id="type" class="vocation" style="margin-right: 5px; width: 346px">
					<select class="select1" name="type" onchange="changeType()">
						<option  value="1" th:selected="${entity.type==1}" >小塾（深圳）</option>
						<option  value="4" th:selected="${entity.type==4}" >小塾（上海）</option>
						<option  value="2" th:selected="${entity.type==2}" >家长端（Android）</option>
						<option  value="3" th:selected="${entity.type==3}" >家长端（iOS）</option>
						<option  value="5" th:selected="${entity.type==5}" >老师端（Android）</option>
						<option  value="6" th:selected="${entity.type==6}" >老师端（iOS）</option>
						<option  value="7" th:selected="${entity.type==7}" >小塾pro</option>
						<option  value="8" th:selected="${entity.type==8}" >小塾学伴pad（iOS）</option>
						<option  value="11" th:selected="${entity.type==11}" >小塾学伴pad（Android）</option>
						<option  value="10" th:selected="${entity.type==10}" >小塾学伴（iOS）</option>
						<option  value="9" th:selected="${entity.type==9}" >小塾学伴（Android）</option>
					</select>
				</div>
			</li>
			<li>
				<label>更新内容：</label>
				<textarea style="border: solid 1px #a7b5bc;width: 345px" rows="15" name="updateContent">[[${entity.updateContent}]]</textarea>
			</li>
			<li>
				<label>是否需要升级：</label>
				<div class="vocation" style="margin-right: 5px; width: 346px">
					<label><input type="radio" class="isZt" name="needUpdate" th:checked="${ entity.needUpdate eq 0  }" value=0 />否</label>
					<label><input type="radio" class="isZt" name="needUpdate" th:checked="${ entity.needUpdate eq 1 }" value=1 />是</label>
				</div>
			</li>
			<li class="clearfix">
				<input type="hidden" name="attachmentUrl" id="attachmentUrl" th:value="${entity.attachmentUrl}"/>
				<label class="upload-file">上传附件：</label>
				<input type="file" id="upAttach">
			</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 id="dispaly-progress"></div>
</div>
</body>
<script th:include="sys/common/fileUpload" th:remove="tag"></script>
<script type="text/javascript">

$(function(){
	$("#submitFrom").validate({
		ignore:"",
		rules : {
            version: {
                required : true
			}
		},
		messages: {
            version: {
                required : "版本号不能为空"
            }
		},
		errorPlacement : function(error, element) {
				error.appendTo(element.parent()); 
		},
		submitHandler : function(form) {
			roleFrom();
		}
	});
	
});
function roleFrom(){
	var url="[[${sysUrl}]]/sys/appinfo/appinfoSave";
	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/appinfo/appinfoList.html';
					},1000);
				}else{
					parent.layer.msg(data.meta.message,{icon:11});
				}
		}
		
	});
}
var options = uploadOptions("upfile","上传发版包");
var options_att = uploadOptions("upAttach","上传附件");
function changeType(){
    var type = $(".select1 option:selected").val();
    options.uploader= "[[${sysUrl}]]/sys/appinfo/upload/"+type;
    initUpload(options,"fileKey","");
}
$(function(){
    options.fileTypeExts = "*.apk";
    options.fileSizeLimit= '200MB';
    var type=$(".select1 option:selected").val();
    options.uploader= "[[${sysUrl}]]/sys/appinfo/upload/"+type;
    initUpload(options,"fileKey","");
    options_att.fileTypeExts = "*.*";
    options_att.fileSizeLimit= '200MB';
    options_att.uploader= "[[${sysUrl}]]/sys/appinfo/upload/"+999;
    initUpload(options_att,"attachmentUrl","");
});

</script>
</html>