
<!DOCTYPE HTML>
<html>
<head>
    {% set title = houseId?"修改二手房房源":"添加二手房房源" %}
    <meta charset="utf-8">
    <title>{{title}}</title>
    <script>
        var i = 0;
    </script>
</head>
<body>
<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="secHouse" class="form-inline form-horizontal">
    <div class="row">
        <div class="col-xs-10">
            <!-- 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>-->
                <!--{% if not houseId %}-->
                    <!--<li role="presentation">-->
                        <!--<a href="#owner" aria-controls="owner" role="tab" data-toggle="tab">业主信息</a>-->
                    <!--</li>-->
                <!--{% endif %}-->
                <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="#addFeature" aria-controls="addFeature" role="tab" data-toggle="tab">房源特色</a>-->
                <!--</li>-->
                <!--<li role="presentation">-->
                    <!--<a href="#addConsultant" aria-controls="addConsultant" role="tab" data-toggle="tab">置业顾问</a>-->
                <!--</li>-->
                <li role="presentation">
                    <a href="#customer_tracking" aria-controls="customer_tracking" role="tab" data-toggle="tab">房源跟进</a>
                </li>
            </ul>
            <!-- Tab panes -->
            <div class="tab-content">
                <div role="tabpanel" class="tab-pane active" id="info">
                    {% include 'houseInfo.html' %}
                    {% include 'weixin.html' %}
                    {% if not houseId %}
                    {% include 'owner.html' %}
                    {% endif %}
                    {% include 'business.html' %}
                </div>
                <!--<div role="tabpanel" class="tab-pane" id="weixin">-->
                    <!--{% include 'weixin.html' %}-->
                <!--</div>-->
                <!--<div role="tabpanel" class="tab-pane" id="business">-->
                  <!---->
                <!--</div>-->
                <!--<div role="tabpanel" class="tab-pane" id="owner">-->
                 <!---->
                <!--</div>-->
                <div role="tabpanel" class="tab-pane" id="photos">
                    {% include 'photos.html' %}
                    {% include 'addRecHouse.html' %}
                    {% include 'addFeature.html' %}
                    {% include 'addConsultant.html' %}
                </div>
                <!--<div role="tabpanel" class="tab-pane" id="addRecHouse">-->
                  <!---->
                <!--</div>-->
                <!--<div role="tabpanel" class="tab-pane" id="addFeature">-->
                   <!---->
                <!--</div>-->
                <!--<div role="tabpanel" class="tab-pane" id="addConsultant">-->
                   <!---->
                <!--</div>-->
                <div role="tabpanel" class="tab-pane" id="customer_tracking">
                    {% include 'save_customer_tracking.html' %}
                    {% import "macro.html" as macro %}
                    {{ macro.customer_tracking_list(houseId, 1) }}
                </div>
            </div>
            <input type="text" name="type" value="2" hidden="hidden">
            {% if houseId %}
            <input type="text" name="houseId" value="{{houseId}}" hidden="hidden">
            {% endif %}
        </div>
        <div  class="col-xs-2">
            <div  class="row" style="position: fixed;top:200px;">
                {% if (role == 'administrator'or role =='eidtor') %}
                <select id="status" name="status">
                    {% for item in status %}
                    <option {{ item.id == result.status?"selected":"" }} value={{item.id}}>{{item.value}}</option>
                    {% endfor %}
                </select>
				{% else %}
                    <input type="hidden" name="status" value="0">                {% endif %}
                <input type="submit" id="submit" class="button action" style="position: fixed;top:155px">
            </div>
        </div>
    </div>
</form>

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

<script>
    (function($){
        $(document).ready(function(){
            $("#baseCity").change(function(){
                setCity("baseCity","baseAreaId","basePlateId");
            });
            $("#baseAreaId").change(function(){
                setArea("baseCity","baseAreaId","basePlateId");
            });
            setCheckBox();
            setAge();
            setDate("entrustDay");
            setDate("deadLine");
            var json = {
                "faceto":"{{result.faceto}}",
                "age":"{{result.age}}",
                "propertyRight":"{{result.propertyRight}}",
                "decoration":"{{result.decoration}}",
                "source":"{{result.source}}",
                "structure":"{{result.structure}}",
                "roomNum":"{{result.roomNum}}",
                "livingRoom":"{{result.livingRoom}}",
                "bathRoom":"{{result.bathRoom}}",
                "kitchen":"{{result.kitchen}}",
                "balcony":"{{result.balcony}}"
            };
            revertOption(json);

            var rulesJson = {
                housename:'required',
                mark:'required',
                total_price:'required',
                community_name:'required',
                average_price:'required',
                latest_news:'required',
                baseCity:{
                    citySelectcheck: true
                },
                baseAreaId:{
                    areaSelectcheck: true
                },
                basePlateId:{
                    plateSelectcheck: true
                }
            };
            {% if not houseId %}
                rulesJson.owner_name = 'required';
                rulesJson.owner_phone = 'required';
            {% endif %}
            $('#secHouse').validate({
                onkeyup: false,
                onfocusout: false,
                ignore: [],
                errorClass: "my-error-class",
                rules: rulesJson,
                messages: {
                    housename:'请输入房源名称',
                    mark:'请输入标签',
                    owner_name:'请输入业主姓名',
                    owner_phone:'请输入业主电话',
                    total_price:'请输入售价',
                    community_name:'请输入小区名称',
                    average_price:'请输入单价'
                },
                errorContainer: "#messageBox1",
                errorLabelContainer: "#messageBox1",
                submitHandler: function (form) {
                    if($("#consultantImg > p").length == 0){
                        alert("请选择置业顾问");
                        return false;
                    }
                    if($("#photosTbody > tr").length == 0){
                        alert("请选择房源相册");
                        return false;
                    }
                    if($("#houseImg > p").length == 0){
                        alert("请选择推荐房源");
                        return false;
                    }
                    if($("#feature > div").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>