<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp" %>
<html>
<head>
    <title>评卷员管理</title>
    <meta name="decorator" content="default"/>
    <%@include file="/WEB-INF/views/include/head.jsp" %>
    <style type="text/css">.sort {
        color: #0663A2;
        cursor: pointer;
    }</style>
    <style type="text/css">
        .sort {
            color: #0663A2;
            cursor: pointer;
        }
        
        .taskWindow, .reSetPasswordWin {
            width: 400px;
            min-height: 150px;
            background: #fff;
            font-family: "微软雅黑", Fixedsys;
            border: #5d6d7d solid 1px;
            position: absolute;
            left: 50%;
            top: 50%;
            margin: -150px 0 0 -200px;
            text-align: center;
            z-index: 99999;
        }
        
        .task-header, .password-header {
            width: 100%;
            height: 46px;
            background: #5d6d7d;
            color: #fff;
        }
        
        .task-content, .password-content {
            font-size: 18px;
            color: #005277;
            text-align: left;
            padding: 15px;
            line-height: 30px;
            word-wrap: break-word;
        }
        
        .image-close {
            margin-top: 15px;
            margin-right: 15px;
            cursor: pointer;
            float: right;
        }
        
        .title {
            font-size: 22px;
            font-weight: bold;
            color: #fff;
            margin: 0px;
            padding: 13px 0 0 13px;
            float: left;
        }

        .task-count, .password-value {
            width: 150px;
        }

        .btn-info {
            height: 25px;
            margin-left: 320px;
            margin-bottom: 20px;
        }
        
        .wrong, .passwordWrong {
            font-size: 12px;
            color: #f00;
            line-height: 30px;
            padding-left: 20px;
        }
        
        #cover {
            position: fixed;
            z-index: 9999;
            top: 0px;
            left: 0px;
            display: none;
            width: 100%;
            height: 100%;
            opacity: 0.5;
            background: #000 none repeat scroll 0% 0%;
        }
    </style>
    <link rel="stylesheet" href="${ctxStatic}/common/animate.min.css" />
	<style>
		#delete-modal{
            position:fixed;
            left:0;
            right:0;
            top:0;
            bottom:0;
            z-index:500;
            display:none;
            background:rgba(0,0,0,.3);
        }
        #deleteDiv {
            position:absolute;
            left:50%;
            top:50%;
            transform:translateX(-50%) translateY(-50%);
        }
        .my-form {
            padding: 0 20px;
            position: fixed;
            z-index: 1000;
            left: 50%;
            top: 50%;
            transform: translateX(-50%) translateY(-50%);
            background: #fff;
            border-radius: 4px;
            width: 384px;
            border: 1px solid #ddd;
        }
        .my-form .my-form-head {
            padding: 15px 0 10px;
            position: relative;
        }
        .my-form .my-form-head .close-icon {
            position: absolute;
            right: -10px;
            top: 14px;
            width: 24px;
            cursor: pointer;
        }
        .my-form .my-form-head .title-box {
            padding-right: 30px;
            display: flex;
            align-items: center;
        }
        .my-form .my-form-head .title-box .title2 {
            font-size: 16px;
            font-weight: bold;
            margin-left: 6px;
            color:#595959;
        }
        .my-form .my-form-head .title-box .warning-icon {
            width: 24px;
        }
        .my-form .sub-title {
            color: #595959;
            line-height: 22px;
            font-size: 14px;
            padding-left: 30px;
        }
        .my-form .sub-title span {
            color: #F53F3F;
        }
        .my-form .my-form-body {
            padding: 20px 0;
        }
        .my-form .my-form-body .gray-bg {
            background: #F0F0F0;
            border-radius: 4px;
            padding: 30px 20px 20px;
        }
        .my-form-item {
            display: flex;
            align-items: flex-start;
        }
        .my-form-item label {
            font-size: 14px;
            color: #595959;
            width: 120px;
            line-height: 30px;
        }
        .my-form-item .control-box {
            flex: 1;
        }
        .my-form-item .control-box .error-tip {
            height: 24px;
            line-height: 20px;
            font-size: 12px;
            color: #F53F3F;
        }
        .my-form-foot {
            display: flex;
            justify-content: space-between;
            align-items: center;
            padding: 5px 0 15px 0;
        }
    </style>
