query_normal.html 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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><img src='{:tomedia($row['thumb'])}' style='width:30px;height:30px;padding1px;border:1px solid #ccc' /> {$row['goodsname']}</td>
  11. <td style="width:80px;"><a href="javascript:;" class="choose_dan_link" data-json='{:json_encode($row);}'>选择</a></td>
  12. </tr>
  13. <?php } ?>
  14. <?php if( count($ds)<=0){ ?>
  15. <tr>
  16. <td colspan='4' align='center'>未找到商品</td>
  17. </tr>
  18. <?php } ?>
  19. </tbody>
  20. </table>
  21. </div>
  22. <script>
  23. var query_kwd = '{$kwd}';
  24. var query_url = "{:U('goods/query_normal', array('type'=>$type,'is_not_hexiao' => $is_not_hexiao))}";
  25. var can_next = true;
  26. $(".select-btn").click(function(){
  27. query_kwd = $.trim($("#select-url-kw").val());
  28. if(!can_next)
  29. {
  30. return false;
  31. }
  32. can_next = false;
  33. $.ajax({
  34. url:query_url,
  35. type:'post',
  36. dataType:'json',
  37. data:{keyword:query_kwd,is_ajax:1},
  38. success:function(ret){
  39. if(ret.code == 0)
  40. {
  41. $('.supplyquery tbody').html(ret.html);
  42. // $('#pager_ajax').html(ret.pager);
  43. }
  44. can_next = true;
  45. }
  46. })
  47. });
  48. $(document).delegate(".choose_dan_link","click",function(){
  49. //data-json
  50. var json_obj = JSON.parse($(this).attr('data-json'));
  51. var p_html = '';
  52. p_html+= '<div class="input-group " style="margin: 0;">';
  53. p_html+= ' <div class="layadmin-text-center choose_user">';
  54. p_html+= ' <img style="" src="'+json_obj.thumb+'">';
  55. p_html+= ' <div class="layadmin-maillist-img" style="">'+json_obj.goodsname+'</div>';
  56. p_html+= ' <button type="button" class="layui-btn layui-btn-sm" onclick="cancle_bind(this)"><i class="layui-icon">&#xe640;</i></button>';
  57. p_html+= ' </div>';
  58. p_html+= '</div>';
  59. $(cur_open_div).parent().siblings().remove();
  60. $(cur_open_div).parent().after(p_html);
  61. $(cur_open_div).val( json_obj.gid );
  62. layer.close(layer.index);
  63. });
  64. </script>