<div style='max-height:500px;overflow:auto;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" data-type="url">搜索</span>
  </div>
  <table class="table supplyquery table-hover supplyquery" style="min-width:850px;">
    <tbody>
    <tr>
      <th style="color:#000;">表单名称</th>
      <th style="color:#000;">表单类型</th>
      <th style="color:#000;">操作</th>
    </tr>
    <?php foreach($data['list'] as $row){  ?>
    <tr>
      <td>{$row['form_name']}</td>
      <td>{$row['form_type_name']}</td>
      <td style="width:80px;">
        <?php if(!empty($gpc['template']) && $gpc['template'] == 'mult'){ ?>
        <a href="javascript:;" class="choose_mult_link" data-json='<?php echo json_encode($row);?>'>选择</a>
        <?php }else{ ?>
        <a href="javascript:;" class="choose_dan_link" data-json='<?php echo json_encode($row);?>'>选择</a>
        <?php } ?>
      </td>
    </tr>
    <?php } ?>

    <?php if( count($list)<=0 ){ ?>
    <tr>
      <td colspan='3' align='center'>未找到表单信息</td>
    </tr>
    <?php } ?>
    </tbody>
    <?php if( count($list) > 0 ){ ?>
    <tfoot>
    <tr>
      <td colspan='3' align='center' id="pager_ajax">
        {$pager}
      </td>
    </tr>
    </tfoot>
    <?php } ?>
  </table>
</div>
<script>
  var type = "{$data['gpc']['type']}";
  var query_kwd = "{$data['gpc']['keyword']}";
  var template = "{$data['gpc']['template']}";
  var query_url = "{:U('allform/query_form')}";
  var can_next = true;

  $(document).delegate(".choose_dan_link","click",function(){
    //data-json
    var json_obj = JSON.parse($(this).attr('data-json'));
    $(cur_open_div).val(json_obj.id);
    $(cur_open_name).val(json_obj.form_name);
    layer.close(child_index);
  });

  /*$(document).delegate(".choose_mult_users","click",function(){
   var is_exist = false;
   var json_obj = JSON.parse($(this).attr('data-json'));
   $(cur_open_div).parent().parent().find('.mult_choose_userid').each(function(){
   var uid = $(this).attr("data-uid");
   if(uid == json_obj.user_id){
   is_exist = true;
   }
   });
   if(!is_exist){
   var p_html = '';
   p_html+= '<div class="input-group mult_choose_userid" data-uid="'+json_obj.user_id+'" style="border-radius: 0;float: left;margin: 10px;margin-left:0px;">';
   p_html+= '	<div class="layadmin-text-center choose_user">';
   p_html+= '		<img style="" src="'+json_obj.avatar+'">';
   p_html+= '		<div class="layadmin-maillist-img" style="">'+json_obj.username+'</div>';
   p_html+= '		<button type="button" class="layui-btn layui-btn-sm" onclick="cancle_bind(this)"><i class="layui-icon">&#xe640;</i></button>';
   p_html+= '	</div>';
   p_html+= '</div>';
   $(cur_open_div).parent().after(p_html);
   }
   });*/

  $(".select-btn").click(function(){

    query_kwd = $.trim($("#select-url-kw").val());

    var s_page = $(this).attr('page');
    if(!can_next)
    {
      return false;
    }
    can_next = false;
    $.ajax({
      url:query_url,
      type:'post',
      dataType:'json',
      data:{keyword:query_kwd, page:1,is_ajax:1, template:template, type: type},
      success:function(ret){
        if(ret.status == 0)
        {
          $('.supplyquery tbody').html(ret.result.html);
          $('#pager_ajax').html(ret.result.pager);

        }
        can_next = true;
      }
    })
  });
  $("body").delegate(".pagination a","click",function(){
    var s_page = $(this).attr('page');
    if(!can_next)
    {
      return false;
    }
    can_next = false;
    $.ajax({
      url:query_url,
      type:'post',
      dataType:'json',
      data:{keyword:query_kwd, page:s_page,is_ajax:1, template:template, type: type},
      success:function(ret){
        console.log(ret);
        if(ret.status == 0)
        {
          $('.supplyquery tbody').html(ret.result.html);
          $('#pager_ajax').html(ret.result.pager);

        }
        can_next = true;
      },
      error: function (XMLHttpRequest, textStatus, errorThrown) {
        //弹出报错内容　　
        console.log(XMLHttpRequest.status+XMLHttpRequest.readyState+textStatus);
      }
    })
  })

  $.ajaxSetup({ headers: { 'X-CSRF-TOKEN': $('meta[name="_token"]').attr('content') }})
</script>