<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('修改学校专业')" />
    <th:block th:include="include :: bootstrap-fileinput-css" />
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-major-edit" th:object="${tbSchoolMajor}">
            <input name="id" th:field="*{id}" type="hidden">
            <div class="form-group">
                <label class="col-sm-3 control-label is-required">学校名称：</label>
                <div class="col-sm-8">
                    <input name="schoolCnName" th:field="*{schoolCnName}" class="form-control" type="text" disabled="true">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label is-required">专业类型：</label>
                <div class="col-sm-8">
                    <input class="form-control" name="majorTypeDesc" th:field="*{majorTypeDesc}" type="text" disabled="true">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label is-required">专业名称：</label>
                <div class="col-sm-8">
                    <input name="majorCnName" th:field="*{majorCnName}" class="form-control" type="text" disabled="true">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label is-required">专业QS排名：</label>
                <div class="col-sm-8">
                    <input id="qs" th:field="*{qs}" class="form-control" type="text" disabled="true">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label is-required">专业图标：</label>
                <input type="hidden" class="form-control" th:field="*{majorIcon}">
                <div class="col-sm-8">
                    <div class="file-loading">
                        <input id="singleFile" name="file" type="file">
                    </div>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label is-required">专业封面：</label>
                <input type="hidden" class="form-control" th:field="*{majorCover}">
                <div class="col-sm-8">
                    <div class="file-loading">
                        <input id="singleMajorCover" name="file" type="file">
                    </div>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label is-required">学位中文名称：</label>
                <div class="col-sm-8">
                    <input name="degreeCnName" th:field="*{degreeCnName}" class="form-control" type="text" disabled="true">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label is-required">学位英文名称：</label>
                <div class="col-sm-8">
                    <input name="degreeEnName" th:field="*{degreeEnName}" class="form-control" type="text" disabled="true">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label is-required">学位类型：</label>
                <div class="col-sm-8">
<!--                    <select id="degreeType" class="form-control select2-multiple">-->
<!--                        <option>请选择学位类型</option>-->
<!--                    </select>-->
                    <input class="form-control" name="degreeTypeDesc" th:field="*{degreeTypeDesc}" type="text" disabled="true">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label is-required">学习时长：</label>
                <div class="col-sm-8">
                    <input name="learnTime" th:field="*{learnTime}" class="form-control" type="text" disabled="true">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label is-required">雅思分数：</label>
                <div class="col-sm-8">
                    <input name="ielts" th:field="*{ielts}" class="form-control" type="text" disabled="true">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label is-required">学费：</label>
                <div class="col-sm-8">
                    <input name="tuition" th:field="*{tuition}" class="form-control" type="text" disabled="true">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label is-required">入学时间：</label>
                <div class="col-sm-8">
                    <input name="enrollmentTime" th:field="*{enrollmentTime}" class="form-control" type="text" disabled="true">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label is-required">所需材料：</label>
                <div class="col-sm-9">
                    <label th:each="material:${@materialService.queryAll()}" class="check-box">
                        <input type ="checkbox" id="needMaterial" name="needMaterial"
                               th:value="${material.id}"
                               th:text ="${material.materialName}"
                               th:attr ='checked=${checkedList.contains(material.id) ? true : false}' disabled="true">
                    </label>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label  is-required">是否需要作品集：</label>
                <div class="col-sm-8">
                    <input class="form-control" name="needWorksDesc" th:field="*{needWorksDesc}" type="text" disabled="true">
<!--                    <select id="needWorks" class="form-control select2-multiple" required>-->
<!--                    </select>-->
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label is-required">是否需要前置学历：</label>
                <div class="col-sm-8">
