
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="C" uri="http://java.sun.com/jsp/jstl/core" %>
<%@page language="java" contentType="text/html; charset=utf-8"
        pageEncoding="utf-8" %>
<%@ include file="header.jsp" %>

<link rel="stylesheet" type="text/css" href="<%=webpath%>/css/printOut.css"/>
<link rel="stylesheet" type="text/css" href="<%=path%>/css/addDialog.css"/>
<script type="text/javascript" src="<%=webpath%>/js/business/enterprise.js"></script>
<script type="text/javascript" src="<%=webpath%>/js/business/user.js"></script>
<script type="text/javascript" src="<%=webpath%>/js/DatePicker/WdatePicker.js"></script>
<script type="text/javascript" src="<%=webpath%>/js/jquery.jqprint-0.3.js"></script>
<script src="http://www.jq22.com/jquery/jquery-migrate-1.2.1.min.js"></script>
<!--media=print 这个属性说明可以在打印时有效-->
<!--希望打印时不显示的内容设置class="Noprint"样式-->
<!--希望人为设置分页的位置设置class="PageNext"样式-->
<style>
    table.searchTable td:nth-last-child(1) {
        width: auto;
    }

    table.searchTable td {
        width: auto;
    }
    .search{
        margin:15px 55px 10px 18px;
    }
</style>
<style media="print">
    .Noprint {
        display: none;
    }

    .PageNext {
        page-break-after: always;
    }
    table.searchTable td:nth-last-child(1){
        width:40%;
    }
</style>
<script type="text/javascript">
    function clearFormVal() {
        $("#userform").form("clear");
        $("#roles").attr('value','');
        $("#enterprise").attr('value','');
    }
    function querys() {
        var queryParams = {};
        var frame_code = $("#frame_code").val();
        var caseCode = $("#caseCode").val();
        var role = $("#rescueState").val();
        var username = $("#username").val();
        var state = parseInt(${state});
        queryParams['state'] = state;
        queryParams['phone'] = frame_code;
        queryParams['name'] = caseCode;
        queryParams['role'] = role;
        queryParams['username'] = username;
        queryCouponList("<%=path%>/user/getUserInfo.do", queryParams,
            "<%=path%>/casesInfo/caseDetailList.do?state=" + state + "&code=", state);;

    }
    function query() {
        var queryParams = {};
        var frame_code = $("#frame_code").val();
        var caseCode = $("#caseCode").val();
        var role = $("#rescueState").val();
        var username = $("#username").val();
        if((username == null || username == '') && (frame_code == null || frame_code == '') && (caseCode == null || caseCode == '') &&  role == ''){
            alert("查询条件不能为空");
            return;
        }
        var state = parseInt(${state});
        queryParams['state'] = state;
        queryParams['phone'] = frame_code;
        queryParams['name'] = caseCode;
        queryParams['role'] = role;
        queryParams['username'] = username;
        queryCouponList("<%=path%>/user/getUserInfo.do", queryParams,
            "<%=path%>/casesInfo/caseDetailList.do?state=" + state + "&code=", state);;

    }
    function clearVal() {
        $("#frame_code").val("");
        $("#license").val("");
        $("#caseCode").val("");
        $("#createTime").val("");
        $("#finishTime").val("");
    }

    function clearValState1() {
        $("#username").val("");
        $("#frame_code").val("");
        $("#caseCode").val("");
        $("#rescueState").val("");
    }

    $(window).ready(function () {
        //$(".order_print").hide();
       // alert('wangxu');
        var frame_code = $("#frame_code").val();
        var caseCode = $("#caseCode").val();
        var createTime = $("#createTime").val();
        var finishTime = $("#finishTime").val();
        var companyName = $("#companyName").val();
        var username = $("#username").val();
        var role = $("#rescueState").val();
        var queryParams = {};
        queryParams['phone'] = frame_code;
        queryParams['name'] = caseCode;
        queryParams['role'] = role;
        queryParams['username'] = username;
        var state = parseInt(${state});
        queryCouponList("<%=path%>/user/getUserInfo.do", queryParams,
                "<%=path%>/casesInfo/caseDetailList.do?state=" + state + "&code=", state);

    })
    function openNew() {
        $(".order_undo").show();
        clearFormVal();
        $("#newPassword").val('1111');
        $("#confirmPassword").val('1111');
        $("#start").html('初始密码1111');
    }
    function submit() {
        var newPassword = $("#newPassword").val();
        var confirmPassword = $("#confirmPassword").val();
        if (newPassword != confirmPassword) {
            alert("密码和确认密码不匹配");
            return;
        }
            var name = $("#name").val();
            var username = $("#usernames").val();
            var phone = $("#phone").val();
            var roles = $("#roles").val();
            var enterprise = $("#enterprise").val();
            var reg = /^[1][3,4,5,7,8][0-9]{9}$/;
            if (name == null || name == '') {
                alert('请输入姓名');
                return;
            }
            if (username == null || username == '') {
                alert('请输入用户名');
                return;
            }
            if (phone == null || phone == '' || !reg.test(phone)) {
                alert('手机号格式错误');
                return;
            }
            if (roles == '') {
            alert('请选择角色');
            return;
            }
           if (enterprise == '') {
            alert('请指定供应商');
            return;
            }
            if (newPassword == null || newPassword == '') {
                alert('请输入密码');
                return;
            }
        $.ajax({
            cache: true,
            type: "POST",
            url:"/user/insertUser.do",
            data: $('#userform').serialize(),// 你的formid
            async: false,
            error: function (request) {
                alert("Connection error");
            },
            success: function (data) {
                var data = eval("(" + data + ")");
                if (data.flag == 1) {
                    $("#addedit_dialog").hide();
                    querys();
                } else {
                    alert(data.msg);
                }
            }
        });
        /* }else{
         alert("提交数据不能为空");
         } */

    }
    function loginEmailBlurs(strEmail) {
        var loginEmail = $.trim($("input[name='email']").val());
        if (loginEmail == null || loginEmail == "") {
            alert("您的邮箱账号忘记输入了");
        }
        else {
            if (strEmail.search(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/) != -1) {
                return true;
            }
            else {
                alert("请输入正确的邮箱格式");
            }
        }
    }
