<!DOCTYPE html>
<!--[if IE 8]>
<html lang="en" class="ie8 no-js"> <![endif]-->
<!--[if IE 9]>
<html lang="en" class="ie9 no-js"> <![endif]-->
<!--[if !IE]><!-->
<html>
<!--<![endif]-->
<!-- BEGIN HEAD -->
<head>
    <base href="#springUrl('/assets/adminlte/')"/>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>工作台</title>
    <!-- Tell the browser to be responsive to screen width -->
    <meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
    <!-- Bootstrap 3.3.5 -->
    <link rel="stylesheet" href="bootstrap/css/bootstrap.min.css">
    <!-- Font Awesome -->
    <link rel="stylesheet" href="plugins/font-awesome/css/font-awesome.min.css">
    <!-- Ionicons -->
    <link rel="stylesheet" href="plugins/ionicons/css/ionicons.min.css">

    <!-- DataTables -->
    <link rel="stylesheet" href="plugins/datatables/dataTables.bootstrap.css">

    <!-- Theme style -->
    <link rel="stylesheet" href="dist/css/AdminLTE.min.css">
    <!-- AdminLTE Skins. Choose a skin from the css/skins
         folder instead of downloading all of them to reduce the load. -->
    <link rel="stylesheet" href="dist/css/skins/_all-skins.min.css">
    <!-- iCheck -->
    <link rel="stylesheet" href="plugins/iCheck/flat/blue.css">
    <!-- Date Picker -->

    <!-- Daterange picker -->

    <!-- bootstrap wysihtml5 - text editor -->
    <link rel="stylesheet" href="plugins/bootstrap-wysihtml5/bootstrap3-wysihtml5.min.css">
    <!--validate css-->
    <link rel="stylesheet" href="plugins/jquery-validation/css/validate.css">
    <link rel="stylesheet" type="text/css" media="all" href="plugins/daterangepicker-master/daterangepicker.css" />
    <!--fileinput css-->
    <link rel="stylesheet" href="plugins/bootstrap-fileinput/bootstrap-fileinput.css">
    <link rel="stylesheet" href="css/product.css">
    <!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
    <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
    <!--[if lt IE 9]>
    <script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
    <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
    <![endif]-->
</head>
<style>
    #prizes th {
        border: 1px #ccc solid;
        background: #FFFAF0;
    }

    #prizes td {
        border: 1px #ccc solid;
    }
    .previewImg {
        max-width: 100%;
        max-height: 100%;
        border: 0px;
        display: none;
        z-index: 999;
    }
</style>
<!-- END HEAD -->
<body class="hold-transition skin-blue sidebar-mini">

