<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/webpage/include/taglib.jsp"%>
<html>
<head>
	<title>版本信息管理</title>
	<meta name="decorator" content="default"/>
    <style>
        label.error{
            left:0;
            top:40px;
        }
    </style>
	<script type="text/javascript">
		var validateForm;
		function doSubmit(){//回调函数，在编辑和保存动作时，供openDialog调用提交表单。
            var val=$("#tel_remarks option:selected").val();
            if(val=="Android"){
                var obj =$("#appFile")[0].files[0];
                var fileType = obj.name;
                console.info(fileType);
                if(fileType.endsWith("apk")){

                }else {
                    //需要置空
                    var file = $("#appFile");
                    file.after(file.clone().val(""));
                    file.remove();
                    top.layer.alert('请上传*.apk格式的文件',{icon:0,title:'系统提示'});
                    return false ;
                }
            }

		  if(validateForm.form()){
			  $("#inputForm").submit();
			  return true;
		  }
	
		  return false;
		}
		$(document).ready(function() {
			validateForm = $("#inputForm").validate({
				submitHandler: function(form){
					loading('正在提交，请稍等...');
					form.submit();
				},
				errorContainer: "#messageBox",
				errorPlacement: function(error, element) {
					$("#messageBox").text("输入有误，请先更正。");
					if (element.is(":checkbox")||element.is(":radio")||element.parent().is(".input-append")){
						error.appendTo(element.parent().parent());
					} else {
						error.insertAfter(element);
					}
				}
			});
			//查看时禁用
            $("input,select,textarea").attr("disabled",${readAttr});

            //默认不显示
            $("#android_app_url,#android_app_files").hide();
        });
        
		function  select_ios_android() {
            var remarks = $("#tel_remarks option:selected").val().toLocaleLowerCase();
            if("android" == remarks){
                $("#android_app_files").show();
            }else if("ios" == remarks){
                $("#android_app_files").hide();
            }
        }
    </script>
    <style>
        /*超过5个汉字，调整label的长度，以下是配套的*/
        .layui-item .layui-form-label{
            width:90px;
        }
        .form-group .layui-item .layui-input-block,
        .query .layui-input-block {
            margin-left: 116px;
        }
    </style>
</head>
<body >
<div class="single-form">
    <div class="container">
		<form:form id="inputForm" modelAttribute="appversions" enctype="multipart/form-data" action="${ctx}/appversion/appversions/save" method="post" class="form-horizontal">
		<form:hidden path="id"/>
		<sys:message content="${message}"/>	
        <%--<table class="table table-bordered  table-condensed dataTables-example dataTable no-footer">
            <tbody>
            <tr>
                <td  class="width-15 active">	<label class="pull-right"><font color="red">*</font>手机类型：</label></td>
                <td class="width-35" >
                    <form:select path="remarks" id="tel_remarks" class="form-control input-sm" onchange="select_ios_android();">
                        <form:option value="" label=""/>
                        <form:option items="IOS" value="IOS" itemLabel="label" itemValue="value" htmlEscape="false"/>
                        <form:option items="Android" value="Android" itemLabel="label" itemValue="value" htmlEscape="false"/>
                    </form:select>
                </td>
                <td  class="width-15 active">	<label class="pull-right"><font color="red">*</font>版本信息：</label></td>
                <td class="width-35" ><form:input path="versions" htmlEscape="false" maxlength="200" class="form-control required"/></td>
            </tr>
            <tr>
                <td  class="width-15 active">	<label class="pull-right"><font color="red">*</font>更新内容：</label></td>
                <td class="width-75" colspan="3" >
                    <form:textarea path="content" htmlEscape="false" colspan="3" rows="6" maxlength="550" class="form-control "/>
                </td>
            </tr>
            <tr id="android_app_url">
                <td class="width-15 active"><label class="pull-right"><font color="red">*</font>下载地址：</label></td>
                <td class="width-75" colspan="3">
                    <form:textarea  path="url" htmlEscape="false" colspan="3" rows="2" maxlength="550" cssClass="form-control"/><br>
                </td>
            </tr>
            <tr id="android_app_files">
                <td  class="width-15 active">	<label class="pull-right">上传Android APP：</label></td>
                <td class="width-75" colspan="3" >
&lt;%&ndash;
                    <form:hidden id="files" path="files" htmlEscape="false" maxlength="255" class="form-control"/>
                    <sys:ckfinder input="files" type="files" uploadPath="/appversion/appversions" selectMultiple="true"/>
&ndash;%&gt;
                    <input type="file" name="appFile"/>
                </td>
            </tr>
            </tbody>--%>
            <div class="form-group layui-row first">
            <div class="form-group-label"><h2>基本信息</h2></div>
            <div class="layui-item layui-col-sm6">
                <label class="layui-form-label"><span class="require-item">*</span>手机类型：</label>
                <div class="layui-input-block">
                    <form:select  path="remarks" id="tel_remarks" class="form-control required  simple-select" onchange="select_ios_android();">
                        <form:option value="" label=""/>
                        <form:option items="IOS" value="IOS" itemLabel="label" itemValue="value" htmlEscape="false"/>
                        <form:option items="Android" value="Android" itemLabel="label" itemValue="value" htmlEscape="false"/>
                    </form:select>
                </div>
            </div>
            <div class="layui-item layui-col-sm6">
                <label class="layui-form-label"><span class="require-item">*</span>版本信息：</label>
                <div class="layui-input-block">
                    <form:input path="versions" htmlEscape="false"   id="versions"  class="form-control required layui-input" value="${appversions.versions}"/>
                </div>
            </div>
                <div class="layui-item layui-col-sm6" id="android_app_url">
                    <label class="layui-form-label"><span class="require-item">*</span>下载地址：</label>
                    <div class="layui-input-block">
                        <form:input path="url" htmlEscape="false"   id="model"  class="form-control required layui-input" value="${appversions.url}"/>
                    </div>
                </div>
                <div class="layui-item layui-col-sm6" id="android_app_files">
                    <label class="layui-form-label double-line"><span class="require-item">*</span>上传Android APP：</label>
                    <div class="layui-input-block">
                        <input type="file" name="appFile" id="appFile"/>
                    </div>
                </div>
            <div class="layui-item layui-col-sm12">
                <label class="layui-form-label">更新内容：</label>
                <div class="layui-input-block">
                    <form:textarea path="content" htmlEscape="false"  rows="6" maxlength="550" class="form-control "/>
                </div>
            </div>

    </div>
    <div class="form-group layui-row page-end"></div>
	</form:form>
    </div>
</div>
</body>
</html>