{% block listBlock %}
<div class="wrap">
    <h2> {% if house_type == 0%}新房列表{% elseif house_type == 1 %}二手房列表{% else %}租房房列表{% endif %}</h2>
    <form id="scores-filter" method="GET" class="form-inline">
        <br />
        {% include 'selectOrganization.html' %}
        <!-- For plugins, we also need to ensure that the form posts back to our current page -->
        <div style="margin-bottom: 10px;">
            <input type="hidden" name="page" value="{{page}}"/>
            <select id="listCity" name="listCity" class="form-control">
                <option value="-1"> 城市</option>
                {% for item in city %}
                <option {{ item.id == cityId ?"selected":"" }} value="{{ item.id }}">{{ item.value }}</option>
                {% endfor %}
            </select>
            <select id="listDistrict" name="listDistrict"  class="form-control">
                <option value="-1">区域</option>
                {% if district %}
                {% for item in district %}
                <option {{ item.id == districtId ?"selected":"" }} value="{{ item.id }}">{{ item.value }}</option>
                {% endfor %}
                {% endif %}
            </select>
            <select  id="listPlate" name="listPlate"  class="form-control">
                <option value="-1">板块</option>
                {% if plate %}
                {% for item in plate %}
                <option {{ item.id == plateId ?"selected":"" }} value="{{ item.id }}">{{ item.value }}</option>
                {% endfor %}
                {% endif %}
            </select>
            {% if house_type == 2%}
            <select id="rentalPrice" name="rentalPrice"  class="form-control">
                <option value ="">租金</option>
                {% if dicRentalPrice %}
                {% for item in dicRentalPrice %}
                <option {{ item.value == rentalPrice ?"selected":"" }} value="{{ item.value }}">{{ item.value }}</option>
                {% endfor %}
                {% endif %}
            </select>
            {% elseif house_type == 0 %}
            <select id="averagePrice" name="averagePrice"  class="form-control">
                <option value ="">单价</option>
                <!--<option {{ item.value == average_price ?"selected":"" }} value="{{ item.value }}">{{ item.value }}</option>-->
            </select>
            {% else%}
            <select id="totalPrice" name="totalPrice"  class="form-control">
                <option value ="">价格</option>
                {% if dicTotalPrice %}
                {% for item in dicTotalPrice %}
                <option {{ item.value == totalPrice ?"selected":"" }} value="{{ item.value }}">{{ item.value }}</option>
                {% endfor %}
                {% endif %}
            </select>
            {% endif %}
            {% if house_type == 0%}
            <select id="room" name="room"  class="form-control">
                <option value="-1">类型</option>
                {% for item in room %}
                <option {{ item.id == roomId ?"selected":"" }} value="{{ item.id }}">{{ item.value }}</option>
                {% endfor %}
            </select>
            {% endif %}
            <select id="buildProperty" name="buildProperty"  class="form-control">
                <option value="-1"> 房型</option>
                {% for item in buildProperty %}
                <option {{ item.id == buildPropertyId ?"selected":"" }} value="{{ item.id }}">{{ item.value }}</option>
                {% endfor %}
            </select>
            <select id="acreage" name="acreage"  class="form-control">
                <option value ="">面积</option>
                {% if acreage %}
                {% for item in dicArea %}
                <option {{ item.value == acreage ?"selected":"" }} value="{{ item.value }}">{{ item.value }}</option>
                {% endfor %}
                {% endif %}
            </select>
            <select name="status" name="status"  class="form-control">
                <option value="-1">状态</option>
                {% for item in status%}
                <option {{ item.id == statusId ?"selected":"" }} value="{{ item.id }}">{{ item.value }}</option>
                {% endfor %}
            </select>
        </div>
        <div id="organization" style="margin-bottom: 10px;">
            <label for="endDate">楼盘名:</label>
            <input type="text" name="searchText"  class="form-control">
            <label for="beginDate" >开始日期:</label>
            <input type="date" name="beginDate" class="form-control" {% if req %}value="{{req.beginDate}}"{% endif %}>
            <label for="endDate">结束日期:</label>
            <input type="date" name="endDate" class="form-control"  {% if req %}value="{{req.endDate}}"{% endif %}>
            <label for="stuff">员工:</label>
            <input type="text" name="stuff" class="form-control"   {% if req %}value="{{req.stuff}}"{% endif %}>
            <input type="hidden" name="hasSearch" value="1"/>
            <input type="hidden" id="house_type" value="{{house_type}}"/>
            <input type="submit" id="submit" class="button action" value="搜索">
        </div>
    </form>
    <form method="post">
        <!-- Now we can render the completed list table -->
        {% if house_type == 0 %}
            {{function("addNewHouseTable")}}
        {% elseif house_type == 1%}
            {{function("addSecTable")}}
        {% else %}
            {{function("addRentTable")}}
        {% endif %}
        <input type="hidden" name="allot_consultant_id" id="allot_consultant_id">
    </form>
</div>
{% include 'recConsultant.html' %}
{{ block('recConsultant') }}
<script>
    (function ($) {
        $(document).ready(function(){
            var acreage =$("#acreage");
            var totalPrice = $("#totalPrice");
            var rentalPrice = $("#rentalPrice");
			var averagePrice = $("#averagePrice");
            $("#listCity").change(function() {
                var cityId = $("#listCity").val();
                setCity("listCity", "listDistrict", "listPlate");
                acreage.find('option:not(:first-child)').remove();
                totalPrice.find('option:not(:first-child)').remove();
                rentalPrice.find('option:not(:first-child)').remove();
                //面积
                searchAcreage(cityId, acreage);
                //城市联动房子价格
                if ($("#house_type").val() == 2) {
                    searchRentalPrice(cityId, rentalPrice);
                }else if($("#house_type").val() == 0){
                    searchPrice(cityId,averagePrice);
                }
                else{
                    searchTotalPrice(cityId,totalPrice);
                }
            });
            //设置区域
            $("#listDistrict").change(function(){
                setArea("listCity","listDistrict","listPlate");
            })

            {% if house_type == 1 %}
                allot_consultant('sechandhouselist');
            {% elseif house_type == 2 %}
                allot_consultant('renthouselist');
            {% endif %}

			$('form').submit(function () {
                var organization = getOrganization();
                var select = $('select[data-depth]:not(.hidden)');
                if (select.length > 1 && organization == -1) {
                    alert('请选择门店');
                    return false;
                } else {
                    $(this).append('<input type="hidden" name="organization" value="' + organization + '">');
                }
            });
        });
    })(jQuery);
</script>
{% endblock %}