</head>
<body>
<ul class="nav nav-tabs">
<c:if test="${fnx:hasPrivilegeCode(role_privilege_codes, 'exam_mark-mark')}">
    <li><a href="${ctx}/admin/exam/mark?subjectCode=${subject.code}">评卷进度</a></li>
    </c:if>
    <c:if test="${fnx:hasPrivilegeCode(role_privilege_codes, 'exam_mark-group')}">
    <li><a href="${ctx}/admin/exam/group?subjectCode=${query.subjectCode}">分组管理</a></li>
    </c:if>
    <li class="active"><a href="##">评卷员管理</a></li>
    <c:if test="${fnx:hasPrivilegeCode(role_privilege_codes, 'exam_mark-trial')}">
    <li><a href="${ctx}/admin/exam/trial?subjectCode=${query.subjectCode}">试评管理</a></li>
    </c:if>
        <c:if test="${fnx:hasPrivilegeCode(role_privilege_codes, 'exam_mark-library')}">
    <li><a href="${ctx}/admin/exam/library?subjectCode=${query.subjectCode}">任务管理</a></li>
    </c:if>
        <c:if test="${fnx:hasPrivilegeCode(role_privilege_codes, 'exam_mark-arbitrate')}">
    <li><a href="${ctx}/admin/exam/arbitrate?subjectCode=${query.subjectCode}">仲裁管理</a></li>
    </c:if>
        <c:if test="${fnx:hasPrivilegeCode(role_privilege_codes, 'exam_mark-quality')}">
    <li><a href="${ctx}/admin/exam/quality?subjectCode=${query.subjectCode}">质量监控</a></li>
    </c:if>
</ul>
<div id="importBox" class="hide">
    <form id="importForm" action="${ctx}/admin/exam/marker/import" method="post" enctype="multipart/form-data"
          style="padding-left:20px;text-align:center;" class="form-search" onsubmit="loading('正在导入，请稍等...');"><br/>
        <input name="subjectCode" type="hidden" value="${query.subjectCode }"/>
        <input id="uploadFile" name="file" type="file" style="width:330px"/><br/><br/>　　
        <input id="btnImportSubmit" class="btn btn-primary" type="submit" value="   导    入   "/>
        <a href="${ctx}/admin/exam/marker/template">下载模板</a>
    </form>
</div>

<%--     <div id="importUpdateBox" class="hide">
        <form id="importUpdateForm" action="${ctx}/admin/exam/marker/importUpdate" method="post" enctype="multipart/form-data"
              style="padding-left:20px;text-align:center;" class="form-search" onsubmit="loading('正在导入，请稍等...');"><br/>
            <input id="uploadUpdateFile" name="file" type="file" style="width:330px"/><br/><br/>　　
            <input id="btnUpdateImportSubmit" class="btn btn-primary" type="submit" value="   导    入   "/>
            <a href="${ctx}/admin/exam/marker/updateLoginNameTemplate">下载模板</a>
        </form>
    </div> --%>

<form id="searchForm" action="${ctx}/admin/exam/marker" method="post" class="breadcrumb form-search">
    <input type="hidden" id="pageNumber" name="pageNumber" value="${query.pageNumber}"/>
    <input type="hidden" id="pageSize" name="pageSize" value="${query.pageSize}"/>
    <div>
        <label>科目</label>
        <select class="input-large" id="subject-select" name="subjectCode">
        	<option value="">请选择</option>
            <c:forEach items="${subjectList}" var="subject">
                <option value="${subject.code}"
                        <c:if test="${subject.code==query.subjectCode}">selected</c:if>>${subject.code}-${subject.name}</option>
            </c:forEach>
        </select>
        <label>分组</label>
        <select class="input-medium" id="group-select" name="groupNumber">
        </select>
        <label>登录名</label>
        <input type="text" name="loginName" value="${query.loginName}" maxlength="30" class="input-small"/>
        &nbsp;
        <label>姓名</label>
        <input type="text" name="name" value="${query.name}" maxlength="30" class="input-small"/>
        &nbsp;
        <input id="btnSubmit" class="btn btn-primary" type="button" value="查询" onclick="goSearch()"/>
		&nbsp;<input id="btnImport" class="btn" type="button" value="导入"/>
		&nbsp;<input class="btn" type="button" value="绑定评卷员" disabled id="save-button"/>
        <!--     <input id="btnExport" class="btn" type="button" value="导出"/> -->
        &nbsp;
		<input id="btnEnable" class="btn" type="button" value="启用" onclick="goEnable(true)"/>
		&nbsp;
		<input id="btnEnable" class="btn" type="button" value="禁用" onclick="goEnable(false)"/>
		&nbsp;
		<input id="btnRelease" class="btn" type="button" value="回收" onclick="goRelease()"/>
		&nbsp;
		<input id="btnTaskCount" class="btn" type="button" value="设置评卷数" onclick="goTaskCount()"/>
		 <c:if test="${web_user.schoolAdmin==true }">
		&nbsp;
		<input id="btnResetPassword" class="btn" type="button" value="重置密码" onclick="goResetPassword()"/>
		</c:if>
    </div>