</script>
<input type="hidden" id="paths" value="<%=path%>"/>
<!--希望打印时不显示的内容设置class="Noprint"样式-->
<!--IE内置打印控件IEWebBrowser-->
<OBJECT id="wb" height="0" width="0" classid="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2" name="wb"></OBJECT>
<div id="main" class="Noprint">
    <div class="search">
            <table class="searchTable">
                <tbody>
                <tr>
                    <td style="position:relative;">
                        <span class="inputTitle"> 姓名:</span>
                        <span id="input34Wrap">
                    <input id="caseCode" name="endSubmitDate"
                           type="text" value=""
                           class="mc-ipt-text hasDatepicker"
                           style=""/><span class="mc-ipt"
                                           style="width:90%;"><span
                                id="input33Tip" class="mc-ipt-tip-query"
                                style="font-size: 11px; line-height: 40px; height: 40px;"></span></span></span></td>
                    <td style="position:relative;">
                        <span class="inputTitle"> 登录名:</span>
                        <span id="input34Wrap">
                    <input id="username" name="endSubmitDate"
                           type="text" value=""
                           class="mc-ipt-text hasDatepicker"
                           style=""/><span class="mc-ipt"
                                           style="width:90%;"><span
                                id="input33Tip" class="mc-ipt-tip-query"
                                style="font-size: 11px; line-height: 40px; height: 40px;"></span></span></span></td>
                    <!-- <td><b><font><font>VIN码</font></font></b></td> -->
                    <td style="position:relative;">
                        <span class="inputTitle"> 手机号: </span>
                        <span id="input34Wrap">
                    <input id="frame_code" name="endSubmitDate"
                           type="text" value=""
                           class="mc-ipt-text hasDatepicker"
                           style=""/><span class="mc-ipt"
                                           style="width:90%;"><span
                                id="input33Tip" class="mc-ipt-tip-query"
                                style="font-size: 11px; line-height: 40px; height: 40px;"></span></span></span></td>
                    <td style="position:relative;">
                        <span class="inputTitle"> 角色: </span>
                        <span id="input34Wrap">
                     <select id="rescueState" style="width:183px"
                             class="selector" tabindex="-1" aria-hidden="true">
                                    <option value="" selected="selected" >---请选择---</option>
                                     <c:forEach items="${roles}" var="r">
                                         <option value="${r.id}">${r.name}</option>
                                     </c:forEach>
                            </select><span style="width:90%;"><span
                                id="input33Tip" class="mc-ipt-tip-query"
                                style="font-size: 11px; line-height: 40px; height: 40px;"></span></span></span></td>

                    <!-- <td><b><font><font>车牌号</font></font></b></td> -->
                    <td>
                        <button class="t-button searchBtn" id="CaseInfoList2btnCtClear" type="button"
                                onclick="clearValState1();"><img class="searchIcon" src="../images/clear.png">清空
                        </button>
                        <button class="t-button searchBtn" style="margin-right:10px;" id="CaseInfoList2btnCtSearch"
                                type="button" onclick="query();"><img class="searchIcon" src="../images/search.png">搜索
                        </button>
                        <button class="t-button searchBtn2" style="margin-right:10px;"
                                type="button" onclick="openNew();">
                            <img style="width:12px;" class="searchIcon"
                                 src="../images/add.png">新增
                        </button>
                        <!--
                        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                            <button class="t-button" id="CaseInfoList2btnCtSearch" type="button" onclick="query();">
                                <font><font>
                                    &nbsp;&nbsp;搜 索&nbsp;&nbsp;</font></font></button> -->
                    </td>

                </tr>
                </tbody>
            </table>
    </div>
    <table id="datatable"></table>
