<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<style>
    .col-sm-2{
        width:100px;
    }
    .btn-green{ background-color:green;border: green}
</style>
<div class="">
    <form class="form form-horizontal" method="post" id="form1" name="form1" action="exportWeek.jsp" >
        <div style="height:450px;overflow: hidden;text-align: center">
            <div style="width:45%;height:90%;float:left;border: solid 1px #eee;margin-left: 40px">
                <div class="row cl">
                    <label class="form-label col-xs-2 col-sm-2" style="width:100px;">
                        日期&nbsp;：
                    </label>
                    <div class="formControls col-xs-8 col-sm-5">
                        <input type="text" class="input-text Wdate" autocomplete="off"  onclick="WdatePicker({dateFmt:'yyyy-MM-dd',onpicked:refrashTask})" name="b_time" id="b_time" value="" >
                    </div>
                </div>
                <div id="leftUserList" >

                </div>
            </div>
            <div style="width:45%;height:90%;float:left;border: solid 1px #eee;margin-left: 20px">
                <div class="row cl">
                    <label class="form-label col-xs-2 col-sm-2" style="width:100px;">
                        日期&nbsp;：
                    </label>
                    <div class="formControls col-xs-8 col-sm-5">
                        <input type="text" class="input-text Wdate" autocomplete="off" onclick="WdatePicker({dateFmt:'yyyy-MM-dd',onpicked:refrashTask2})" name="e_time" id="e_time" value="" >
                    </div>
                </div>
                <div id="rightUserList" >

                </div>
            </div>
            <div class="cl mb-10  " style="height: 50px;">
                <div class="col-sm-3 pd-10" style="width:100%;text-align: center;">
                    <input class="btn btn-primary radius btn-green" type="button" onclick="javascript:saveForm();" value="&nbsp;&nbsp;换班&nbsp;&nbsp;">
                </div>
            </div>
        </div>
    </form>
</div>
<script>
    function saveForm() {
        var date_left=$("#b_time").val();
        var date_right=$("#e_time").val();
        var user_left=$("input[name='leftUserList_1']:checked").val();
        var zb_type_left=user_left.substring(user_left.indexOf("_")+1,user_left.length);
        user_left=user_left.substring(0,user_left.indexOf("_"));
        var user_right=$("input[name='rightUserList_1']:checked").val();
        var zb_type_right=user_right.substring(user_right.indexOf("_")+1,user_right.length);
        user_right=user_right.substring(0,user_right.indexOf("_"));
        $.ajax({
            type: "post",
            url: "action.jsp?action=changeUser&date_left="+date_left+"&date_right="+date_right
                +"&user_left="+user_left+"&user_right="+user_right+"&zb_type_left="+zb_type_left+"&zb_type_right="+zb_type_right,
            success: function (msg) {
                if (msg.indexOf("success") >= 0) {
                    layer.msg('操作成功!', {icon: 1, time: 1000},
                        function () {
                            window.parent.location.reload();
                            var index = parent.layer.getFrameIndex(window.name);
                            parent.layer.close(index);
                        });
                } else {
                    layer.msg('操作失败', {
                        icon: 5,
                        time: 2000 //2秒关闭（如果不配置，默认是3秒）
                    }, function () {
                        // console.log("********************8")
                    });
                }
            }
        });
    }
    function refrashTask() {
        var value=$("#b_time").val();
        $.ajax({
            type: "post",
            url: "getUserBydate-t.jsp?year="+value+"&divId=leftUserList",
            success: function (msg) {
                $("#leftUserList").html(msg);
            }
        });
    }
    function refrashTask2() {
        var value=$("#e_time").val();
        $.ajax({
            type: "post",
            url: "getUserBydate-t.jsp?year="+value+"&divId=rightUserList",
            success: function (msg) {
                $("#rightUserList").html(msg);
            }
        });
    }
</script>