</form>
<tags:message content="${message}"/>
<table id="contentTable" class="table table-striped table-bordered table-condensed">
    <thead>
    <tr>
        <th><input type="checkbox" id="ids">登录名</th>
        <th>姓名</th>
        <th>科目</th>
        <th>分组</th>
        <th>状态</th>
        <th>已评数量</th>
        <th>正在评卷</th>
        <th>任务数</th>
        <th>绑定机组</th>
        <th>操作</th>
    </tr>
    </thead>
    <tbody>
    <c:forEach items="${query.result}" var="marker">
        <tr>
            <td><input type="checkbox" class="ids" name="ids" value="${marker.id}">${marker.user.loginName}</td>
            <td>${marker.user.name}</td>
            <td>
                <c:if test="${marker.subject!=null}">
                    ${marker.subject.code}-${marker.subject.name}
                </c:if>
            </td>
            <td>
                <c:if test="${marker.group!=null}">
                    ${marker.group.number}-${marker.group.title}
                </c:if>
            </td>
            <td>${marker.enable eq true ? "启用" : "禁用"}</td>
            <td>${marker.markedCount}
            	<c:if test="${marker.reseting==true}">
                    正在重置
                </c:if>
                <c:if test="${fnx:hasPrivilegeCode(role_privilege_codes, 'exam_mark-marker-reset') && marker.reseting==false}">
                 &nbsp;<a href="javascript:void(0)" class="reset-button" data-code="${marker.subjectCode}" data-number="${marker.groupNumber}" data-progress="${marker.group.percent}" data-id="${marker.id}">重置</a>
                </c:if>
            </td>
            <td>${marker.currentCount}</td>
            <td>${marker.topCount}</td>
            <td><c:if test="${marker.classCount != 0}"><a href="${ctx}/admin/exam/marker/class/${marker.id}">${marker.classCount}</a></c:if>
            	<c:if test="${marker.classCount == 0}">0</c:if>
            </td>
            <td>
                <c:if test="${web_user.schoolAdmin==true && marker.reseting==false}">
                    <c:if test="${marker.enable==true}">
                        <a href="javascript:void(0)" class="toggle-button" data-id="${marker.id}" data-value="false">禁用</a>
                    </c:if>
                    <c:if test="${marker.enable==false}">
                        <a href="javascript:void(0)" class="toggle-button" data-id="${marker.id}" data-value="true">启用</a>
                    </c:if>
                </c:if>
                <c:if test="${(web_user.schoolAdmin==true||web_user.role=='SUBJECT_HEADER') && marker.reseting==false}">
                    <a href="${ctx}/admin/exam/marker/delete?markerId=${marker.id}">解绑</a>
                </c:if>
                <c:if test="${web_user.schoolAdmin==true && marker.reseting==false}">
                    <a href="javascript:void(0)" class="release-button" data-id="${marker.id}">回收</a>
                    <a href="javascript:void(0)" class="task-button" data-id="${marker.id}" onclick="showTaskWin('${marker.id}');">设置评卷数</a>
                    <a href="javascript:void(0)" class="reSetPassword-button" data-id="${marker.id}"
                       onclick="reSetPassword('${marker.id}');">重置密码</a>
                </c:if>
            </td>
        </tr>
    </c:forEach>
    </tbody>
