<%@ 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" %>
    <script type="text/javascript">
        $(document).ready(function () {
            $("#loginName").focus();
            $("#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);
                    }
                }
            });
            $("#random-check").change(function () {
                if ($("#random-check").is(':checked')) {
                    $("#password").prop("disabled", "disabled");
                } else {
                	$("#random-check").prop("checked", false);
                    $("#password").prop("disabled", "");
                }
            });
            $('#role-select').change(function () {
                var role = $('#role-select').val();
                if (role == '4') {
                    $('#subject-div').show();
                } else {
                    $('#subject-div').hide();
                }
                if (role == '5') {
                    $('#marker-div').show();
                } else {
                    $('#marker-div').hide();
                }
                if (role == '8') {
                    $('#inspector-div').show();
                } else {
                    $('#inspector-div').hide();
                }
            });
            $('#role-select').trigger('change');
            window.localStorage.removeItem("subjectCodeString");
        });
    </script>
</head>
<body>
<ul class="nav nav-tabs">
    <li><a href="${ctx}/admin/user/list">用户列表</a></li>
    <li class="active"><a href="##">用户新增</a></li>
</ul>
<form:form id="inputForm" action="${ctx}/admin/user/batchSave" method="post" class="form-horizontal">
    <tags:message content="${message}"/>
    <div class="control-group">
        <label class="control-label">考试名称</label>
        <div class="controls">
            ${exam.id }-${exam.name }
        </div>
    </div>
    <div class="control-group">
        <label class="control-label">角色</label>
        <div class="controls">
            <select name="role" id="role-select">
                <c:if test="${roleList != null}">
                    <c:forEach items="${roleList}" var="role">
                        <option value="${role.value}" >${role.name}</option>
                    </c:forEach>
                </c:if>
            </select>
        </div>
    </div>
	<div class="control-group">
            <label class="control-label">命名规则</label>
            <div class="controls"  id="subject-div">机构ID+科目代码+流水号</div>
            <div class="controls"  id="marker-div">机构ID+科目代码+分组号+流水号</div>
            <div class="controls"  id="inspector-div">机构ID+FH+科目代码+流水号</div>
	</div>
    <div class="control-group">
        <label class="control-label">每分组账号数</label>
        <div class="controls">
            <input name="number" type="number" htmlEscape="false" max="100" min="1" class="required digits"/>
        </div>
    </div>
	<div class="control-group">
        <label class="control-label">随机密码</label>
        <div class="controls">
            <input name="random" type="checkbox" id="random-check"/>
        </div>
    </div>
    <div class="control-group">
        <label class="control-label">密码</label>
        <div class="controls">
            <input name="password" type="text" class="required" id="password"/>
        </div>
    </div>
	<div class="control-group" id="subject-code-div">
		<label class="control-label">选择科目</label>
		<div class="controls">
          <input name="subjectCodeString" id="subjectCodeString" type="hidden"/>
                    <a href="${ctx}/admin/user/getSubjectCode" target="_blank" class="required"
                       id="configuration" rel="opener">设置</a>
        </div>
	 </div>
    <div class="form-actions">
        <input id="btnSubmit" class="btn btn-primary" type="submit" value="保 存"/>
        &nbsp;
        <a href="javascript:" onclick="history.go(-1);"  class="btn">返回</a>
    </div>
</form:form>
</body>
</html>