<div class="wrapper">
    <div class="content-wrapper" style="margin-left:0;">

        <section class="content-header">
            <h1>
                需求变更管理
                <small>需求变更</small>
            </h1>
            <ol class="breadcrumb">
                <li><a href="#"><i class="fa fa-dashboard"></i>首页</a></li>
                <li><a class="active"></a></li>
            </ol>

        </section>
        <!-- Main content -->

        <div class="row">
            <div class="col-xs-12">
                <!-- general form elements disabled -->
                <div class="box box-primary">
                    <form role="form" id="myForm">
                        <div class="box-body">
                            <div class="form-group form-md-line-input">
                                #if($service.isHotel=='0')
                                <input type="checkbox" name="hotel" value="hotel">酒店管理
                                #end
                                #if($service.isEat=='0')
                                <input type="checkbox" name="eat" value="eat">餐饮管理
                                #end
                                #if($service.isRelay=='0')
                                <input type="checkbox" name="relay" value="hotel">接送管理
                                #end
                                #if($service.isTake=='0')
                                <input type="checkbox" name="take" value="take">试乘试驾
                                #end
                                #if($service.isfactory=='0')
                                <input type="checkbox" name="factory" value="factory">工厂参观
                                #end
                            </div>

                            <section class="panel panel-default" id="panel">
                                <header class="panel-heading suk_heading">
                                    <ul class="nav nav-pills pull-right">
                                        <li><a href="#" class="panel-toggle text-muted"><i
                                                class="fa fa-caret-down text-active"></i><i
                                                class="fa fa-caret-up text"></i></a></li>
                                    </ul>
                                    酒店服务
                                </header>
                                <section class="chat-list panel-body suk_body">
                                    <div id="hotel" style="display: none"
                                         class="form-group form-md-line-input col-md-12">
                                        <select class="form-control" name="title" value="" id="">
                                            #if($service.isHotel=='0')
                                            #foreach( $h in $hotel )
                                            <option value="${h.title}"
                                                    #if($detailsObject.title== $h.title)
                                                    selected
                                                    #end
                                            >${h.title}
                                            </option>
                                            #end
                                            #end
                                        </select>
                                    </div>
                                    <div id="hotelintime" style="display: none"
                                         class="form-group form-md-line-input col-md-12 hoteltime">
                                        <label>入住时间</label>
                                        #foreach( $h in $hotel )
                                        <input type="text" style="display:none;"
                                               class="form-control  hotelDatePicker start"
                                               data-title="$!{h.title}"
                                               #if($detailsObject.title== $h.title)
                                               value="$!{detailsObject.startDate}"
                                               #end
                                               data-start="$!{h.startDate}" data-end="$!{h.endDate}" required
                                               name="startTimeStr" placeholder="入住时间"
                                               readonly="readonly">
                                        #end
                                    </div>
                                    <div id="hotelouttime" style="display: none"
                                         class="form-group form-md-line-input col-md-12 hoteltime end">
                                        <label>离开时间</label>
                                        #foreach( $h in $hotel )
                                        <input type="text" style="display:none;"
                                               class="form-control hotelDatePicker"
                                               data-title="$!{h.title}"
                                               data-start="$!{h.startDate}"
                                               #if($detailsObject.title== $h.title)
                                               value="$!{detailsObject.endDate}"
                                               #end
                                               data-end="$!{h.endDate}" required
                                               name="endTimeStr" placeholder="离开时间"
                                               readonly="readonly">
                                        #end
                                    </div>
                                </section>
                            </section>


                            <section class="panel panel-default" id="pane2">
                                <header class="panel-heading suk_heading">
                                    <ul class="nav nav-pills pull-right">
                                        <li><a href="#" class="panel-toggle text-muted"><i
                                                class="fa fa-caret-down text-active"></i><i
                                                class="fa fa-caret-up text"></i></a></li>
                                    </ul>
                                    餐饮服务
                                </header>
                                <section class="chat-list panel-body suk_body">
                                    <div id="eat" style="display: none" class="form-group form-md-line-input col-md-12">
                                        #if($service.isEat=='0')
                                        #foreach($e in $eat)
                                        <input type="checkbox" name="eatname" value="${e.eatname}">${e.eatname}<br/>
                                        #end
                                        #end
                                    </div>
                                </section>
                            </section>


                            <section class="panel panel-default" id="pane3">
                                <header class="panel-heading suk_heading">
                                    <ul class="nav nav-pills pull-right">
                                        <li><a href="#" class="panel-toggle text-muted"><i
                                                class="fa fa-caret-down text-active"></i><i
                                                class="fa fa-caret-up text"></i></a></li>
                                    </ul>
                                    接站服务
                                </header>
                                <section class="chat-list panel-body suk_body">
                                    <div id="way" style="display: none" class="form-group form-md-line-input col-md-12">
                                        #if($service.isRelay=='0')
                                        #if($relay.isHigh=='0')
                                        <input type="radio" name="relay1" id="highbus" value="highbus">高铁
                                        #end
                                        #if($relay.isPlane=='0')
                                        <input type="radio" name="relay1" id="plane" value="plane">飞机
                                        #end
                                        #if($relay.isOnedrive=='0')
                                        <input type="radio" name="relay1" id="onedrive" value="onedrive">自驾
                                        #end
                                        #if($relay.isOther=='0')
                                        <input type="radio" name="relay1" id="other" value="other">其他
                                        #end
                                        #end
                                    </div>
                                    <div id="highbusShow" style="display: none"
                                         class="form-group form-md-line-input col-md-12 relayShow">
                                        <label>高铁站点</label><br/>
                                        <select class="form-control" name="titlehigh" value="">
                                            #if($relay.isHigh=='0')
                                            #foreach( $h in $high )
                                            <option
                                                    #if($detailshigh.highsattion== $h.highsattion)
                                                    selected
                                                    #end
                                                    value="${h.highsattion}">${h.highsattion}
                                            </option>
                                            #end
                                            #end
                                        </select>
                                    </div>
                                    <div id="planeShow" style="display: none"
                                         class="form-group form-md-line-input col-md-12 relayShow">
                                        <label>飞机站点</label><br/>
                                        <select class="form-control" name="titleplane" value="">
                                            #if($relay.isPlane=='0')
                                            #foreach( $p in $plane )
                                            <option
                                                    #if($detailsplane.planesattion== $p.planesattion)
                                                    selected
                                                    #end
                                                    value="${p.planesattion}">${p.planesattion}
                                            </option>
                                            #end
                                            #end
                                        </select>

                                    </div>
                                    <div id="arrivetime" style="display: none"
                                         class="form-group form-md-line-input col-md-12">
                                        <label>到站时间</label>
                                        <input type="text" class="form-control datepicker"
                                               value="$!{arrivetime}" required
                                               name="arrivetime" placeholder="到站时间"
                                               readonly="readonly">
                                    </div>
                                    <div id="shift" style="display: none"
                                         class="form-group form-md-line-input col-md-12">
                                        <label>班次</label>
                                        <input type="text" required class="form-control pull-right"
                                               value="$!{shift}"
                                               name="shift" placeholder="班次"
                                        >
                                    </div>
                                </section>
                            </section>


                            <section class="panel panel-default" id="pane4">
                                <header class="panel-heading suk_heading">
                                    <ul class="nav nav-pills pull-right">
                                        <li><a href="#" class="panel-toggle text-muted"><i
                                                class="fa fa-caret-down text-active"></i><i
                                                class="fa fa-caret-up text"></i></a></li>
                                    </ul>
                                    送站服务
                                </header>
                                <section class="chat-list panel-body suk_body">
                                    <div id="way1" style="display: none"
                                         class="form-group form-md-line-input col-md-12">
                                        #if($service.isRelay=='0')
                                        #if($relay.isHigh=='0')
                                        <input type="radio" name="relay2" value="highbus1">高铁
                                        #end
                                        #if($relay.isPlane=='0')
                                        <input type="radio" name="relay2" value="plane1">飞机
                                        #end
                                        #if($relay.isOnedrive=='0')
                                        <input type="radio" name="relay2" i value="onedrive1">自驾
                                        #end
                                        #if($relay.isOther=='0')
                                        <input type="radio" name="relay2" value="other1">其他
                                        #end
                                        #end
                                     </div>
                                    <div id="highbus1Show" style="display: none"
                                         class="form-group form-md-line-input col-md-12 relayShow1">
                                        <label>高铁站点</label><br/>
                                        <select class="form-control" name="titlehigh1" value="">
                                            #if($relay.isHigh=='0')
                                            #foreach( $h in $high )
                                            <option
                                                    #if($detailshigh1.highsattion== $h.highsattion)
                                                    selected
                                                    #end
                                                    value="${h.highsattion}">${h.highsattion}
                                            </option>
                                            #end
                                            #end
                                        </select>
                                    </div>
                                    <div id="plane1Show" style="display: none"
                                         class="form-group form-md-line-input col-md-12 relayShow1">
                                        <label>飞机站点</label><br/>
                                        <select class="form-control" name="titleplane1" value="">
                                            #if($relay.isPlane=='0')
                                            #foreach( $p in $plane )
                                            <option
                                                    #if($detailsplane1.planesattion== $p.planesattion)
                                                    selected
                                                    #end
                                                    value="${p.planesattion}">${p.planesattion}
                                            </option>
                                            #end
                                            #end
                                        </select>

                                    </div>
                                    <div id="arrivetime1" style="display: none"
                                         class="form-group form-md-line-input col-md-12">
                                        <label>到站时间</label>
                                        <input type="text" class="form-control datepicker"
                                               value="$!{arrivetime1}" required
                                               name="arrivetime1" placeholder="到站时间"
                                               readonly="readonly">
                                    </div>
                                    <div id="shift1" style="display: none"
                                         class="form-group form-md-line-input col-md-12">
                                        <label>班次</label>
                                        <input type="text" required class="form-control pull-right"
                                               value="$!{shift1}"
                                               name="shift1" placeholder="班次"
                                        >
                                    </div>

                                </section>
                            </section>


                            <section class="panel panel-default" id="pane5">
                                <header class="panel-heading suk_heading">
                                    <ul class="nav nav-pills pull-right">
                                        <li><a href="#" class="panel-toggle text-muted"><i
                                                class="fa fa-caret-down text-active"></i><i
                                                class="fa fa-caret-up text"></i></a></li>
                                    </ul>
                                    试驾时间
                                </header>
                                <section class="chat-list panel-body suk_body">
                                    <div id="take1" style="display: none"
                                         class="form-group form-md-line-input col-md-12">
                                        #if($service.isTake=='0')
                                        #foreach($t in $take)
                                        <input type="radio" name="taketime" value="${t.taketime}">${t.taketime} $!{t.take_des}<br/>
                                        #end
                                        #end
                                    </div>
                                </section>
                            </section>


                            <section class="panel panel-default" id="pane6">
                                <header class="panel-heading suk_heading">
                                    <ul class="nav nav-pills pull-right">
                                        <li><a href="#" class="panel-toggle text-muted"><i
                                                class="fa fa-caret-down text-active"></i><i
                                                class="fa fa-caret-up text"></i></a></li>
                                    </ul>
                                    参观时间
                                </header>
                                <section class="chat-list panel-body suk_body">
                                    <div id="factory1" style="display: none"
                                         class="form-group form-md-line-input col-md-12">
                                        #if($service.isfactory=='0')
                                        #foreach($f in $factory)
                                        <span><input type="checkbox" name='visittime' value="${f.visittime} ${f.des}">${f.visittime} ${f.des}</span><br/>
                                        #end
                                        #end
                                    </div>
                                </section>
                            </section>


                            <section class="panel panel-default" id="pane7">
                                <header class="panel-heading suk_heading">
                                    <ul class="nav nav-pills pull-right">
                                        <li><a href="#" class="panel-toggle text-muted"><i
                                                class="fa fa-caret-down text-active"></i><i
                                                class="fa fa-caret-up text"></i></a></li>
                                    </ul>
                                    备注
                                </header>
                                <section class="chat-list panel-body suk_body">
                                    <div id="des" class="form-group form-md-line-input col-md-12">
                                        <input type="text" class="form-control pull-right "
                                               value="$!{desc}" name="desc" placeholder="备注"
                                        >
                                    </div>
                                </section>
                            </section>


                            <div class="box-footer">
                                #if($shiro.hasPermission("qy:demand:edit"))
                                <input class="btn btn-primary" id="save" value="保存" type="submit">
                                #end
                                <a class="btn btn-primary" href="javascript:history.go(-1)">返回</a>
                            </div>
                        </div>
                    </form>
                    <!-- /.box-body -->
                </div><!-- /.box -->


            </div><!-- /.col -->
        </div><!-- /.row -->
        </section><!-- /.content -->
    </div><!-- /.content-wrapper -->


    <!-- Add the sidebar's background. This div must be placed
         immediately after the control sidebar -->
    <div class="control-sidebar-bg"></div>