<!--                    <select id="needEducation" class="form-control select2-multiple" required>-->
<!--                    </select>-->
                    <input class="form-control" name="needEducationDesc" th:field="*{needEducationDesc}" type="text" disabled="true">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label is-required">是否需要面试：</label>
                <div class="col-sm-8">
                    <input class="form-control" name="needInterviewDesc" th:field="*{needInterviewDesc}" type="text" disabled="true">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label is-required">审核结果：</label>
                <div class="col-sm-8">
                    <input name="checkResult" id="checkResult" th:field="*{checkResult}" class="form-control" type="text" required>
                </div>
            </div>
            <input id="checkStatusDesc" name="checkStatusDesc" th:field="*{checkStatusDesc}" type="hidden">
            <div class="form-group">
                <label class="col-sm-3 control-label is-required">审核状态：</label>
                <div class="col-sm-8">
                    <select id="checkStatus" class="form-control select2-multiple">
                        <option>请选择审核状态：</option>
                    </select>
                </div>
            </div>
        </form>
    </div>
    <th:block th:include="include :: footer" />
    <th:block th:include="include :: bootstrap-fileinput-js" />
    <script th:inline="javascript">
        var prefix = ctx + "system/majorCheck";
        $("#form-major-edit").validate({
            focusCleanup: true
        });

        function submitHandler() {
            if ($.validate.form()) {
                $.operate.save(prefix + "/edit", $('#form-major-edit').serialize()
                    +"&checkStatus="+$('#checkStatus')[0].value);
            }
        }
        initUpload();
        initMajorCover();

        //初始化方法
        function initUpload() {
            var logoUrl = $("#majorIcon").val();//拿到图片路径
            var preList = new Array();
            var initialPreviewConfig = new Array();
            //设置初始化区域值
            if (logoUrl != null && logoUrl != ''){
                var a = {
                    // caption : '主图'+(i+1),
                    // width: '120px',
                    url: '/common/del',
                    // key: i,
                    extra: {url: logoUrl}
                }
                preList.push(logoUrl);
                initialPreviewConfig.push(a);
            }

            $("#singleFile").fileinput({
                language: 'zh', //设置语言
                uploadUrl: "/common/upload", //上传的地址，改成自己的
                allowedFileExtensions:['bmp', 'gif', 'jpg', 'jpeg', 'png'],//接收的文件后缀
                initialPreviewAsData:true,
                initialPreview:preList,//预览图片
                uploadAsync: true, //默认异步上传
                showUpload: true, //是否显示上传按钮
                showRemove : false, //显示移除按钮
                showPreview : true, //是否显示预览
                showCaption: false,//是否显示标题
                browseClass: "btn btn-primary", //按钮样式
                dropZoneEnabled: false,//是否显示拖拽区域
                maxFileCount: 1, //表示允许同时上传的最大文件个数
                maxFileSize:10 *1024 *1024,
                messages: {maxFileSize:'文件上传的最大大小为 10MB',acceptFileTypes:'此文件是不支持的图片格式'    },
                enctype: 'multipart/form-data',
                validateInitialCount:true,
                msgFilesTooMany:5,
                autoReplace:false,
                initialPreviewConfig:initialPreviewConfig
            });
        }

        function initMajorCover() {
            var logoUrl = $("#majorCover").val();//拿到图片路径
            var preList = new Array();
            var initialPreviewConfig = new Array();
            //设置初始化区域值
            if (logoUrl != null && logoUrl != ''){
                var a = {
                    // caption : '主图'+(i+1),
                    // width: '120px',
                    url: '/common/del',
                    // key: i,
                    extra: {url: logoUrl}
                }
                preList.push(logoUrl);
                initialPreviewConfig.push(a);
            }

            $("#singleMajorCover").fileinput({
                language: 'zh', //设置语言
                uploadUrl: "/common/upload", //上传的地址，改成自己的
                allowedFileExtensions:['bmp', 'gif', 'jpg', 'jpeg', 'png'],//接收的文件后缀
                initialPreviewAsData:true,
                initialPreview:preList,//预览图片
                uploadAsync: true, //默认异步上传
                showUpload: true, //是否显示上传按钮
                showRemove : false, //显示移除按钮
                showPreview : true, //是否显示预览
                showCaption: false,//是否显示标题
                browseClass: "btn btn-primary", //按钮样式
                dropZoneEnabled: false,//是否显示拖拽区域
                maxFileCount: 1, //表示允许同时上传的最大文件个数
                maxFileSize:10 *1024 *1024,
                messages: {maxFileSize:'文件上传的最大大小为 10MB',acceptFileTypes:'此文件是不支持的图片格式'    },
                enctype: 'multipart/form-data',
                validateInitialCount:true,
                msgFilesTooMany:5,
                autoReplace:false,
                initialPreviewConfig:initialPreviewConfig
            });
        }

        $(document).ready(function() {
            <!--异步请求-->
            $.ajax({
                url: ctx+"system/dict/data/business_check_status",
                type: "get",
                dataType: "json",
                success: function(data){
                    for(var i=0; i<data.length; i++){
                        $("#checkStatus").append("<option value='" + data[i].dictValue + "'>" + data[i].dictLabel + "</option>");
                    }
                    var vtext = $("#checkStatusDesc")[0].value;
                    $("#checkStatus").find("option").each(function(){
                        if($(this).text() == vtext)	{
                            $(this).attr("selected",true);
                        }
                    });
                }
            });
        });
    </script>
</body>
</html>