</table>
<div class="taskWindow" style="display:none">
    <div class="task-header">
        <p class="title">设置任务数</p>
        <p class="image-close"><img src="${ctxStatic}/mark-new/images/images-close.png"/></p></div>
    <div class="task-content"><input type="text" class="task-count" placeholder="请输入任务数"/><i class="wrong"></i></div>
    <a href="#" class="btn btn-small btn-info task-btn">确定</a>
</div>

<div class="reSetPasswordWin" style="display:none">
    <div class="password-header">
        <p class="title">重置密码</p>
        <p class="image-close password-close"><img src="${ctxStatic}/mark-new/images/images-close.png"/></p></div>
    <div class="password-content"><input type="text" class="password-value" placeholder="请输入新的密码"/><i class="passwordWrong"></i></div>
    <a href="#" class="btn btn-small btn-info password-btn">确定</a>
</div>

<div id="delete-modal">
	<div id="deleteDiv" class="my-form form-horizontal">
        <div class="my-form-head">
            <div class="title-box">
                <img src="${ctxStatic}/images/dialog_warning_icon.png" class="warning-icon" />
                <span class="title2"></span>
            </div>
            <img src="${ctxStatic}/images/dialog_close_icon.png" class="close-icon" onclick="deleteDivHide()"/>
        </div>
        <div class="sub-title sub-title1">
            该操作分组将会<span>清掉已完成</span>的评卷任务，确认吗？
        </div>
        <div class="sub-title sub-title2">
            确认删除或重置，请联系大区经理获取授权码
        </div>
        <div class="my-form-body">
            <div class="gray-bg">
                <div class="my-form-item subjectCode">
                    <label>输入科目代码</label>
                    <div class="control-box">
                        <input type="text" id="subjectCode">
                        <div class="error-tip"></div>
                    </div>
                </div>
                <div class="my-form-item groupNumber">
                    <label>输入分组序号</label>
                    <div class="control-box">
                        <input type="text" id="groupNumber">
                        <div class="error-tip"></div>
                    </div>
                </div>
                <div class="my-form-item authCode">
                    <label>输入授权码</label>
                    <div class="control-box">
                        <input type="text" id="authCode">
                        <div class="error-tip"></div>
                    </div>
                </div>

            </div>
        </div>
        <div class="my-form-foot">
            <button class="btn btn-primary" onclick="dialogObj.validate()">确认</button>
            <button class="btn btn-default" onclick="deleteDivHide()">取消</button>
        </div>
    </div>
</div>

