printer_mult.html 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. <div style='max-height:500px;overflow:auto;min-width:850px;'>
  2. <div class="input-group layui-row" style="margin:10px;">
  3. <input type="text" placeholder="请输入打印机名称进行搜索" id="select-url-kw" value="" class="form-control">
  4. <span class="input-group-addon btn btn-default select-btn" data-type="url">搜索</span>
  5. </div>
  6. <table class="table table-hover supplyquery" style="min-width:850px;">
  7. <tbody>
  8. <?php foreach($ds as $row){ ?>
  9. <tr>
  10. <td>
  11. {$row['printer_name']}
  12. </td>
  13. <td style="width:80px;"><a href="javascript:;" class="choose_dan_link_printers" data-json='{:json_encode($row);}'>选择</a></td>
  14. </tr>
  15. <?php } ?>
  16. <?php if(count($ds)<=0){ ?>
  17. <tr>
  18. <td colspan='2' align='center'>未找到打印机</td>
  19. </tr>
  20. <?php } ?>
  21. </tbody>
  22. </table>
  23. </div>
  24. <script>
  25. var query_kwd = '{$kwd}';
  26. var query_url = "{:U('printer/query_printer', array('type' => $type,'template' => 'mult','unselect_printerid' => $_GPC['unselect_printerid']))}";
  27. var can_next = true;
  28. $(".select-btn").click(function(){
  29. query_kwd = $.trim($("#select-url-kw").val());
  30. if(!can_next)
  31. {
  32. return false;
  33. }
  34. can_next = false;
  35. $.ajax({
  36. url:query_url,
  37. type:'post',
  38. dataType:'json',
  39. data:{keyword:query_kwd,is_ajax:1},
  40. success:function(ret){
  41. if(ret.code == 0)
  42. {
  43. $('.supplyquery tbody').html(ret.html);
  44. // $('#pager_ajax').html(ret.pager);
  45. }
  46. can_next = true;
  47. }
  48. })
  49. });
  50. $(document).delegate(".choose_dan_link_printers","click",function(){
  51. //data-json
  52. var json_obj = JSON.parse($(this).attr('data-json'));
  53. var p_html = '';
  54. p_html+= '<div class="input-group mult_choose_printerid" data-printerid="'+json_obj.printerid+'" style="border-radius: 0;float: left;margin: 10px;margin-left:0px;width: 20%;">';
  55. p_html+= ' <div class="layadmin-text-center choose_user">';
  56. p_html+= ' <div class="layadmin-name" style="">'+json_obj.printer_name+'</div>';
  57. p_html+= ' <button type="button" class="layui-btn layui-btn-sm" onclick="cancle_bind(this)"><i class="layui-icon">&#xe640;</i></button>';
  58. p_html+= ' </div>';
  59. p_html+= '</div>';
  60. //$(cur_open_div).parent().siblings().remove();
  61. var can_tr = true;
  62. $(cur_open_div).parent().siblings().each(function(){
  63. if( $(this).attr('data-printerid') == json_obj.printerid )
  64. {
  65. can_tr = false;
  66. }
  67. })
  68. if( can_tr )
  69. {
  70. $(cur_open_div).parent().after(p_html);
  71. //$(cur_open_div).val( json_obj.gid );
  72. }
  73. //layer.close(layer.index);
  74. });
  75. </script>