<!DOCTYPE HTML>
<html>
<head>
    {% set title = houseId?"修改新房房源":"添加新房房源" %}
    <meta charset="utf-8">
    <title>{{title}}</title>
</head>
<body>
<script>
    var i = 0
</script>
<h2 class="title">{{title}}</h2>
<div class="alert alert-danger" role="alert" id="messageBox1" style="display:none;">

</div>
<form action="" method="POST" enctype="multipart/form-data" id="newHouse" class="form-inline">
    <div class="row">
        <div class="col-md-11">
            <!-- Nav tabs -->
            <ul class="nav nav-tabs" role="tablist">
                <li role="presentation" class="active"><a href="#info" aria-controls="info" role="tab" data-toggle="tab">楼盘情况</a></li>
                <li role="presentation"><a href="#weixin" aria-controls="weixin" role="tab" data-toggle="tab">微信营销</a></li>
                <li role="presentation"><a href="#business" aria-controls="business" role="tab" data-toggle="tab">业务信息</a></li>
                <li role="presentation"><a href="#mainHouse" aria-controls="mainHouse" role="tab" data-toggle="tab">主力户型</a></li>
                <li role="presentation"><a href="#photos" aria-controls="photos" role="tab" data-toggle="tab">房源相册</a></li>
                <li role="presentation"><a href="#addRecHouse" aria-controls="addRecHouse" role="tab" data-toggle="tab">推荐房源</a></li>
                <li role="presentation"><a href="#addConsultant" aria-controls="addConsultant" role="tab" data-toggle="tab">置业顾问</a></li>
            </ul>
            <!-- Tab panes -->
            <div class="tab-content">

                    <div role="tabpanel" class="tab-pane active" id="info">
                        {% if (house_type==1 or house_type == 2)%}
                            {% include 'houseInfo.html' %}
                        {% else %}
                            {% include 'newHouseInfo.html' %}
                        {% endif %}
                    </div>


                <div role="tabpanel" class="tab-pane" id="weixin">
                    {% include 'weixin.html' %}
                </div>
                <div role="tabpanel" class="tab-pane" id="business">
                    {% include 'business.html' %}
                </div>
                <div role="tabpanel" class="tab-pane" id="mainHouse">
                    {% include 'mainHouse.html' %}
                </div>
                <div role="tabpanel" class="tab-pane" id="photos">
                    {% include 'photos.html' %}
                </div>
                <div role="tabpanel" class="tab-pane" id="addRecHouse">
                    {% include 'addRecHouse.html' %}
                </div>
                <div role="tabpanel" class="tab-pane" id="addConsultant">
                    {% include 'addConsultant.html' %}
                </div>
            </div>
            <input type="text" name="type" value="1" hidden="hidden">
            {% if houseId %}
            <input type="text" name="houseId" value="{{houseId}}" hidden="hidden">
            {% endif %}
        </div>
        <div  class="col-md-1">
            {% if (role == 'administrator'or role =='eidtor') %}
            <div  class="row" style="position: fixed;top:200px;">
            <select id="status" name="status">
                {% for item in status %}
                <option {{ item.id == searchStatus.id?"selected":"" }} value={{item.id}}>{{item.value}}</option>
                {% endfor %}
            </select>
            </div>
            {% endif %}
            <input type="submit" id="submit" class="button action" style="position: fixed;top:155px">
        </div>
    </div>
</form>

<!-- Modal -->
<!-- 推荐房源弹出层 -->
{% include 'recommendHouse.html' %}
{{ block('recommendHouse') }}
<!-- 置业顾问弹出层 -->
{% include 'recConsultant.html' %}
{{ block('recConsultant') }}


<script>
    (function($){
        $(document).ready(function(){
            setCity();
            setArea();
            setDate("checkin");
            var json = {"decoration":"{{result.decoration}}"};
            revertOption(json);
            $('#newHouse').validate({
                onkeyup: false,
                onfocusout: false,
                ignore: [],
                errorClass: "my-error-class",
                rules: {
                    housename:'required',
                    mark:'required',
                    community_name:'required',
                    address:'required',
                    average_price:'required',
                    latest_news:'required',
                    baseCity:{
                        citySelectcheck: true
                    },
                    baseAreaId:{
                        areaSelectcheck: true
                    },
                    basePlateId:{
                        plateSelectcheck: true
                    }
                },
                messages: {
                    housename:'请输入楼盘名称',
                    mark:'请输入标签',
                    community_name:'请输入小区名称',
                    address:'请输入地址',
                    average_price:'请输入均价',
                    latest_news:'请输入最新动态'
                },
                errorContainer: "#messageBox1",
                errorLabelContainer: "#messageBox1",
                submitHandler: function (form) {
                    if($("#photosTbody > tr").length == 0){
                        alert("请选择房源相册");
                        return false;
                    }
                    if($("#houseImg > p").length == 0){
                        alert("请选择推荐房源");
                        return false;
                    }
                    form.submit();
                }
            });
            jQuery.validator.addMethod('citySelectcheck', function (value) {
                return (value != '-1');
            },"请选择城市");
            jQuery.validator.addMethod('areaSelectcheck', function (value) {
                return (value != '-1');
            },"请选择区域");
            jQuery.validator.addMethod('plateSelectcheck', function (value) {
                return (value != '-1');
            },"请选择板块");
        });
    })(jQuery);

</script>

</body>
</html>