<!DOCTYPE html>
<html lang="en">
<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/peiyou/peiyouList.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}"/>
        <ul class="forminfo">
            <li class="clearfix">
                <label>科目：<b>*</b></label>
                <input type="text" id="courseName" name="courseName" class="dfinput fl" th:value="${entity.courseName}">
            </li>
            <li class="clearfix">
                <label>年级：<b>*</b></label>
                <input type="text" id="grade" name="grade" class="dfinput fl" th:value="${entity.grade}">
            </li>
            <li class="clearfix">
                <label>版本：<b>*</b></label>
                <input type="text" id="bookName" name="bookName" class="dfinput fl" th:value="${entity.bookName}">
            </li>
            <li class="clearfix">
                <label>单元：<b>*</b></label>
                <input type="text" id="unit" name="unit" class="dfinput fl" th:value="${entity.unit}">
            </li>
            <li class="clearfix">
                <label>二级单元：<b>*</b></label>
                <input type="text" id="secondUnit" name="secondUnit" class="dfinput fl" th:value="${entity.secondUnit}">
            </li>
            <li class="clearfix">
                <label>难易级别：<b>*</b></label>
                <input type="text" id="difficultyLevel" name="difficultyLevel" class="dfinput fl" th:value="${entity.difficultyLevel}">
            </li>
            <li class="clearfix">
                <input type="hidden" name="studentBookPath" id="studentBookPath" th:value="${entity.studentBookPath}"/>
                <label class="upload-file">学生上传：</label>
                <input type="file" id="upfile">
            </li>
            <li class="clearfix">
                <input type="hidden" name="teacherBookPath" id="teacherBookPath" th:value="${entity.teacherBookPath}"/>
                <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 : {
                courseName: {
                    required : true
                }
            },
            messages: {
                courseName: {
                    required : "科目不能为空"
                }
            },
            rules : {
                grade: {
                    required : true
                }
            },
            messages: {
                grade: {
                    required : "年级不能为空"
                }
            },

            errorPlacement : function(error, element) {
                error.appendTo(element.parent());
            },
            submitHandler : function(form) {
                roleFrom();
            }
        });

    });
   function roleFrom(){
       var url="[[${sysUrl}]]/sys/peiyou/peiyouSave";
       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/peiyou/peiyouList.html';
                   },1000);
               }else{
                   parent.layer.msg(data.meta.message,{icon:11});
               }
           }

       });
   }
    var options = uploadOptions("upfile","学生版上传");
    var options_att = uploadOptions("upAttach","老师版上传");

   $(function(){
        options.fileTypeExts = "*.PDF";
        options.fileSizeLimit= '200MB';
        options.uploader= "[[${sysUrl}]]/sys/peiyou/upload";
        initUpload(options,"studentBookPath","");
        options_att.fileTypeExts = "*.*";
        options_att.fileSizeLimit= '200MB';
        options_att.uploader= "[[${sysUrl}]]/sys/peiyou/upload";
        initUpload(options_att,"teacherBookPath","");
    });

</script>
</html>