<div style='max-height:500px;overflow:auto;min-width:850px;'>
<table class="table table-hover supplyquery" style="min-width:850px;">
	<div class="input-group layui-row" style="margin:10px;">
		<input type="text" placeholder="请输入内容进行搜索" id="select-url-kw" value="" class="form-control">
		<span class="input-group-addon btn btn-default select-btn" id="search_kw" data-type="url">搜索</span>
	</div>
    <tbody>   
        <?php foreach( $need_data as  $row  ){ ?>
        <tr>
            <td>{$row['community_name']}</td>
			<td>{$row['head_name']}</td>
			<td>{$row['head_mobile']}</td>
            <td>{$row['fullAddress']}</td>
            <td style="width:80px;"><a href="javascript:;" class="choose_dan_head" data-json='{:json_encode($row);}'>选择</a></td>
        </tr>
        <?php } ?>
        <?php if( count($need_data)<=0){ ?>
        <tr> 
            <td colspan='4' align='center'>未找到可分配的小区</td>
        </tr>
        <?php } ?>
    </tbody>
</table>
</div>

<script type="text/javascript" >
  
var query_kwd = '{$kwd}';
var query_url = "{:U('communityhead/lineheadquery', array('is_just_line' => $is_just_line))}";
var can_next = true;

	$("#search_kw").click(function(){
		var query_kwd = $('#select-url-kw').val();
		
		if(!can_next)
		{
			return false;
		}
		can_next = false;
		
		$.ajax({
			url:query_url,
			type:'post',
			dataType:'json',
			data:{keyword:query_kwd,is_ajax:1},
			success:function(ret){
				if(ret.code == 0)
				{
					$('.supplyquery tbody').html(ret.html);
					
				}
				can_next = true;
			}
		})
	})

    $(document).undelegate(".choose_dan_head","click").delegate(".choose_dan_head","click",function(){
        var json_obj = JSON.parse($(this).attr('data-json'));
        var p_html = '';
        p_html+= '<div class="multi-audio-item " data-id="'+json_obj.id+'">';
        p_html+= '    <div class="input-group">';
        p_html+= '       <input type="text" class="form-control img-textname" readonly="" value="'+json_obj.community_name+'">';
        p_html+= '       <input type="hidden" value="'+json_obj.id+'" name="head_id[]">';
        p_html+= '       <div class="input-group-btn">';
        p_html+= '            <button class="btn btn-default" data-id="'+json_obj.id+'" onclick="cancle_head(this, '+json_obj.id+')" type="button"><i class="fa fa-remove"></i></button>';
        p_html+= '       </div>';
        p_html+= '    </div>';
        p_html+= '</div>';
		
		//$(cur_open_div).val( json_obj.member_id );
        // $(cur_open_div).parent().siblings().remove();
        $('.multi-audio-details').append(p_html);
        
        // $(cur_open_div).val( json_obj.head_id );
        layer.close(layer.index); 
    });
</script>
