<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<style>
    .col-sm-2{
        width:14%;
    }
    .col-sm-3{
        width:19%;
    }
    .btn-red{ background-color:red;border: red}
    .btn-green{ background-color:green;border: green}
</style>
<div class="">
    <form class="form form-horizontal" id="form-admin-add">
        <input type="hidden" value="add" name="action" id="action">
        <div id="content" class="cl pd-5  bk-gray divOverflow" style="overflow:hidden;margin-bottom: 20px;">
            <div class="row cl">
                <label class="form-label col-xs-4 col-sm-2">
                    <span class="c-red">*</span>开始时间&nbsp;：
                </label>
                <div class="formControls col-xs-8 col-sm-10">
                    <input type="text" autocomplete="off" class="input-text Wdate" onclick="WdatePicker({dateFmt:'yyyy-MM-dd'})" name="b_time" id="b_time" value="" >
                </div>
            </div>
            <div class="row cl" >
                <label class="form-label col-xs-4 col-sm-2">
                    <span class="c-red">*</span>结束时间&nbsp;：
                </label>
                <div class="formControls col-xs-8 col-sm-10">
                    <input type="text" autocomplete="off" class="input-text Wdate" onclick="WdatePicker({dateFmt:'yyyy-MM-dd'})" name="e_time" id="e_time" value="" >
                </div>
            </div>

            <div class="row cl" >
                <label class="form-label col-xs-4 col-sm-2">
                    <span class="c-red">*</span>选择模型&nbsp;：
                </label>
                <div class="formControls col-xs-8 col-sm-10" id="mx_id">
                    <script>
                        $.post("./zd_view_list.jsp?name_id=mx_id&math="+Math.random(),function(data){
                                document.getElementById("mx_id").innerHTML=data;
                            }
                        );
                    </script>
                </div>
            </div>
        </div>
    </form>
</div>
<div class="cl mb-10  bk-gray " 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;">
        <input class="btn btn-primary radius btn-red" type="button" onclick="javascript:deleteForm();" value="&nbsp;&nbsp;重置排班&nbsp;&nbsp;">
    </div>
</div>
<script>
    function saveForm() {
        if($("#b_time").val()==''||$("#e_time").val()==''){
            layer.alert("时间不能为空",{icon:5,title:"提示"});
            return false;
        }
        if($("#mx_id option:selected").val()==''){
            layer.alert("请选择模型",{icon:5,title:"提示"});
            return false;
        }
        $.ajax({
            type: "POST",
            url: "./action.jsp",
            data: $('#form-admin-add').serialize(),
            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 deleteForm(){
        if($("#b_time").val()==''||$("#e_time").val()==''){
            layer.alert("时间不能为空",{icon:5,title:"提示"});
            return false;
        }
        layer.confirm('确认要重置吗？', function (index) {
			$.ajax({
				type: "POST",
				url: "./action.jsp?b_time="+$("#b_time").val()+"&e_time="+$("#e_time").val()+"&action=delete",
				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")
						});
					}
				}
			});
		});
    }
</script>