<div class="pagination">${query}</div>
<script type="text/javascript">
    var searchSubjectCode = '${query.subjectCode}';
    var searchGroupNumber = '${query.groupNumber}';
    var check_list;
    $(document).ready(function () {
        $('#cover').hide();
        var subjectCode = $('#subject-select').val();
	   	 if(subjectCode==''){
	   		 $('#save-button').attr("disabled",true);
	   	 }else{
	   		 $('#save-button').attr("disabled",false);
	   	 }
    });
    $("#btnImport").click(function () {
        $.jBox($("#importBox").html(), {
            title: "导入数据", buttons: {"关闭": true},
            bottomText: "导入文件不能超过5M，仅允许导入“xls”或“xlsx”格式文件！"
        });
    });
    /* $("#btnUpdateImport").click(function(){
    $.jBox($("#importUpdateBox").html(), {title:"导入数据", buttons:{"关闭":true},
    bottomText:"导入文件不能超过5M，仅允许导入“xls”或“xlsx”格式文件！"});
    }); */

    $("#btnExport").click(function () {
        top.$.jBox.confirm("确认要导出评卷员数据吗？", "系统提示", function (v, h, f) {
            if (v == "ok") {
                $("#searchForm").attr("action", "/admin/exam/marker/export");
                $("#searchForm").submit();
                $("#searchForm").attr("action", "${ctx}/admin/exam/marker");
            }
        }, {buttonsFocus: 1});
        top.$('.jbox-body .jbox-icon').css('top', '55px');
    });
    $('.reset-button').click(function () {
    	var deleteCheck = '${deleteCheck}';
    	var id = $(this).attr('data-id');
    	var subjectCode = $(this).attr('data-code');
    	var groupNumber = $(this).attr('data-number');
    	var progress = $(this).attr('data-progress');
    	if(deleteCheck=='false'){
    		deleteDivHide();
	        if (!confirm("确定要重置改评卷员吗？")) {
	            return;
	        }
	        $.post('${ctx}/admin/exam/marker/reset', {id: id}, function (result) {
	            if (result.success == true) {
	                alert('重置成功');
	                $("#searchForm").submit();
	            } else {
	                alert(result.message);
	            }
	        });
    		return;
    	}
    	dialogObj = createDialog();
        dialogObj.initDialog({ progress: progress, subjectCode: subjectCode, groupNumber: groupNumber }, function (initParams,deleteCode) { 
	        //这个回调方法里写进度小余10%的业务分支
	        deleteDivHide();
        	if(deleteCode!=null && deleteCode!=''){
        		$.post('${ctx}/admin/exam/marker/reset', {id: id,deleteCode:deleteCode}, function (result) {
    	            if (result.success == true) {
    	                alert('重置成功');
    	                $("#searchForm").submit();
    	            } else {
    	                alert(result.message);
    	            }
    	        });
        		return;
        	}else{
        		$.post('${ctx}/admin/exam/marker/reset', {id: id}, function (result) {
    	            if (result.success == true) {
    	                alert('重置成功');
    	                $("#searchForm").submit();
    	            } else {
    	                alert(result.message);
    	            }
    	        });
        		return;
        	}
    	})
    });
    $('.toggle-button').click(function () {
        var id = $(this).attr('data-id');
        var enable = $(this).attr('data-value');
        var check_list =[];
        check_list.push(id);
        $.ajax({
        	url:"${ctx}/admin/exam/marker/toggle",
        	data:{ids: check_list, enable: enable},
        	traditional:true,
        	type:"post",
        	success:function (result) {
                if (result.success == true) {
                    alert('修改成功');
                    $("#searchForm").submit();
                } else {
                    alert(result.message);
                }
        	}
        });
    });
    $('.release-button').click(function () {
        var id = $(this).attr('data-id');
        var check_list =[];
        check_list.push(id);
        $.ajax({
        	url:"${ctx}/admin/exam/marker/release",
        	data:{ids: check_list},
        	traditional:true,
        	type:"post",
        	success:function (result) {
                if (result.success == true) {
                    alert('回收成功');
                    $("#searchForm").submit();
                } else {
                    alert(result.message);
                }
        	}
        });
    });
    $('#subject-select').change(function () {
        var code = $(this).val();
        $('#group-select').empty();
        $('#group-select').append('<option value="">请选择</option>');
        if (code == '') {
            $('#group-select').val('0').trigger('change');
            return;
        }
        $.post('${ctx}/admin/exam/group/query', {subjectCode: code}, function (result) {
            var parent = $('#group-select');
            for (var i = 0; i < result.length; i++) {
                var group = result[i];
                var dom = $('<option value="' + group.number + '">' + group.number + '-' + group.title + '</option>').appendTo(parent);
                if (searchSubjectCode == code && searchGroupNumber == group.number) {
                    dom.attr('selected', 'selected');
                }
            }
            parent.trigger('change');
        });
    });
    $('#subject-select').trigger('change');

    function page(n, s) {
        $("#pageNumber").val(n);
        $("#pageSize").val(s);
        $("#searchForm").attr("action", "${ctx}/admin/exam/marker");
        $("#searchForm").submit();
        return false;
    }

    function goSearch() {
        $("#pageNumber").val(1);
        $("#pageSize").val('${query.pageSize}');
        $("#searchForm").attr("action", "${ctx}/admin/exam/marker");
        $("#searchForm").submit();
        return false;
    }

    function showTaskWin(obj) {
        $('.wrong').html('');
        $('.task-count').val('');
        $('.taskWindow').show();
        $('#cover').show();
        check_list =[];
        check_list.push(obj);
    }

    function reSetPassword(obj) {
        $('.passwordWrong').html('');
        $('.password-value').val('');
        $('.reSetPasswordWin').show();
        $('#cover').show();
        check_list =[];
        check_list.push(obj);
    }

    $('.image-close').click(function () {
        $('.taskWindow').hide();
        $('#cover').hide();
    });
    $('.password-close').click(function () {
        $('.reSetPasswordWin').hide();
        $('#cover').hide();
    });
    function goTaskCount() {
    	check_list = [];
    	$("input[name='ids']:checked").each(function(){
    		check_list.push($(this).val())
    	})
        if(check_list.length==0) {
            alert('请选择');
            return false;
        }
        $('.wrong').html('');
        $('.task-count').val('');
        $('.taskWindow').show();
        $('#cover').show();
        return false;
    }
    $('.task-btn').click(function () {
        var taskCount = $('.task-count').val();
        var wrongMessage = $('.wrong');
        taskCount = taskCount.replace(/(^\s*)|(\s*$)/g, "");
        if (taskCount.length == 0) {
            wrongMessage.html('任务数不能为空！');
            return false;
        } else {
            if (!/^\+?[1-9][0-9]*$/.test(taskCount)) {
                wrongMessage.html('请输入正整数!');
                return false;
            }
            if (taskCount > 2147483647) {
                wrongMessage.html('数量不合法!');
                return false;
            }
        }
        $.ajax({
        	url:"${ctx}/admin/exam/marker/setTaskCount",
        	data:{ids: check_list, taskCount: taskCount},
        	traditional:true,
        	type:"post",
        	success:function (result) {
                if (result.success == true) {
                    alert('设置成功');
                    $("#searchForm").submit();
                } else {
                    alert(result.message);
                }
	            $('.taskWindow').hide();
        	}
        });
    });
    function goResetPassword() {
    	check_list = [];
    	$("input[name='ids']:checked").each(function(){
    		check_list.push($(this).val())
    	})
        if(check_list.length==0) {
            alert('请选择');
            return false;
        }
    	$('.passwordWrong').html('');
        $('.password-value').val('');
        $('.reSetPasswordWin').show();
        $('#cover').show();
        return false;
    }
    $('.password-btn').click(function () {
        var password = $('.password-value').val();
        var wrongMessage = $('.passwordWrong');
        password = password.replace(/(^\s*)|(\s*$)/g, "");
        if (password.length == 0) {
            wrongMessage.html('密码不能为空！');
            return false;
        } else if (password.length > 12 || password.length < 6) {
            wrongMessage.html('密码至少6位，不能大于12位');
            return false;
        }
        $.ajax({
        	url:"${ctx}/admin/exam/marker/reSetPassword",
        	data:{ids: check_list, password: password},
        	traditional:true,
        	type:"post",
        	success:function (result) {
                if (result.success == true) {
                    alert('修改成功');
                    $("#searchForm").submit();
                } else {
                    alert(result.message);
                }
                $('.reSetPasswordWin').hide();
        	}
        });
    });
    $('#save-button').click(function () {
        var subjectCode = $('#subject-select').val();
        if (subjectCode == "") {
            alert('请选择科目');
            return false;
        }
        window.location.href ='${ctx}/admin/exam/marker/save?subjectCode=' + subjectCode;
        return true;
    });
    $('#subject-select').change(function () {
    	 var subjectCode = $('#subject-select').val();
    	 if(subjectCode==''){
    		 $('#save-button').attr("disabled",true);
    	 }else{
    		 $('#save-button').attr("disabled",false);
    	 }
    });
    $("#ids").change(function () {
        if ($("#ids").is(':checked')) {
            $(".ids").attr("checked", true);
        } else {
        	$(".ids").attr("checked", false);
        }
    });
    
    $(".ids").change(function () {
    	var all = true;
    	$("input[name='ids']").each(function(){
    		if(!$(this).is(':checked')){
    			all = false;
    		}
    	})
		 $("#ids").attr("checked", all);
    });
    function goEnable(enable) {
    	var check_list = []
    	$("input[name='ids']:checked").each(function(){
    		check_list.push($(this).val())
    	})
        if(check_list.length==0) {
            alert('请选择');
            return false;
        }
        $.ajax({
        	url:"${ctx}/admin/exam/marker/toggle",
        	data:{ids: check_list, enable: enable},
        	traditional:true,
        	type:"post",
        	success:function (result) {
                if (result.success == true) {
                    alert('修改成功');
                    $("#searchForm").submit();
                } else {
                    alert(result.message);
                }
        	}
        });
    }
    function goRelease() {
    	var check_list = []
    	$("input[name='ids']:checked").each(function(){
    		check_list.push($(this).val())
    	})
        if(check_list.length==0) {
            alert('请选择');
            return false;
        }
        $.ajax({
        	url:"${ctx}/admin/exam/marker/release",
        	data:{ids: check_list},
        	traditional:true,
        	type:"post",
        	success:function (result) {
                if (result.success == true) {
                    alert('回收成功');
                    $("#searchForm").submit();
                } else {
                    alert(result.message);
                }
        	}
        });
    }