</div><!-- ./wrapper -->

<script src="plugins/jQuery/jQuery-2.1.4.min.js"></script>
<!-- Bootstrap 3.3.5 -->
<script src="bootstrap/js/bootstrap.min.js"></script>
<!-- DataTables -->
<script src="plugins/datatables/jquery.dataTables.min.js"></script>
<script src="plugins/datatables/extensions/i18n/lanauage_ch.js"></script>
<script src="plugins/datatables/dataTables.bootstrap.min.js"></script>
<!-- SlimScroll -->
<script src="plugins/slimScroll/jquery.slimscroll.min.js"></script>
<!-- FastClick -->
<script src="plugins/fastclick/fastclick.min.js"></script>
<!--fileinput js-->
<script src="plugins/bootstrap-fileinput/bootstrap-fileinput.js"></script>
<!-- AdminLTE App -->
<script src="dist/js/app.min.js"></script>
<script src="plugins/bootstrap-maxlength/bootstrap-maxlength.min.js" type="text/javascript"></script>
<script src="plugins/security/sha256.js" type="text/javascript"></script>
<script src="plugins/jquery-validation/js/jquery.validate.min.js"></script>
<script src="js/jquery.form.min.js"></script>
<script type="text/javascript" charset="utf-8" src="plugins/ueditor-min-1.4.3/ueditor.config.js"></script>
<script type="text/javascript" charset="utf-8" src="plugins/ueditor-min-1.4.3/ueditor.all.js"></script>
<script type="text/javascript" charset="utf-8" src="plugins/ueditor-min-1.4.3/lang/zh-cn/zh-cn.js"></script>
<script src="js/jquery.serializejson.js"></script>
<script src="common/js/cfapp.js"></script>
<script src="js/app.js"></script>
<script type="text/javascript" src="plugins/daterangepicker-master/moment.min.js"></script>
<script type="text/javascript" src="plugins/daterangepicker-master/daterangepicker.js"></script>
<script>
    var csrfheader = {name: '_csrf_header', value: '${_csrf.headerName}'};
    var csrftoken = {name: '_csrf', value: '${_csrf.token}'};