</div>
<div class="order_undo" id="addedit_dialog" style="display: none;">
    <form action="" id="userform" method="post">
        <input type="hidden" value="" id="enterpriseid" name="id">
        <div class="dialog_default" style="width:1300px;" id="dialogNb">
            <div class="dialog_title" style="margin:auto;width: 40%">新增/编辑</div>
            <div class="dialog_con" style="margin-left:390px;width:40%">
                <div class="dialog_left" style="padding: 15px 40px;">
                    <table>
                        <tbody>
                        <tr>
                            <td colspan="3"></td>
                        </tr>
                        <tr>
                            <td colspan="3">
                                <span class="concat">姓名</span>
                                <div class="contactWrap"><input autocomplete="off" id="name" class="contactInput" name="name"
                                                                type="text" value=""/></div>
                            </td>

                        </tr>
                        <tr>
                            <td colspan="3">
                                <span class="concat">用户名</span>
                                <div class="contactWrap"><input id="usernames"class="contactInput" name="login_name"
                                                                type="text" value=""/></div>
                            </td>
                        </tr>
                        <tr>
                            <td colspan="3">
                                <span class="concat">手机号</span>
                                <div class="contactWrap"><input id="phone" class="contactInput" name="phone"
                                                                type="text" value=""/></div>
                            </td>

                        </tr>
                        <tr>
                            <td colspan="3"><span class="concat">邮箱</span>
                                <div class="contactWrap">
                                <input id="email" name="email" onblur="loginEmailBlurs(this.value)" type="text" value=""/>
                                </div>
                            </td>
                        </tr>
                        <tr>
                            <td style="position:relative;" colspan="3">
                                <span class="inputTitle"> 指定角色 </span>
                                <span id="input34Wrap">
                     <select id="roles" style="width:183px"
                             class="selector" tabindex="-1" aria-hidden="true" name="role">
                                    <option value="" selected="selected" >---请选择---</option>
                                     <c:forEach items="${roles}" var="r">
                                         <option value="${r.id}">${r.name}</option>
                                     </c:forEach>
                            </select><span style="width:90%;"><span
                                        id="input33Tip" class="mc-ipt-tip-query"
                                        style="font-size: 11px; line-height: 40px; height: 40px;"></span></span></span></td>

                            <!-- <td><b><font><font>车牌号</font></font></b></td> -->
                            <td>
                        </tr>
                        <tr>
                            <td style="position:relative;" colspan="3">
                                <span class="inputTitle"> 指定经销商 </span>
                                <span id="input34Wrap">
                     <select id="enterprise" style="width:183px"
                             class="selector" tabindex="-1" aria-hidden="true" name="enterprise">
                                    <option value="" selected="selected">---请选择---</option>
                                     <c:forEach items="${enterprise}" var="r">
                                         <option value="${r.id}">${r.name}</option>
                                     </c:forEach>
                            </select><span style="width:90%;"><span
                                        id="input33Tip" class="mc-ipt-tip-query"
                                        style="font-size: 11px; line-height: 40px; height: 40px;"></span></span></span></td>

                            <!-- <td><b><font><font>车牌号</font></font></b></td> -->
                            <td>
                        </tr>
                        <tr>
                            <td colspan="2">
                                <span class="concat">密码</span>
                                <div class="contactWrap">
                                <input id="newPassword"  name="newPassword" type="password" placeholder="密码"
                                       value=""/></div></td>
                            <td>
                                <div id="start" style="color:red;margin-left:100px;font-size:12px;width:100px"></div>
                            </td>
                        </tr>
                        <tr>
                            <td colspan="3">
                                <span class="concat">确认密码</span>
                                <div class="contactWrap">
                                <input id="confirmPassword"  name="confirmPassword" type="password" placeholder="确认密码"
                                       value=""/>
                                </div>
                            </td>
                        </tr>
                        </tbody>
                    </table>
                    <div class="confirm_cancel clearfix" style="padding-top:10px;width:400px;margin-bottom: 30px">
                        <a href="javascript:void(0);" class="btn2"
                           style="margin-right:20px;margin-left:40px" onclick="submit();">提&nbsp;&nbsp;交</a>
                        <a href="javascript:void(0);" class="btn1 cancel" onclick="cancel()">取&nbsp;&nbsp;消</a>
                    </div>

                </div>
            </div>
        </div>
    </form>

</div>
<%@ include file="footer.jsp" %>