query_normal_mult_recipe.html 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  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. <img src='{:tomedia($row['thumb'])}' style='width:30px;height:30px;padding1px;border:1px solid #ccc' />
  12. <?php if($row['is_finished'] == 1){ ?>
  13. <span style="color:red;">[已结束]&nbsp;</span>
  14. <?php } ?>
  15. <?php if($row['is_grab'] == 1){ ?>
  16. <span style="color:red;">[已抢光]</span>
  17. <?php } ?>
  18. {$row['goodsname']}
  19. </td>
  20. <td style="width:80px;"><a href="javascript:;" class="choose_dan_link_recipe" data-json='{:json_encode($row);}'>选择</a></td>
  21. </tr>
  22. <?php } ?>
  23. <?php if( count($ds)<=0 ){ ?>
  24. <tr>
  25. <td colspan='4' align='center'>未找到商品</td>
  26. </tr>
  27. <?php } ?>
  28. </tbody>
  29. </table>
  30. </div>
  31. <script>
  32. var query_kwd = '{$kwd}';
  33. var query_url = "{:U('goods/query_normal', array('type' => $type,'template' => 'mult','is_recipe' => 1, 'is_not_hexiao' => $is_not_hexiao,'unselect_goodsid' => $_GPC['unselect_goodsid']))}";
  34. var can_next = true;
  35. $(".select-btn").click(function(){
  36. query_kwd = $.trim($("#select-url-kw").val());
  37. if(!can_next)
  38. {
  39. return false;
  40. }
  41. can_next = false;
  42. $.ajax({
  43. url:query_url,
  44. type:'post',
  45. dataType:'json',
  46. data:{keyword:query_kwd,is_ajax:1},
  47. success:function(ret){
  48. if(ret.code == 0)
  49. {
  50. $('.supplyquery tbody').html(ret.html);
  51. // $('#pager_ajax').html(ret.pager);
  52. }
  53. can_next = true;
  54. }
  55. })
  56. });
  57. $(document).delegate(".choose_dan_link_recipe","click",function(){
  58. //data-json
  59. var json_obj = JSON.parse($(this).attr('data-json'));
  60. var p_html = '';
  61. p_html+= '<div class="input-group mult_choose_goodsid" data-gid="'+json_obj.gid+'" style="border-radius: 0;float: left;margin: 10px;margin-left:0px;width: 22%;">';
  62. p_html+= ' <div class="layadmin-text-center choose_user">';
  63. p_html+= ' <input type="text" class="sp_text" placeholder="食材名称" style="padding-left:5px;margin-bottom:5px;display:block;" name="sp['+json_obj.gid+'][title]" value="" >';
  64. p_html+= ' <img style="" src="'+json_obj.thumb+'">';
  65. p_html+= ' <div class="layadmin-maillist-img" style="">'+json_obj.goodsname+'</div>';
  66. p_html+= ' <button type="button" class="layui-btn layui-btn-sm" onclick="cancle_bind(this)"><i class="layui-icon">&#xe640;</i></button>';
  67. p_html+= ' </div>';
  68. p_html+= '</div>';
  69. //$(cur_open_div).parent().siblings().remove();
  70. var can_tr = true;
  71. $(cur_open_div).parent().siblings().each(function(){
  72. if( $(this).attr('data-gid') == json_obj.gid )
  73. {
  74. can_tr = false;
  75. }
  76. })
  77. if( can_tr )
  78. {
  79. $(cur_open_div).parent().after(p_html);
  80. //$(cur_open_div).val( json_obj.gid );
  81. }
  82. //layer.close(layer.index);
  83. });
  84. </script>