</script>
<script>
function deleteDivHide(){
	 $('#delete-modal').hide();
}
var dialogObj=null;
function createDialog() {
	return {
        initParams: {},
        setDialogTitle: function (index) {
            if (index < 4) {
                $('#deleteDiv .title2').html('第' + index + '次警告');
                $('.sub-title1,.subjectCode,.groupNumber').show();
                $('.sub-title2,.authCode').hide();

            } else {
                $('#deleteDiv .title').html('分组授权码');
                $('.sub-title1,.subjectCode,.groupNumber').hide();
                $('.sub-title2,.authCode').show();
            }
        },
        validate: function () {
            if (this.warningIndex <= 3) {
                var subjectCodeVal = $('.subjectCode input').val();
                var groupNumberVal = $('.groupNumber input').val();
                $('.subjectCode input+.error-tip').html(!subjectCodeVal?'请输入科目代码':subjectCodeVal != this.initParams.subjectCode?'输入的科目代码不正确':'')
                $('.groupNumber input+.error-tip').html(!groupNumberVal?'请输入分组序号':groupNumberVal != this.initParams.groupNumber?'输入的分组序号不正确':'')

                if (!subjectCodeVal || !groupNumberVal || subjectCodeVal != this.initParams.subjectCode || groupNumberVal != this.initParams.groupNumber) {
                    return;
                } else {
                    this.next();
                }
            } else if (this.warningIndex == 4) {
                var authCodeVal = $('.authCode input').val();
                if(!authCodeVal){
                    $('.authCode input+.error-tip').html('请输入授权码');
                    return;
                }else{
                    $('.authCode input+.error-tip').html('');
                    this.next();
                }
            }

        },
        next() {
            if (this.warningIndex == 4) {
                this.callback(this.initParams,$('.authCode input').val());
            } else if (this.times <= 3 && this.times == this.warningIndex) {
                this.callback(this.initParams);
            } else {
                $('.subjectCode input+.error-tip').html('');
                $('.subjectCode input,.groupNumber input').val('')
                $('.groupNumber input+.error-tip').html('');
                this.warningIndex++;
                $('#deleteDiv').removeClass('animate__animated animate__fadeIn')
                setTimeout(function(){
                    $('#deleteDiv').addClass('animate__animated animate__fadeIn')
                },0)
                this.setDialogTitle(this.warningIndex);
            }
        },
        warningIndex: 1,//当前正在进行的第几次输入
        times: 0,//需要重复输入的次数
        callback:null,
        initDialog: function (initParams, callBack) {
            this.initParams = initParams;
            var progress = initParams.progress;
            if(callBack){
                this.callback = callBack;
                if (progress <= 10) {
                    callBack(initParams);
                    return;
                }
            }
            this.times = progress <= 80 ? 2 : progress >= 80 && progress < 100 ? 3 : 4;
            this.warningIndex = 1;
            $('#delete-modal').show();
            this.setDialogTitle(this.warningIndex);
        },
        submit: function (index) {
            console.log('你最开始传入的基础参数initParams为：',this.initParams);
            if(this.warningIndex==4){
                console.log('你输入的授权码为：'+$('.authCode input').val())
            }
        }
    }
   
}
</script>
</body>
</html>