</script>
<!-- END PAGE LEVEL PLUGINS -->
<script>
    var locale = {
        "format": 'YYYY-MM-DD HH:mm',
        "separator": " -222 ",
        "applyLabel": "确定",
        "cancelLabel": "取消",
        "fromLabel": "起始时间",
        "toLabel": "结束时间'",
        "customRangeLabel": "自定义",
        "weekLabel": "W",
        "daysOfWeek": ["日", "一", "二", "三", "四", "五", "六"],
        "monthNames": ["一月", "二月", "三月", "四月", "五月", "六月", "七月", "八月", "九月", "十月", "十一月", "十二月"],
        "firstDay": 1
    };
    $().ready(function () {
        recdTypeAdd.init();

        //如果试驾选择30号，工厂参观30号就影藏
        $("#take1 input").on('click',function(){
            //alert("a")
            if ($("input[name='take']").is(":checked")) {
                for (var k = 0; k < $("#take1 input").length; k++) {
                    var node = $("#take1 input")[k];
                    if ($(node).is(":checked")) {
                        var s = $(node).val();
                        for (var i = 0; i < $("#factory1 input").length; i++) {
                            var node = $("#factory1 input")[i];
                                var str = $(node).val();
                                var str1 = [];
                                var index = str.indexOf(" ");
                                str1 = str.split(" ");
                                if(s == str.substr(0,index)){
                                    $(node).attr("checked",false);
                                    $(node).parent().css("display","none");
                                }else{
                                    $(node).parent().css("display","");
                                }
                        }
                    }
                }

            }
        })


        $(".hotelDatePicker").each(function () {
            var start = $(this).attr("data-start");
            var end = $(this).attr("data-end");
            var value = $(this).val();
            $(this).daterangepicker({
                'locale': {
                    "format": 'YYYY-MM-DD',
                    "separator": " -222 ",
                    "applyLabel": "确定",
                    "cancelLabel": "取消",
                    "fromLabel": "起始时间",
                    "toLabel": "结束时间'",
                    "customRangeLabel": "自定义",
                    "weekLabel": "W",
                    "daysOfWeek": ["日", "一", "二", "三", "四", "五", "六"],
                    "monthNames": ["一月", "二月", "三月", "四月", "五月", "六月", "七月", "八月", "九月", "十月", "十一月", "十二月"],
                    "firstDay": 1
                },
                "singleDatePicker": true,
                "timePicker": false,
                "timePicker24Hour": true,
                "showCustomRangeLabel": false,
                "maxDate": end,
                "minDate": start

            });
            if(value==null || value ==""){
                $(this).val("");
            }
        })

        $('.datepicker').daterangepicker({
            'locale': locale,
            "singleDatePicker": true,
            "timePicker": true,
            "timePicker24Hour": true,
            "showCustomRangeLabel": false
        }, function(start, end, label) {
            console.log("New date range selected: ' + start.format('YYYY-MM-DD') + ' to ' + end.format('YYYY-MM-DD') + ' (predefined range: ' + label + ')");
        });


        var detailsjson = ${detailsinfo}

        var service = ${service};

        if (detailsjson != "" && detailsjson != null) {
            if (detailsjson.isHotel == '0') { //酒店服务
                $("input[name='hotel']").attr("checked", true);
                var hotelTitle;
                if(detailsjson.hotel){
                    var hotel = JSON.parse(detailsjson.hotel);
                    hotelTitle = hotel.title;
                }else{
                    hotelTitle =$("#hotel select option:selected").text();
                }
                $("#hotel").show();
                $("#hotelintime").show();
                $("#hotelouttime").show();
                $(".hoteltime input[data-title=" + hotelTitle + "]").show();
            }


            $("input[name='hotel']").change(function () {
                if ($("input[name='hotel']").is(":checked")) {
                    $("#hotel").show();
                    $("#hotelintime").show();
                    $("#hotelouttime").show();
                    var hoteValue = $("#hotel select option:selected").text();
                    $(".hoteltime input[data-title=" + hoteValue + "]").show();
                } else {
                    $("#hotel").hide();
                    $("#hotelintime").hide();
                    $("#hotelouttime").hide();
                }
            })


            $("#hotel select").change(function () {
                var hoteValue;
                if(detailsjson.hotel){
                    var hotel = JSON.parse(detailsjson.hotel);
                    var title = hotel.title;
                    hoteValue = $(this).val();
                }else{
                    hoteValue =$("#hotel select option:selected").text();
                }
                $(".hoteltime input").hide();
                $(".hoteltime input[data-title=" + hoteValue + "]").show();
            })


            if (detailsjson.isEat == '0') {  //餐饮服务
                $("input[name='eat']").attr("checked", true);
                var eat = JSON.parse(detailsjson.eat);
                for (var i = 0; i < eat.length; i++) {
                    for (var k = 0; k < $("#eat input").length; k++) {
                        var node = $("#eat input")[k];
                        if ($(node).val() == eat[i].eatname) {
                            $(node).attr("checked", true);
                        }
                    }
                }
                $("#eat").show();
            }
            $("input[name='eat']").change(function () {
                if ($("input[name='eat']").is(":checked")) {
                    $("#eat").show();
                } else {
                    $("#eat").hide();
                }
            })


            //接
            if (detailsjson.isRelay == '0') {
                $("input[name='relay']").attr("checked", true);
                $("#way").show();


                var relay = JSON.parse(detailsjson.relay);
                if (relay != "") {
                    if (relay.isPlane == '0') { //飞机
                        $("input[value='plane']").attr("checked", true);
                        $("#planeShow").show();
                        $("#arrivetime").show();
                        $("#shift").show();
                    } else if (relay.isHigh == '0') {//高铁
                        $("input[value='highbus']").attr("checked", true);
                        $("#highbusShow").show();
                        $("#arrivetime").show();
                        $("#shift").show();
                    } else if (relay.isOnedrive == '0') {//自驾
                        $("input[value='onedrive']").attr("checked", true);
                        $(".relayShow").hide();
                    } else if (relay.isOther == '0') {//其他
                        $("input[value='other']").attr("checked", true);
                        $(".relayShow").hide();
                    }
                }

            }
            $('input[type=radio][name=relay1]').change(function () {
                $(".relayShow").hide();
                $('#' + $(this).val() + "Show").show();
                if ($("input[type=radio][value='onedrive']").is(":checked")) {
                    $("#arrivetime").hide();
                    $("#shift").hide();
                } else if ($("input[type=radio][value='other']").is(":checked")) {
                    $("#arrivetime").hide();
                    $("#shift").hide();
                } else {
                    $("#arrivetime").show();
                    $("#shift").show();
                }
            })

            //送
            if (detailsjson.isRelay == '0') {
                $("input[name='relay']").attr("checked", true);
                $("#way1").show();
                var relay = JSON.parse(detailsjson.send);
                if (relay != "") {
                    if (relay.isPlane == '0') {//飞机
                        $("input[value='plane1']").attr("checked", true);
                        $("#plane1Show").show();
                        $("#arrivetime1").show();
                        $("#shift1").show();
                    } else if (relay.isHigh == '0') {//高铁
                        $("input[value='highbus1']").attr("checked", true);
                        $("#highbus1Show").show();
                        $("#arrivetime1").show();
                        $("#shift1").show();
                    } else if (relay.isOnedrive == '0') {//自驾
                        $("input[value='onedrive1']").attr("checked", true);
                        $(".relayShow1").hide();
                    } else if (relay.isOther == '0') {//其他
                        $("input[value='other1']").attr("checked", true);
                        $(".relayShow1").hide();
                    }
                }

            }
            $('input[type=radio][name=relay2]').change(function () {
                $(".relayShow1").hide();
                $('#' + $(this).val() + "Show").show();

                if ($("input[type=radio][value='onedrive1']").is(":checked")) {
                    $("#arrivetime1").hide();
                    $("#shift1").hide();
                } else if ($("input[type=radio][value='other1']").is(":checked")) {
                    $("#arrivetime1").hide();
                    $("#shift1").hide();
                } else {
                    $("#arrivetime1").show();
                    $("#shift1").show();
                }
            })

            $("input[name='relay']").change(function () {
                var relay={};
                var send={};
                if(detailsjson.relay){
                    relay = JSON.parse(detailsjson.relay);
                    send = JSON.parse(detailsjson.send);
                }
                if ($("input[name='relay']").is(":checked")) {
                    $("#way").show();
                    $("#way1").show();
                    if(detailsjson.relay){
                        if (relay.isOnedrive == '0' || relay.isOther == '0') {
                            $("#highbusShow").hide();
                            $("#planeShow").hide();
                            $("#shift").hide();
                            $("#arrivetime").hide();
                        } else {
                            $("#highbusShow").show();
                            $("#planeShow").show();
                            $("#shift").show();
                            $("#arrivetime").show();
                        }
                    }

                    if(detailsjson.send){
                        if (send.isOnedrive == '0' || send.isOther == '0') {
                            $("#highbus1Show").hide();
                            $("#shift1").hide();
                            $("#arrivetime1").hide();
                            $("#plane1Show").hide();
                        } else {
                            $("#highbus1Show").show();
                            $("#shift1").show();
                            $("#arrivetime1").show();
                            $("#plane1Show").show();
                        }
                    }





                } else {
                    $("#way").hide();
                    $("#way1").hide();
                    $("#highbusShow").hide();
                    $("#highbus1Show").hide();
                    $("#planeShow").hide();
                    $("#plane1Show").hide();
                    $("#shift1").hide();
                    $("#shift").hide();
                    $("#arrivetime1").hide();
                    $("#arrivetime").hide();
                }
            })


            //试乘
            var taketime = null;
            if (detailsjson.isTake == '0') {
                $("input[name='take']").attr("checked", true);
                $("#take1").show();
                var take = JSON.parse(detailsjson.take);
                for (var i = 0; i < take.length; i++) {
                    for (var k = 0; k < $("#take1 input").length; k++) {
                        var node = $("#take1 input")[k];
                        if ($(node).val() == take[i].taketime) {
                            $(node).attr("checked", true);
                        }
                        if ($(node).is(":checked")) {
                            taketime = $(node).val();
                        }

                    }

                }

            }
            $("input[name='take']").change(function () {
                if ($("input[name='take']").is(":checked")) {
                    $("#take1").show();
                    for(var i=0;i<$("#take1 input").length; i++){
                        var node = $("#take1 input")[i];
                        $(node).attr("checked",false);
                    }
                } else {
                    $("#take1").hide();
                    for (var i = 0; i < $("#factory1 input").length; i++) {
                        var node = $("#factory1 input")[i];
                        $(node).parent().css("display","");
                    }
                }
            })

            //工厂
            if (detailsjson.isfactory == '0') {
                $("#factory1").show();
                $("input[name='factory']").attr("checked", true);
                var factory = JSON.parse(detailsjson.factory);
                for (var i = 0; i < factory.length; i++) {
                    for (var k = 0; k < $("#factory1 input").length; k++) {
                        var node = $("#factory1 input")[k];
                        var str = factory[i].visittime+" "+factory[i].visitdesc;

                        var str1 = $(node).val();
                        var index = str.indexOf(" ");
                        var visittime = str1.substr(0,index);
                        if(visittime == taketime){
                            $(node).parent("span").css("display","none");
                            $(node).attr("checked",false);
                        }else{
                            $(node).parent("span").css("display","");
                        }
                        if ($(node).val() == str) {
                            $(node).attr("checked", true);
                        }
                    }
                }

            } else {
                $("#factory1").hide();
            }
            $("input[name='factory']").change(function () {
                if ($("input[name='factory']").is(":checked")) {
                    $("#factory1").show()
                    for(var i =0;i<$("#factory1 input").length;i++){
                        var node = $("#factory1 input")[i];
                        $(node).attr("checked",false);
                    }
                } else {
                    $("#factory1").hide()
                }
            })


        }else{
            $("input[name='factory']").change(function () {
                if ($("input[name='factory']").is(":checked")) {
                    $("#factory1").show()
                } else {
                    $("#factory1").hide()
                }
            })
        }


    })

    var recdTypeAdd = function () {
        var initForm = function () {
            var initFormCtrl = function () {
                bindEvent();
            };
            var bindEvent = function () {

                $("#myForm").validate({
                    rules: {},
                    messages: {},
                    submitHandler: function (form) {
                        //alert("a")
                        var object = {};
                        var staticArray = "1";
                        //酒店服务
                        if ($("input[name='hotel']").is(":checked")) {
                            object.isHotel = "0";
                            var hotelArr = {};
                            var title = $("select[name='title']").val();
                            var endTimeStr = $("input[name='endTimeStr'][data-title=" + title + "]").val();
                            var startTimeStr = $("input[name='startTimeStr'][data-title=" + title + "]").val();
                            var t1 = new Date(endTimeStr);
                            var t2 = new Date(startTimeStr);
                            if (Date.parse(t1) - Date.parse(t2) < 0) {
                                Cfapp.alert({
                                    message: "离店时间早于进店时间",
                                    btntext: "确定",
                                    success: function () {
                                    }
                                })
                                return;
                            }
                            hotelArr.title = title;
                            hotelArr.startDate = startTimeStr;
                            hotelArr.endDate = endTimeStr;
                            object.hotel = JSON.stringify(hotelArr);
                        } else {
                            object.isHotel = staticArray;
                        }
                        //餐饮服务
                        if ($("input[name='eat']").is(":checked")) {
                            object.isEat = "0";
                            var eatArr = [];
                            for (var k = 0; k < $("#eat input").length; k++) {
                                var node = $("#eat input")[k];
                                if ($(node).is(":checked")) {
                                    var eatObj = {};
                                    eatObj.eatname = $(node).val();
                                    eatArr.push(eatObj);
                                }
                            }
                            object.eat = JSON.stringify(eatArr);
                        } else {
                            object.isEat = staticArray;
                        }

                        //接送服务
                        if ($("input[name='relay']").is(":checked")) {
                            object.isRelay = "0";
                            var relayArr = {};
                            if ($("input[type='radio'][value='plane']").is(":checked")) {     //接
                                relayArr.isPlane = "0";
                                var planeArry = {};
                                planeArry.planesattion = $("select[name='titleplane']").val();
                                relayArr.plane = planeArry;
                                relayArr.arrivetime  =$("input[name='arrivetime']").val();
                                relayArr.shift = $("input[name='shift']").val();
                                object.relay = JSON.stringify(relayArr);
                            } else if ($("input[type='radio'][value='highbus']").is(":checked")) {
                                relayArr.isHigh = "0";
                                var highArry = {};
                                highArry.highsattion = $("select[name='titlehigh']").val();
                                relayArr.arrivetime  =$("input[name='arrivetime']").val();
                                relayArr.shift = $("input[name='shift']").val();
                                relayArr.high = highArry;
                                object.relay = JSON.stringify(relayArr);
                            } else if ($("input[type='radio'][value='onedrive']").is(":checked")) {
                                relayArr.isOnedrive = "0";
                                object.relay = JSON.stringify(relayArr);
                            } else if ($("input[type='radio'][value='other']").is(":checked")) {
                                relayArr.isOther = "0";
                                object.relay = JSON.stringify(relayArr);
                            }


                            var sendArr = {};
                            if ($("input[type='radio'][value='plane1']").is(":checked")) {     //送
                                sendArr.isPlane = "0";
                                var planeArry = {};
                                planeArry.planesattion = $("select[name='titleplane1']").val();
                                sendArr.plane = planeArry;
                                sendArr.arrivetime1  =$("input[name='arrivetime1']").val();
                                sendArr.shift1 = $("input[name='shift1']").val();
                                object.send = JSON.stringify(sendArr);
                            } else if ($("input[type='radio'][value='highbus1']").is(":checked")) {
                                sendArr.isHigh = "0";
                                var highArry = {};
                                highArry.highsattion = $("select[name='titlehigh1']").val();
                                sendArr.high = highArry;
                                sendArr.arrivetime1  =$("input[name='arrivetime1']").val();
                                sendArr.shift1 = $("input[name='shift1']").val();
                                object.send = JSON.stringify(sendArr);
                            } else if ($("input[type='radio'][value='onedrive1']").is(":checked")) {
                                sendArr.isOnedrive = "0";
                                object.send = JSON.stringify(sendArr);
                            } else if ($("input[type='radio'][value='other1']").is(":checked")) {
                                sendArr.isOther = "0";
                                object.send = JSON.stringify(sendArr);
                            }


                        } else {
                            object.isRelay = staticArray;
                        }

                        //试乘试驾
                        if ($("input[name='take']").is(":checked")) {
                            object.isTake = "0";
                            var takeArr = [];
                            for (var i = 0; i < $("#take1 input").length; i++) {
                                var node = $("#take1 input")[i];
                                if ($(node).is(":checked")) {
                                    var takeObj = {};
                                    takeObj.taketime =  $(node).val();
                                    takeArr.push(takeObj);
                                }
                            }
                            object.take = JSON.stringify(takeArr);

                        } else {
                            object.isTake = staticArray;
                        }

                        //工厂参观
                        if ($("input[name='factory']").is(":checked")) {
                            object.isfactory = "0";
                            var factoryArr = [];
                            for (var i = 0; i < $("#factory1 input").length; i++) {
                                var node = $("#factory1 input")[i];
                                if ($(node).is(":checked")) {
                                    var factoryObj = {};
                                    var str = $(node).val();
                                    var str1 = [];
                                    var index = str.indexOf(" ");

                                    str1 = str.split(" ");
                                    factoryObj.visittime = str.substr(0,index);
                                    factoryObj.visitdesc = str.substr(index+1,str.length);
                                    factoryArr.push(factoryObj);
                                }
                            }
                            object.factory = JSON.stringify(factoryArr);

                        } else {
                            object.isfactory = staticArray;
                        }

                        //备注
                        object.desc = $("input[name='desc']").val();
                        object.detailsinfo = JSON.stringify(object);
                        object.memberUid = "$!{member_uid}";
                        object.meeting_id = "${meetingId}";
                        object._csrfheader = csrfheader.value;
                        object._csrf = csrftoken.value;
                        $("#save").attr("disabled", true);
                        $.ajax({
                            url: "#springUrl('/a/details/formData')",
                            type: "post",
                            dataType: "json",
                            data: object,
                            success: function (returnobj) {
                                $("#save").attr("disabled", false);
                                if (returnobj.errorNo == 2) {  //保存成功
                                    Cfapp.alert({
                                        message: "添加成功",
                                        btntext: "确定",
                                        success: function () {
                                            location.href = "#springUrl('/a/details/form?meetingId=')${meetingId}&member_uid=$!{member_uid}";
                                        }
                                    });
                                } else if(returnobj.errorNo == 0){
                                    Cfapp.alert({
                                        message: "修改成功",
                                        btntext: "确定",
                                        success: function () {
                                            location.href = "#springUrl('/a/details/form?meetingId=')${meetingId}&member_uid=$!{member_uid}";
                                        }
                                    });
                                }else {
                                    Cfapp.alert({
                                        message: "创建失败",
                                        btntext: "确定",
                                        success: function () {

                                        }
                                    });
                                }
                            }
                        });
                    }
                })
            }
            initFormCtrl();
        }
        return {

            //main function to initiate the module
            init: function () {
                initForm();
            }

        };
    }();


</script>
</body>
<!-- END BODY -->
</html>